forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Historically libblkid support was detected as part of configure and optionally enabled. This was done because at the time support for detecting ZFS pool vdevs had just be added to libblkid and those updated packages were not yet part of many distributions. This is no longer the case and any reasonably current distribution will ship a version of libblkid which can detect ZFS pool vdevs. This patch makes libblkid mandatory at build time and libblkid the preferred method of scanning for ZFS pools. For distributions which include a modern version of libblkid there is no change in behavior. Explicitly scanning the default search paths is still supported and can be enabled with the '-s' command line option. Additionally making libblkid mandatory means that the 'zpool create' command can reliably detect if a specified device has an existing non-ZFS filesystem (ext4, xfs) and print a warning. Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#2448
- Loading branch information
1 parent
d2f3e29
commit 9b37c5c
Showing
7 changed files
with
49 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,13 @@ | ||
dnl # | ||
dnl # Check for ZFS support in libblkid. This test needs to check | ||
dnl # more than if the library exists because we expect there are | ||
dnl # at least 3 flavors of the library out in the wild: | ||
dnl # | ||
dnl # 1) blkid which has no ZFS support | ||
dnl # 2) blkid with ZFS support and a flawed method of probing | ||
dnl # 3) blkid with ZFS support and a working method of probing | ||
dnl # | ||
dnl # To handle this the check first validates that there is a version | ||
dnl # of the library installed. If there is it creates a simulated | ||
dnl # ZFS filesystem and then links a small test app which attempts | ||
dnl # to detect the simualated filesystem type. If it correctly | ||
dnl # identifies the filesystem as ZFS we can safely assume case 3). | ||
dnl # Otherwise we disable blkid support and resort to manual probing. | ||
dnl # Check for libblkid. Basic support for detecting ZFS pools | ||
dnl # has existing in blkid since 2008. | ||
dnl # | ||
AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [ | ||
AC_ARG_WITH([blkid], | ||
[AS_HELP_STRING([--with-blkid], | ||
[support blkid caching @<:@default=check@:>@])], | ||
[], | ||
[with_blkid=check]) | ||
LIBBLKID= | ||
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` | ||
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_LIBS="$LIBS" | ||
LIBS="-lblkid" | ||
AC_RUN_IFELSE([AC_LANG_PROGRAM( | ||
[ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <blkid/blkid.h> | ||
], | ||
[ | ||
blkid_cache cache; | ||
char *value; | ||
if (blkid_get_cache(&cache, NULL) < 0) | ||
return 1; | ||
value = blkid_get_tag_value(cache, "TYPE", | ||
"$ZFS_DEV"); | ||
if (!value) { | ||
blkid_put_cache(cache); | ||
return 2; | ||
} | ||
if (strcmp(value, "zfs_member")) { | ||
free(value); | ||
blkid_put_cache(cache); | ||
return 0; | ||
} | ||
free(value); | ||
blkid_put_cache(cache); | ||
])], | ||
[ | ||
rm -f $ZFS_DEV | ||
AC_MSG_RESULT([yes]) | ||
AC_SUBST([LIBBLKID], ["-lblkid"]) | ||
AC_DEFINE([HAVE_LIBBLKID], 1, | ||
[Define if you have libblkid]) | ||
], | ||
[ | ||
rm -f $ZFS_DEV | ||
AC_MSG_RESULT([no]) | ||
AS_IF([test "x$with_blkid" != xcheck], | ||
[AC_MSG_FAILURE( | ||
[--with-blkid given but unavailable])]) | ||
]) | ||
AC_CHECK_HEADER([blkid/blkid.h], [], [AC_MSG_FAILURE([ | ||
*** blkid.h missing, libblkid-devel package required])]) | ||
LIBS="$saved_LIBS" | ||
], | ||
[ | ||
AS_IF([test "x$with_blkid" != xcheck], | ||
[AC_MSG_FAILURE( | ||
[--with-blkid given but unavailable])]) | ||
] | ||
[]) | ||
]) | ||
AC_SUBST([LIBBLKID], ["-lblkid"]) | ||
AC_DEFINE([HAVE_LIBBLKID], 1, [Define if you have libblkid]) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters