summaryrefslogtreecommitdiff
path: root/libsysfs/sysfs_utils.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2005-03-27 00:09:05 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 23:54:59 -0700
commit93ca11e4be8f4414f09ba60d9d8c77ec8ff2ec3b (patch)
tree169e52b65c926dc290ac6173df3a91b50541549e /libsysfs/sysfs_utils.c
parent69b5c2ca514122eaf08bdc9aadc1b365697d73ef (diff)
[PATCH] libsysfs: remove trailing slash on SYSFS_PATH override
Diffstat (limited to 'libsysfs/sysfs_utils.c')
-rw-r--r--libsysfs/sysfs_utils.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/libsysfs/sysfs_utils.c b/libsysfs/sysfs_utils.c
index 9f6e18f665..210c2a086d 100644
--- a/libsysfs/sysfs_utils.c
+++ b/libsysfs/sysfs_utils.c
@@ -30,20 +30,16 @@
*/
int sysfs_remove_trailing_slash(char *path)
{
- char *c = NULL;
+ size_t len;
if (!path) {
errno = EINVAL;
return 1;
}
- c = strrchr(path, '/');
- if (c == NULL) {
- dprintf("Invalid path %s\n", path);
- errno = EINVAL;
- return 1;
- }
- if (*(c+1) == '\0')
- *c = '\0';
+
+ len = strlen(path);
+ while (len > 0 && path[len-1] == '/')
+ path[--len] = '\0';
return 0;
}
@@ -64,6 +60,7 @@ int sysfs_get_mnt_path(char *mnt_path, size_t len)
sysfs_path_env = getenv(SYSFS_PATH_ENV);
if (sysfs_path_env != NULL) {
safestrcpymax(mnt_path, sysfs_path_env, len);
+ sysfs_remove_trailing_slash(mnt_path);
return 0;
}
safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);