aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2016-02-19 15:43:43 -0800
committerBrian Behlendorf <[email protected]>2016-03-09 10:39:22 -0800
commit7d11e37e5502e4dc473a9fe073779823d6ca2495 (patch)
treee40580f53ba6d20d3e6b1d063fa59e0fe2956a66 /lib/libzfs
parent048bb5bd4950b9cb5368ed93d273f0f36e439122 (diff)
Require libblkid
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]> Closes #2448
Diffstat (limited to 'lib/libzfs')
-rw-r--r--lib/libzfs/libzfs_import.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
index d71f343a0..d2eefff53 100644
--- a/lib/libzfs/libzfs_import.c
+++ b/lib/libzfs/libzfs_import.c
@@ -55,12 +55,8 @@
#include <sys/vtoc.h>
#include <sys/dktp/fdisk.h>
#include <sys/efi_partition.h>
-
#include <sys/vdev_impl.h>
-#ifdef HAVE_LIBBLKID
#include <blkid/blkid.h>
-#endif
-
#include "libzfs.h"
#include "libzfs_impl.h"
@@ -1203,7 +1199,6 @@ zpool_clear_label(int fd)
return (0);
}
-#ifdef HAVE_LIBBLKID
/*
* Use libblkid to quickly search for zfs devices
*/
@@ -1273,7 +1268,6 @@ err_blkid2:
err_blkid1:
return (err);
}
-#endif /* HAVE_LIBBLKID */
char *
zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE] = {
@@ -1313,17 +1307,15 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
verify(iarg->poolname == NULL || iarg->guid == 0);
+ /*
+ * Prefer to locate pool member vdevs using libblkid. Only fall
+ * back to legacy directory scanning when explicitly requested or
+ * if an error is encountered when consulted the libblkid cache.
+ */
if (dirs == 0) {
-#ifdef HAVE_LIBBLKID
- /* Use libblkid to scan all device for their type */
- if (zpool_find_import_blkid(hdl, &pools) == 0)
+ if (!iarg->scan && (zpool_find_import_blkid(hdl, &pools) == 0))
goto skip_scanning;
- (void) zfs_error_fmt(hdl, EZFS_BADCACHE,
- dgettext(TEXT_DOMAIN, "blkid failure falling back "
- "to manual probing"));
-#endif /* HAVE_LIBBLKID */
-
dir = zpool_default_import_path;
dirs = DEFAULT_IMPORT_PATH_SIZE;
}
@@ -1465,9 +1457,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
goto error;
}
-#ifdef HAVE_LIBBLKID
skip_scanning:
-#endif
ret = get_configs(hdl, &pools, iarg->can_be_active);
error: