Skip to content

Commit

Permalink
Revert "discover_cached_paths() should not modify string from nvlist"
Browse files Browse the repository at this point in the history
This reverts commit 8f14d92.
  • Loading branch information
ryao committed Mar 12, 2023
1 parent 8f14d92 commit a40d617
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions lib/libzutil/zutil_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,21 +1565,12 @@ discover_cached_paths(libpc_handle_t *hdl, nvlist_t *nv,
* our directory cache.
*/
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) {
int ret;
char *dir;
boolean_t freestr = B_FALSE;
if ((dl = zfs_dirnamelen(path)) == -1) {
dir = (char *)".";
} else {
if (asprintf(&dir, "%.*s", (int)dl, path) == -1)
return (ENOMEM);
freestr = B_TRUE;
}
ret = zpool_find_import_scan_dir(hdl, lock, cache,
path, 0);
if (freestr)
free(dir);
return (ret);
if ((dl = zfs_dirnamelen(path)) == -1)
path = (char *)".";
else
path[dl] = '\0';
return (zpool_find_import_scan_dir(hdl, lock, cache,
path, 0));
}
return (0);
}
Expand Down

0 comments on commit a40d617

Please sign in to comment.