summaryrefslogtreecommitdiff
path: root/libsysfs/sysfs_utils.c
diff options
context:
space:
mode:
authordsteklof@us.ibm.com <dsteklof@us.ibm.com>2003-12-02 00:48:01 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:04 -0700
commitedcd336477880368915245a4b7ddd1bca5940b30 (patch)
tree7fbc2147d115ec6dc1050e41a2647bce2c7e957c /libsysfs/sysfs_utils.c
parentbc1530c65c282e27eb60de797291ca45c2d8cda2 (diff)
[PATCH] another patch for path problem
The quick patch I sent you yesterday fixes it in one location, but there are other points in the library that calls sysfs_get_mnt_path. We need to address all the areas in the library where paths are used. The following patch is a band-aid until we can get a proper path management in the library.
Diffstat (limited to 'libsysfs/sysfs_utils.c')
-rw-r--r--libsysfs/sysfs_utils.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/libsysfs/sysfs_utils.c b/libsysfs/sysfs_utils.c
index 4e96051c78..627e618dce 100644
--- a/libsysfs/sysfs_utils.c
+++ b/libsysfs/sysfs_utils.c
@@ -77,6 +77,23 @@ static int sysfs_get_fs_mnt_path(const unsigned char *fs_type,
}
/*
+ * sysfs_trailing_slash: checks if there's a trailing slash to path
+ * @path: path to check
+ * returns 1 if true and 0 if not
+ */
+int sysfs_trailing_slash(unsigned char *path)
+{
+ unsigned char *s = NULL;
+
+ if (path == NULL)
+ return 0;
+ s = &path[strlen(path)-1];
+ if (strncmp(s, "/", 1) == 0)
+ return 1;
+ return 0;
+}
+
+/*
* sysfs_get_mnt_path: Gets the sysfs mount point.
* @mnt_path: place to put "sysfs" mount point
* @len: size of mnt_path
@@ -226,6 +243,8 @@ struct dlist *sysfs_open_subsystem_list(unsigned char *name)
return NULL;
}
+ if (sysfs_trailing_slash(sysfs_path) == 0)
+ strcat(sysfs_path, "/");
strcat(sysfs_path, name);
dir = sysfs_open_directory(sysfs_path);
if (dir == NULL) {
@@ -301,7 +320,9 @@ struct dlist *sysfs_open_bus_devices_list(unsigned char *name)
return NULL;
}
- strcat(sysfs_path, SYSFS_BUS_DIR);
+ if (sysfs_trailing_slash(sysfs_path) == 0)
+ strcat(sysfs_path, "/");
+ strcat(sysfs_path, SYSFS_BUS_NAME);
strcat(sysfs_path, "/");
strcat(sysfs_path, name);
strcat(sysfs_path, SYSFS_DEVICES_DIR);