summaryrefslogtreecommitdiff
path: root/lib/sysfs_class.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sysfs_class.c')
-rw-r--r--lib/sysfs_class.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/sysfs_class.c b/lib/sysfs_class.c
index 4fe0b82..b675a5e 100644
--- a/lib/sysfs_class.c
+++ b/lib/sysfs_class.c
@@ -96,8 +96,7 @@ static struct sysfs_class_device *alloc_class_device(void)
*/
static void set_classdev_classname(struct sysfs_class_device *cdev)
{
- char *c, *e, name[SYSFS_PATH_MAX], link[SYSFS_PATH_MAX];
- struct stat stats;
+ char *c, *e, name[SYSFS_NAME_LEN];
int count = 0;
/*
@@ -105,7 +104,7 @@ static void set_classdev_classname(struct sysfs_class_device *cdev)
* Check if this cdev belongs to the newer style subsystem and
* set the classname appropriately.
*/
- memset(name, 0, SYSFS_PATH_MAX);
+ memset(name, 0, SYSFS_NAME_LEN);
safestrcpy(name, cdev->name);
c = strchr(name, ':');
if (c) {
@@ -121,7 +120,9 @@ static void set_classdev_classname(struct sysfs_class_device *cdev)
else
c = strstr(c, "/");
- if (c) {
+ if (c == NULL)
+ safestrcpy(cdev->classname, SYSFS_UNKNOWN);
+ else {
if (*c == '/')
c++;
e = c;
@@ -130,19 +131,6 @@ static void set_classdev_classname(struct sysfs_class_device *cdev)
count++;
}
strncpy(cdev->classname, c, count);
- } else {
- strcpy(link, cdev->path);
- strcat(link, "/subsystem");
- sysfs_get_link(link, name, SYSFS_PATH_MAX);
- if (lstat(name, &stats))
- safestrcpy(cdev->classname, SYSFS_UNKNOWN);
- else {
- c = strrchr(name, '/');
- if (c)
- safestrcpy(cdev->classname, c+1);
- else
- safestrcpy(cdev->classname, SYSFS_UNKNOWN);
- }
}
}