libzfs: constify zfs_strip_partition(), zfs_strip_path()
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13413
This commit is contained in:
parent
ca3b105cd9
commit
5ac80603bd
|
@ -97,8 +97,8 @@ _LIBZUTIL_H int zfs_append_partition(char *path, size_t max_len);
|
||||||
_LIBZUTIL_H int zfs_resolve_shortname(const char *name, char *path,
|
_LIBZUTIL_H int zfs_resolve_shortname(const char *name, char *path,
|
||||||
size_t pathlen);
|
size_t pathlen);
|
||||||
|
|
||||||
_LIBZUTIL_H char *zfs_strip_partition(char *);
|
_LIBZUTIL_H char *zfs_strip_partition(const char *);
|
||||||
_LIBZUTIL_H char *zfs_strip_path(char *);
|
_LIBZUTIL_H const char *zfs_strip_path(const char *);
|
||||||
|
|
||||||
_LIBZUTIL_H int zfs_strcmp_pathname(const char *, const char *, int);
|
_LIBZUTIL_H int zfs_strcmp_pathname(const char *, const char *, int);
|
||||||
|
|
||||||
|
|
|
@ -5588,12 +5588,12 @@
|
||||||
<return type-id='95e97e5e'/>
|
<return type-id='95e97e5e'/>
|
||||||
</function-decl>
|
</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'>
|
<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'/>
|
<return type-id='26a90f95'/>
|
||||||
</function-decl>
|
</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'>
|
<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'/>
|
<parameter type-id='80f4b756' name='path'/>
|
||||||
<return type-id='26a90f95'/>
|
<return type-id='80f4b756'/>
|
||||||
</function-decl>
|
</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'>
|
<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'/>
|
<parameter type-id='80f4b756' name='dev_name'/>
|
||||||
|
|
|
@ -4123,7 +4123,8 @@ char *
|
||||||
zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
|
zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
|
||||||
int name_flags)
|
int name_flags)
|
||||||
{
|
{
|
||||||
char *path, *type;
|
char *type, *tpath;
|
||||||
|
const char *path;
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
char buf[PATH_BUF_LEN];
|
char buf[PATH_BUF_LEN];
|
||||||
char tmpbuf[PATH_BUF_LEN * 2];
|
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) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &value);
|
||||||
(void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)value);
|
(void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)value);
|
||||||
path = buf;
|
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) {
|
if (name_flags & VDEV_NAME_FOLLOW_LINKS) {
|
||||||
char *rp = realpath(path, NULL);
|
char *rp = realpath(path, NULL);
|
||||||
if (rp) {
|
if (rp) {
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
* Note: The caller must free the returned string.
|
* Note: The caller must free the returned string.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
zfs_strip_partition(char *dev)
|
zfs_strip_partition(const char *dev)
|
||||||
{
|
{
|
||||||
return (strdup(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
|
* On FreeBSD we only want to remove "/dev/" from the beginning of
|
||||||
* paths if present.
|
* paths if present.
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
zfs_strip_path(char *path)
|
zfs_strip_path(const char *path)
|
||||||
{
|
{
|
||||||
if (strncmp(path, _PATH_DEV, sizeof (_PATH_DEV) - 1) == 0)
|
if (strncmp(path, _PATH_DEV, sizeof (_PATH_DEV) - 1) == 0)
|
||||||
return (path + sizeof (_PATH_DEV) - 1);
|
return (path + sizeof (_PATH_DEV) - 1);
|
||||||
|
|
|
@ -81,7 +81,7 @@ zfs_append_partition(char *path, size_t max_len)
|
||||||
* caller must free the returned string
|
* caller must free the returned string
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
zfs_strip_partition(char *path)
|
zfs_strip_partition(const char *path)
|
||||||
{
|
{
|
||||||
char *tmp = strdup(path);
|
char *tmp = strdup(path);
|
||||||
char *part = NULL, *d = NULL;
|
char *part = NULL, *d = NULL;
|
||||||
|
@ -117,7 +117,7 @@ zfs_strip_partition(char *path)
|
||||||
* Returned string must be freed.
|
* Returned string must be freed.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
zfs_strip_partition_path(char *path)
|
zfs_strip_partition_path(const char *path)
|
||||||
{
|
{
|
||||||
char *newpath = strdup(path);
|
char *newpath = strdup(path);
|
||||||
char *sd_offset;
|
char *sd_offset;
|
||||||
|
@ -148,8 +148,8 @@ zfs_strip_partition_path(char *path)
|
||||||
/*
|
/*
|
||||||
* Strip the unwanted portion of a device path.
|
* Strip the unwanted portion of a device path.
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
zfs_strip_path(char *path)
|
zfs_strip_path(const char *path)
|
||||||
{
|
{
|
||||||
return (strrchr(path, '/') + 1);
|
return (strrchr(path, '/') + 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue