e0fe5e7c38
This fixes issues with importing ZFS pools, such as when the ZFS device is a partition that covers the end of the disk. See: https://github.com/zfsonlinux/zfs/issues/1684
119 lines
3.5 KiB
Diff
119 lines
3.5 KiB
Diff
commit 1db7b9be75a225cedb3b7a60028ca5695e5b8346
|
|
Author: Richard Yao <ryao@gentoo.org>
|
|
Date: Wed Aug 28 16:17:47 2013 -0400
|
|
|
|
Fix libblkid support
|
|
|
|
libblkid support is dormant because the autotools check is broken and
|
|
liblkid identifies ZFS vdevs as "zfs_member", not "zfs". We fix that
|
|
with a few changes:
|
|
|
|
First, we fix the libblkid autotools check to do a few things:
|
|
|
|
1. Make a 64MB file, which is the minimum size ZFS permits.
|
|
2. Make 4 fake uberblock entries to make libblkid's check succeed.
|
|
3. Return 0 upon success to make autotools use the success case.
|
|
4. Include stdlib.h to avoid implicit declration of free().
|
|
5. Check for "zfs_member", not "zfs"
|
|
6. Make --with-blkid disable autotools check (avoids Gentoo sandbox violation)
|
|
7. Pass '-lblkid' correctly using LIBS not LDFLAGS.
|
|
|
|
Second, we change the libblkid support to scan for "zfs_member", not
|
|
"zfs".
|
|
|
|
This makes --with-blkid work on Gentoo.
|
|
|
|
Signed-off-by: Richard Yao <ryao@gentoo.org>
|
|
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
|
|
Issue #1751
|
|
|
|
diff --git a/config/user-libblkid.m4 b/config/user-libblkid.m4
|
|
index 276587f..2dd2623 100644
|
|
--- a/config/user-libblkid.m4
|
|
+++ b/config/user-libblkid.m4
|
|
@@ -22,26 +22,45 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [
|
|
[with_blkid=check])
|
|
|
|
LIBBLKID=
|
|
- AS_IF([test "x$with_blkid" != xno],
|
|
+ AS_IF([test "x$with_blkid" = xyes],
|
|
+ [
|
|
+ AC_SUBST([LIBBLKID], ["-lblkid"])
|
|
+ AC_DEFINE([HAVE_LIBBLKID], 1,
|
|
+ [Define if you have libblkid])
|
|
+ ])
|
|
+
|
|
+ AS_IF([test "x$with_blkid" = xcheck],
|
|
[
|
|
AC_CHECK_LIB([blkid], [blkid_get_cache],
|
|
[
|
|
AC_MSG_CHECKING([for blkid zfs support])
|
|
|
|
ZFS_DEV=`mktemp`
|
|
- dd if=/dev/zero of=$ZFS_DEV bs=1024k count=8 \
|
|
+ truncate -s 64M $ZFS_DEV
|
|
+ echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
|
|
+ dd of=$ZFS_DEV bs=1k count=8 \
|
|
+ seek=128 conv=notrunc &>/dev/null \
|
|
>/dev/null 2>/dev/null
|
|
echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
|
|
dd of=$ZFS_DEV bs=1k count=8 \
|
|
seek=132 conv=notrunc &>/dev/null \
|
|
>/dev/null 2>/dev/null
|
|
+ echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
|
|
+ dd of=$ZFS_DEV bs=1k count=8 \
|
|
+ seek=136 conv=notrunc &>/dev/null \
|
|
+ >/dev/null 2>/dev/null
|
|
+ echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
|
|
+ dd of=$ZFS_DEV bs=1k count=8 \
|
|
+ seek=140 conv=notrunc &>/dev/null \
|
|
+ >/dev/null 2>/dev/null
|
|
|
|
- saved_LDFLAGS="$LDFLAGS"
|
|
- LDFLAGS="-lblkid"
|
|
+ saved_LIBS="$LIBS"
|
|
+ LIBS="-lblkid"
|
|
|
|
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
|
[
|
|
#include <stdio.h>
|
|
+ #include <stdlib.h>
|
|
#include <blkid/blkid.h>
|
|
],
|
|
[
|
|
@@ -58,10 +77,10 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [
|
|
return 2;
|
|
}
|
|
|
|
- if (strcmp(value, "zfs")) {
|
|
+ if (strcmp(value, "zfs_member")) {
|
|
free(value);
|
|
blkid_put_cache(cache);
|
|
- return 3;
|
|
+ return 0;
|
|
}
|
|
|
|
free(value);
|
|
@@ -82,7 +101,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [
|
|
[--with-blkid given but unavailable])])
|
|
])
|
|
|
|
- LDFLAGS="$saved_LDFLAGS"
|
|
+ LIBS="$saved_LIBS"
|
|
],
|
|
[
|
|
AS_IF([test "x$with_blkid" != xcheck],
|
|
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
|
|
index 53609f2..d1fa98e 100644
|
|
--- a/lib/libzfs/libzfs_import.c
|
|
+++ b/lib/libzfs/libzfs_import.c
|
|
@@ -965,7 +965,7 @@ zpool_find_import_blkid(libzfs_handle_t *hdl, pool_list_t *pools)
|
|
goto err_blkid2;
|
|
}
|
|
|
|
- err = blkid_dev_set_search(iter, "TYPE", "zfs");
|
|
+ err = blkid_dev_set_search(iter, "TYPE", "zfs_member");
|
|
if (err != 0) {
|
|
(void) zfs_error_fmt(hdl, EZFS_BADCACHE,
|
|
dgettext(TEXT_DOMAIN, "blkid_dev_set_search() %d"), err);
|