aboutsummaryrefslogtreecommitdiffstats
path: root/include/libzfs.h
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2012-10-17 16:58:54 -0700
committerBrian Behlendorf <[email protected]>2012-10-22 08:45:58 -0700
commiteac4720465e54c86ae814667985c8a013ec45b85 (patch)
treefcb3dbf45463e84e6e8fd5bab6701d3794b76547 /include/libzfs.h
parentc7dfc086297b6e7768e94d1eef3afaa58beeb5ec (diff)
Allow 'zpool replace' to use short device names
The 'zpool replace' command would fail when given a short name because unlike on other platforms the short name cannot be deterministically expanded to a single path. Multiple path prefixes must be checked and in addition the partition suffix for whole disks is determined by the prefix. To handle this complexity a zfs_strcmp_pathname() function was added which takes either a short or fully qualified device name. Short names will be expanded using the prefixes in the default import search path, or the ZPOOL_IMPORT_PATH environment variable if it's defined. All posible expansions are then compared against the comparison path. Care is taken to strip redundant slashes to ensure legitimate matches are not missed. In the context of this work the existing zfs_resolve_shortname() function was extended to consider the ZPOOL_IMPORT_PATH when set. The zfs_append_partition() interface was also simplified to take only a single buffer. The vast majority of these changes rework existing Linux specific code which was originally written to accomidate udev. However, there is some minimal cleanup which removes Illumos specific code. This was done to improve readability but the basic flow and intent of the upstream code was maintained. These changes are the logical conclusion of the previos work to adjust the 'zpool import' search behavior, see commit 44867b6a. Signed-off-by: Brian Behlendorf <[email protected]> Closes #544 Closes #976
Diffstat (limited to 'include/libzfs.h')
-rw-r--r--include/libzfs.h22
1 files changed, 6 insertions, 16 deletions
diff --git a/include/libzfs.h b/include/libzfs.h
index 75e149334..e59350c9d 100644
--- a/include/libzfs.h
+++ b/include/libzfs.h
@@ -54,22 +54,11 @@ extern "C" {
/*
* Default device paths
*/
+#define DISK_ROOT "/dev"
+#define UDISK_ROOT "/dev/disk"
-#if defined(__sun__) || defined(__sun)
-#define DISK_ROOT "/dev/dsk"
-#define RDISK_ROOT "/dev/rdsk"
-#define UDISK_ROOT RDISK_ROOT
-#define FIRST_SLICE "s0"
-#define BACKUP_SLICE "s2"
-#endif
-
-#ifdef __linux__
-#define DISK_ROOT "/dev"
-#define RDISK_ROOT DISK_ROOT
-#define UDISK_ROOT "/dev/disk"
-#define FIRST_SLICE "1"
-#define BACKUP_SLICE ""
-#endif
+#define DEFAULT_IMPORT_PATH_SIZE 8
+extern char *zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE];
/*
* libzfs errors
@@ -658,8 +647,9 @@ extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t);
extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *,
zfs_type_t);
extern int zfs_spa_version(zfs_handle_t *, int *);
-extern void zfs_append_partition(const char *path, char *buf, size_t buflen);
+extern int zfs_append_partition(char *path, size_t max_len);
extern int zfs_resolve_shortname(const char *name, char *path, size_t pathlen);
+extern int zfs_strcmp_pathname(char *name, char *cmp_name, int wholedisk);
/*
* Mount support functions.