diff options
author | Etienne Dechamps <[email protected]> | 2012-07-06 15:44:14 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-07-12 08:58:19 -0700 |
commit | 8adf48642253c2ef9571ece5b233e0bf1f0217a8 (patch) | |
tree | 1ec425d52a1f5490e41f56421244fd340f46ec28 /lib/libzfs/libzfs_pool.c | |
parent | c7f2d69de397b02cc803f541dd2d405e0c284e76 (diff) |
Fix error handling for "zpool online -e".
The error handling code around zpool_relabel_disk() is either inexistent
or wrong. The function call itself is not checked, and
zpool_relabel_disk() is generating error messages from an unitialized
buffer.
Before:
# zpool online -e homez sdb; echo $?
`: cannot relabel 'sdb1': unable to open device: 2
0
After:
# zpool online -e homez sdb; echo $?
cannot expand sdb: cannot relabel 'sdb1': unable to open device: 2
1
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #808
Diffstat (limited to 'lib/libzfs/libzfs_pool.c')
-rw-r--r-- | lib/libzfs/libzfs_pool.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index bb184ed68..08b83c8c1 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -2083,15 +2083,14 @@ zpool_get_physpath(zpool_handle_t *zhp, char *physpath, size_t phypath_size) * the disk to use the new unallocated space. */ static int -zpool_relabel_disk(libzfs_handle_t *hdl, const char *path) +zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg) { - char errbuf[1024]; int fd, error; if ((fd = open(path, O_RDWR|O_DIRECT)) < 0) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot " "relabel '%s': unable to open device: %d"), path, errno); - return (zfs_error(hdl, EZFS_OPENFAILED, errbuf)); + return (zfs_error(hdl, EZFS_OPENFAILED, msg)); } /* @@ -2104,7 +2103,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *path) if (error && error != VT_ENOSPC) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "cannot " "relabel '%s': unable to read disk capacity"), path); - return (zfs_error(hdl, EZFS_NOCAP, errbuf)); + return (zfs_error(hdl, EZFS_NOCAP, msg)); } return (0); } @@ -2122,6 +2121,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags, nvlist_t *tgt; boolean_t avail_spare, l2cache, islog; libzfs_handle_t *hdl = zhp->zpool_hdl; + int error; if (flags & ZFS_ONLINE_EXPAND) { (void) snprintf(msg, sizeof (msg), @@ -2162,7 +2162,9 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags, if (wholedisk) { pathname += strlen(DISK_ROOT) + 1; - (void) zpool_relabel_disk(hdl, pathname); + error = zpool_relabel_disk(hdl, pathname, msg); + if (error != 0) + return (error); } } |