diff options
author | mav <mav@FreeBSD.org> | 2016-04-09 20:30:50 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2016-04-09 20:30:50 +0000 |
commit | 6dcdb61ae36b64cef3125daa63d6dc75f5bcdadd (patch) | |
tree | 0cacf4d93390959c44399ffc62398ba6bbc50ff7 /cddl/contrib/opensolaris/lib/libzfs | |
parent | c068b26cc6d12f0ebee2f24534a00b823e8020bb (diff) | |
download | FreeBSD-src-6dcdb61ae36b64cef3125daa63d6dc75f5bcdadd.zip FreeBSD-src-6dcdb61ae36b64cef3125daa63d6dc75f5bcdadd.tar.gz |
MFV r297760: 6418 zpool should have a label clearing command
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Author: Will Andrews <will@firepipe.net>
Closes #83
Closes #32
openzfs/openzfs@9663688425131744221ea99f9e66b9ed964492ae
FreeBSD already had `zpool labelclear` functionality, so this is mostly
just a diff reduction.
MFC after: 1 month
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c | 16 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c | 16 |
2 files changed, 15 insertions, 17 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c index 133cc6f..aa2f142 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c @@ -20,10 +20,10 @@ */ /* - * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright 2015 RackTop Systems. + * Copyright 2016 Nexenta Systems, Inc. */ /* @@ -1099,9 +1099,7 @@ zpool_open_func(void *arg) } /* - * Given a file descriptor, clear (zero) the label information. This function - * is used in the appliance stack as part of the ZFS sysevent module and - * to implement the "zpool labelclear" command. + * Given a file descriptor, clear (zero) the label information. */ int zpool_clear_label(int fd) @@ -1168,7 +1166,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) */ for (i = 0; i < dirs; i++) { tpool_t *t; - char *rdsk; + char rdsk[MAXPATHLEN]; int dfd; boolean_t config_failed = B_FALSE; DIR *dirp; @@ -1184,15 +1182,17 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) *end = 0; pathleft = &path[sizeof (path)] - end; +#ifdef illumos /* * Using raw devices instead of block devices when we're * reading the labels skips a bunch of slow operations during * close(2) processing, so we replace /dev/dsk with /dev/rdsk. */ - if (strcmp(path, "/dev/dsk/") == 0) - rdsk = "/dev/"; + if (strcmp(path, ZFS_DISK_ROOTD) == 0) + (void) strlcpy(rdsk, ZFS_RDISK_ROOTD, sizeof (rdsk)); else - rdsk = path; +#endif + (void) strlcpy(rdsk, path, sizeof (rdsk)); if ((dfd = open64(rdsk, O_RDONLY)) < 0 || (dirp = fdopendir(dfd)) == NULL) { diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index 4dc48fa..658059c 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -20,10 +20,10 @@ */ /* - * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. */ #include <sys/types.h> @@ -49,8 +49,6 @@ static int read_efi_label(nvlist_t *config, diskaddr_t *sb); -#define DISK_ROOT "/dev/dsk" -#define RDISK_ROOT "/dev/rdsk" #define BACKUP_SLICE "s2" typedef struct prop_flags { @@ -2345,7 +2343,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *name) "efi_use_whole_disk")) == NULL) return (-1); - (void) snprintf(path, sizeof (path), "%s/%s", RDISK_ROOT, name); + (void) snprintf(path, sizeof (path), "%s/%s", ZFS_RDISK_ROOT, name); if ((fd = open(path, O_RDWR | O_NDELAY)) < 0) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot " @@ -2421,7 +2419,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags, } if (wholedisk) { - pathname += strlen(DISK_ROOT) + 1; + pathname += strlen(ZFS_DISK_ROOT) + 1; (void) zpool_relabel_disk(hdl, pathname); } } @@ -3411,8 +3409,8 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, } #ifdef illumos - if (strncmp(path, "/dev/dsk/", 9) == 0) - path += 9; + if (strncmp(path, ZFS_DISK_ROOTD, strlen(ZFS_DISK_ROOTD)) == 0) + path += strlen(ZFS_DISK_ROOTD); if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK, &value) == 0 && value) { @@ -3846,7 +3844,7 @@ read_efi_label(nvlist_t *config, diskaddr_t *sb) if (nvlist_lookup_string(config, ZPOOL_CONFIG_PATH, &path) != 0) return (err); - (void) snprintf(diskname, sizeof (diskname), "%s%s", RDISK_ROOT, + (void) snprintf(diskname, sizeof (diskname), "%s%s", ZFS_RDISK_ROOT, strrchr(path, '/')); if ((fd = open(diskname, O_RDONLY|O_NDELAY)) >= 0) { struct dk_gpt *vtoc; @@ -3931,7 +3929,7 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name) start_block = NEW_START_BLOCK; } - (void) snprintf(path, sizeof (path), "%s/%s%s", RDISK_ROOT, name, + (void) snprintf(path, sizeof (path), "%s/%s%s", ZFS_RDISK_ROOT, name, BACKUP_SLICE); if ((fd = open(path, O_RDWR | O_NDELAY)) < 0) { |