aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorнаб <[email protected]>2022-05-03 20:13:22 +0200
committerBrian Behlendorf <[email protected]>2022-05-16 15:56:57 -0700
commit276b08cb0077d7f6c4fe6b735e72740e8e72d572 (patch)
tree52443a6ea8600f8e7a9a037e1b3fe83246201b99 /lib
parent5ac80603bdafef9317b3a815137181667cef8947 (diff)
linux: libzutil: zfs_strip_path: only strip known prefixes
This mirrors FreeBSD: # zpool create -o cachefile= testpsko media/testpsko # zpool create -o cachefile= testpsko2 $PWD/testpsko2 $ ./zpool list -v NAME SIZE ALLOC FREE filling 25.5T 6.85T 18.6T mirror-0 3.64T 500G 3.15T ata-HGST_HUS726T4TALE6L4_V6K2L4RR - - - ata-HGST_HUS726T4TALE6L4_V6K2MHYR - - - raidz1-1 21.8T 6.36T 15.5T ata-HGST_HUS728T8TALE6L4_VDKT237K - - - ata-HGST_HUS728T8TALE6L4_VDGY075D - - - ata-HGST_HUS728T8TALE6L4_VDKVRRJK - - - cache - - - nvme0n1p4 63.0G 12.8G 50.2G tarta-boot 240M 50.0M 190M mirror-0 240M 50.0M 190M tarta-boot - - - tarta-boot-nvme - - - tarta-zoot 55.5G 6.96G 48.5G mirror-0 55.5G 6.96G 48.5G tarta-zoot - - - tarta-zoot-nvme - - - testpsko 39.5G 744K 39.5G media/testpsko1 39.5G 744K 39.5G testpsko2 39.5G 130K 39.5G /home/nabijaczleweli/store/code/zfs/testpsko2 39.5G 130K 39.5G Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13413 Closes #9771
Diffstat (limited to 'lib')
-rw-r--r--lib/libzutil/os/linux/zutil_device_path_os.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libzutil/os/linux/zutil_device_path_os.c b/lib/libzutil/os/linux/zutil_device_path_os.c
index 14461b857..cfd4bfbf1 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);
}
/*