chiark / gitweb /
[PATCH] quick fix for libsysfs bus
[elogind.git] / libsysfs / sysfs_device.c
index fbd046f229a297fe5c58ba0d024f28518bba8623..2a5353e6f74ab586063eb0050ca2b6f1cffed362 100644 (file)
@@ -28,6 +28,7 @@ static int confirm_device_bus(struct sysfs_device *dev,
 {
         struct sysfs_link *devlink = NULL;
         unsigned char devpath[SYSFS_PATH_MAX];
 {
         struct sysfs_link *devlink = NULL;
         unsigned char devpath[SYSFS_PATH_MAX];
+       unsigned char *s = NULL;
        int result = 0;
 
         if (busname == NULL || bus_id == NULL)
        int result = 0;
 
         if (busname == NULL || bus_id == NULL)
@@ -36,6 +37,9 @@ static int confirm_device_bus(struct sysfs_device *dev,
         if (sysfs_get_mnt_path(devpath, SYSFS_PATH_MAX) != 0)
                 return -1;
 
         if (sysfs_get_mnt_path(devpath, SYSFS_PATH_MAX) != 0)
                 return -1;
 
+       s = &devpath[strlen(devpath)-1];
+       if (strncmp(s, "/", 1) == 0)
+               *s = '\0';
         strcat(devpath, SYSFS_BUS_DIR);
         strcat(devpath, "/");
         strcat(devpath, busname);
         strcat(devpath, SYSFS_BUS_DIR);
         strcat(devpath, "/");
         strcat(devpath, busname);