Skip to content

Commit fc24f7c

Browse files
Michael Martinbehlendorf
authored andcommitted
Fix missing vdev names in zpool status output
Commit 858219c makes more sense down below in the 'if (verbose)' section of the code. Initially, buf and path will never point to the same location. Once 'path = buf' is set on a raidz vdev, the code may drop into the verbose section depending on the verbose flag. In here, using a tmpbuf makes sense since now 'buf == path'. This issue does not occur in the upstream Solaris code because their implementations of snprintf() allow for buf and path to be the same address. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #57
1 parent cafa970 commit fc24f7c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/libzfs/libzfs_pool.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,6 +3134,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
31343134
char *path, *devid, *type;
31353135
uint64_t value;
31363136
char buf[PATH_BUF_LEN];
3137+
char tmpbuf[PATH_BUF_LEN];
31373138
vdev_stat_t *vs;
31383139
uint_t vsc;
31393140

@@ -3206,13 +3207,12 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
32063207
* If it's a raidz device, we need to stick in the parity level.
32073208
*/
32083209
if (strcmp(path, VDEV_TYPE_RAIDZ) == 0) {
3209-
char tmpbuf[PATH_BUF_LEN];
32103210

32113211
verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY,
32123212
&value) == 0);
3213-
(void) snprintf(tmpbuf, sizeof (tmpbuf), "%s%llu", path,
3213+
(void) snprintf(buf, sizeof (buf), "%s%llu", path,
32143214
(u_longlong_t)value);
3215-
path = tmpbuf;
3215+
path = buf;
32163216
}
32173217

32183218
/*
@@ -3224,9 +3224,9 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
32243224

32253225
verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID,
32263226
&id) == 0);
3227-
(void) snprintf(buf, sizeof (buf), "%s-%llu", path,
3228-
(u_longlong_t)id);
3229-
path = buf;
3227+
(void) snprintf(tmpbuf, sizeof (tmpbuf), "%s-%llu",
3228+
path, (u_longlong_t)id);
3229+
path = tmpbuf;
32303230
}
32313231
}
32323232

0 commit comments

Comments
 (0)