diff --git a/lib/libzutil/os/linux/zutil_device_path_os.c b/lib/libzutil/os/linux/zutil_device_path_os.c index 14461b857b54..cfd4bfbf1e2c 100644 --- a/lib/libzutil/os/linux/zutil_device_path_os.c +++ b/lib/libzutil/os/linux/zutil_device_path_os.c @@ -151,7 +151,15 @@ zfs_strip_partition_path(const char *path) const char * zfs_strip_path(const char *path) { - return (strrchr(path, '/') + 1); + size_t spath_count; + const char *const *spaths = zpool_default_search_paths(&spath_count); + + for (size_t i = 0; i < spath_count; ++i) + if (strncmp(path, spaths[i], strlen(spaths[i])) == 0 && + path[strlen(spaths[i])] == '/') + return (path + strlen(spaths[i]) + 1); + + return (path); } /*