{
struct sysfs_link *devlink = NULL;
unsigned char devpath[SYSFS_PATH_MAX];
- unsigned char *s = NULL;
int result = 0;
if (busname == NULL || bus_id == NULL)
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);
+ if (sysfs_trailing_slash(devpath) == 0)
+ strcat(devpath, "/");
+ strcat(devpath, SYSFS_BUS_NAME);
strcat(devpath, "/");
strcat(devpath, busname);
strcat(devpath, SYSFS_DEVICES_DIR);
return NULL;
}
- strcat(rootpath, SYSFS_DEVICES_DIR);
+ if (sysfs_trailing_slash(rootpath) == 0)
+ strcat(rootpath, "/");
+
+ strcat(rootpath, SYSFS_DEVICES_NAME);
strcat(rootpath, "/");
strcat(rootpath, name);
rdir = sysfs_open_directory(rootpath);
dprintf ("Sysfs not supported on this system\n");
return -1;
}
- strcat(bus_path, SYSFS_BUS_DIR);
+ if (sysfs_trailing_slash(bus_path) == 0)
+ strcat(bus_path, "/");
+ strcat(bus_path, SYSFS_BUS_NAME);
strcat(bus_path, "/");
strcat(bus_path, bus);
strcat(bus_path, SYSFS_DEVICES_DIR);