summaryrefslogtreecommitdiff
path: root/usr/src/lib/libzfs/common/libzfs_import.c
diff options
context:
space:
mode:
authorEric Schrock <Eric.Schrock@Sun.COM>2009-10-21 16:03:06 -0700
committerEric Schrock <Eric.Schrock@Sun.COM>2009-10-21 16:03:06 -0700
commit096d22d43da2758693a6df66ce7d9ab54c9d464c (patch)
treeb8425c2c1973621ead490969138ea2a8ebc6513f /usr/src/lib/libzfs/common/libzfs_import.c
parent807e8f10a5bd74064a2c6ed98b73c845df2f834e (diff)
downloadillumos-joyent-096d22d43da2758693a6df66ce7d9ab54c9d464c.tar.gz
6893087 removing and inserting a faulted vdev clears faulted state
6893088 new ereports need to be generated when clearing a vdev 6893090 clearing a vdev should automatically detach spare 6893099 zpool_clear_label() would be useful
Diffstat (limited to 'usr/src/lib/libzfs/common/libzfs_import.c')
-rw-r--r--usr/src/lib/libzfs/common/libzfs_import.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c
index f5793390ea..8705361b6c 100644
--- a/usr/src/lib/libzfs/common/libzfs_import.c
+++ b/usr/src/lib/libzfs/common/libzfs_import.c
@@ -898,6 +898,36 @@ zpool_read_label(int fd, nvlist_t **config)
}
/*
+ * Given a file descriptor, clear (zero) the label information. This function
+ * is currently only used in the appliance stack as part of the ZFS sysevent
+ * module.
+ */
+int
+zpool_clear_label(int fd)
+{
+ struct stat64 statbuf;
+ int l;
+ vdev_label_t *label;
+ uint64_t size;
+
+ if (fstat64(fd, &statbuf) == -1)
+ return (0);
+ size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
+
+ if ((label = calloc(sizeof (vdev_label_t), 1)) == NULL)
+ return (-1);
+
+ for (l = 0; l < VDEV_LABELS; l++) {
+ if (pwrite64(fd, label, sizeof (vdev_label_t),
+ label_offset(size, l)) != sizeof (vdev_label_t))
+ return (-1);
+ }
+
+ free(label);
+ return (0);
+}
+
+/*
* Given a list of directories to search, find all pools stored on disk. This
* includes partial pools which are not available to import. If no args are
* given (argc is 0), then the default directory (/dev/dsk) is searched.