diff options
author | наб <[email protected]> | 2022-05-03 19:56:12 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-05-16 15:56:53 -0700 |
commit | 5ac80603bdafef9317b3a815137181667cef8947 (patch) | |
tree | d782083a8dd9a24ea0afd4dd045a6741808ac032 /lib | |
parent | ca3b105cd99198e59fa6f0b74943319ad7eedcde (diff) |
libzfs: constify zfs_strip_partition(), zfs_strip_path()
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #13413
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs.abi | 6 | ||||
-rw-r--r-- | lib/libzfs/libzfs_pool.c | 7 | ||||
-rw-r--r-- | lib/libzutil/os/freebsd/zutil_device_path_os.c | 6 | ||||
-rw-r--r-- | lib/libzutil/os/linux/zutil_device_path_os.c | 8 |
4 files changed, 15 insertions, 12 deletions
diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 40bd6a557..1c7695275 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -5588,12 +5588,12 @@ <return type-id='95e97e5e'/> </function-decl> <function-decl name='zfs_strip_partition' mangled-name='zfs_strip_partition' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_strip_partition'> - <parameter type-id='26a90f95' name='path'/> + <parameter type-id='80f4b756' name='path'/> <return type-id='26a90f95'/> </function-decl> <function-decl name='zfs_strip_path' mangled-name='zfs_strip_path' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_strip_path'> - <parameter type-id='26a90f95' name='path'/> - <return type-id='26a90f95'/> + <parameter type-id='80f4b756' name='path'/> + <return type-id='80f4b756'/> </function-decl> <function-decl name='zfs_get_enclosure_sysfs_path' mangled-name='zfs_get_enclosure_sysfs_path' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_get_enclosure_sysfs_path'> <parameter type-id='80f4b756' name='dev_name'/> diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index ffebf2340..730e6db53 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -4123,7 +4123,8 @@ char * zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, int name_flags) { - char *path, *type; + char *type, *tpath; + const char *path; uint64_t value; char buf[PATH_BUF_LEN]; char tmpbuf[PATH_BUF_LEN * 2]; @@ -4148,7 +4149,9 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &value); (void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)value); path = buf; - } else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) { + } else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &tpath) == 0) { + path = tpath; + if (name_flags & VDEV_NAME_FOLLOW_LINKS) { char *rp = realpath(path, NULL); if (rp) { diff --git a/lib/libzutil/os/freebsd/zutil_device_path_os.c b/lib/libzutil/os/freebsd/zutil_device_path_os.c index ac4748ec7..f93ab9ad7 100644 --- a/lib/libzutil/os/freebsd/zutil_device_path_os.c +++ b/lib/libzutil/os/freebsd/zutil_device_path_os.c @@ -40,7 +40,7 @@ * Note: The caller must free the returned string. */ char * -zfs_strip_partition(char *dev) +zfs_strip_partition(const char *dev) { return (strdup(dev)); } @@ -56,8 +56,8 @@ zfs_append_partition(char *path, size_t max_len) * On FreeBSD we only want to remove "/dev/" from the beginning of * paths if present. */ -char * -zfs_strip_path(char *path) +const char * +zfs_strip_path(const char *path) { if (strncmp(path, _PATH_DEV, sizeof (_PATH_DEV) - 1) == 0) return (path + sizeof (_PATH_DEV) - 1); diff --git a/lib/libzutil/os/linux/zutil_device_path_os.c b/lib/libzutil/os/linux/zutil_device_path_os.c index f24696259..14461b857 100644 --- a/lib/libzutil/os/linux/zutil_device_path_os.c +++ b/lib/libzutil/os/linux/zutil_device_path_os.c @@ -81,7 +81,7 @@ zfs_append_partition(char *path, size_t max_len) * caller must free the returned string */ char * -zfs_strip_partition(char *path) +zfs_strip_partition(const char *path) { char *tmp = strdup(path); char *part = NULL, *d = NULL; @@ -117,7 +117,7 @@ zfs_strip_partition(char *path) * Returned string must be freed. */ static char * -zfs_strip_partition_path(char *path) +zfs_strip_partition_path(const char *path) { char *newpath = strdup(path); char *sd_offset; @@ -148,8 +148,8 @@ zfs_strip_partition_path(char *path) /* * Strip the unwanted portion of a device path. */ -char * -zfs_strip_path(char *path) +const char * +zfs_strip_path(const char *path) { return (strrchr(path, '/') + 1); } |