summaryrefslogtreecommitdiff
path: root/namedev.c
diff options
context:
space:
mode:
authordsteklof@us.ibm.com <dsteklof@us.ibm.com>2003-10-21 01:19:14 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:01:42 -0700
commitfe3fe3b29ffbc7d0ce7dca6a371da31d8b3ff7f8 (patch)
treefd2071c7c28b780d1509f32d8cc93c41405eceb2 /namedev.c
parent3370fb2152d5c812ed4a48b9108a97b446713c9d (diff)
[PATCH] new version of libsysfs patch
Here's the patch applying the latest libsysfs. - adds the latest libsysfs code to udev * new code includes dlist implementation, a generic linked list implementation. Needed our own because LGPL * rearranged structures * provided more functions for accessing directory and attributes - gets rid of ->directory->path references in namedev.c - replaces sysfs_get_value_from_attributes with sysfs_get_classdev_attr
Diffstat (limited to 'namedev.c')
-rw-r--r--namedev.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/namedev.c b/namedev.c
index ac05fd88e4..c21a5be7ad 100644
--- a/namedev.c
+++ b/namedev.c
@@ -547,7 +547,7 @@ static int get_attr(struct sysfs_class_device *class_dev, struct device_attr *at
attr->mode = 0;
if (class_dev->sysdevice) {
- dbg_parse("class_dev->sysdevice->directory->path = '%s'", class_dev->sysdevice->directory->path);
+ dbg_parse("class_dev->sysdevice->path = '%s'", class_dev->sysdevice->path);
dbg_parse("class_dev->sysdevice->bus_id = '%s'", class_dev->sysdevice->bus_id);
} else {
dbg_parse("class_dev->name = '%s'", class_dev->name);
@@ -557,19 +557,21 @@ static int get_attr(struct sysfs_class_device *class_dev, struct device_attr *at
switch (dev->type) {
case LABEL:
{
- char *temp;
+ struct sysfs_attribute *tmpattr = NULL;
+ struct sysfs_class_device *class_dev_parent = NULL;
+ char *temp = NULL;
dbg_parse("LABEL: match file '%s' with value '%s'",
dev->sysfs_file, dev->sysfs_value);
/* try to find the attribute in the class device directory */
- temp = sysfs_get_value_from_attributes(class_dev->directory->attributes, dev->sysfs_file);
- if (temp)
+ tmpattr = sysfs_get_classdev_attr(class_dev, dev->sysfs_file);
+ if (tmpattr)
goto label_found;
/* look in the class device device directory if present */
if (class_dev->sysdevice) {
- temp = sysfs_get_value_from_attributes(class_dev->sysdevice->directory->attributes, dev->sysfs_file);
- if (temp)
+ tmpattr = sysfs_get_classdev_attr(class_dev, dev->sysfs_file);
+ if (tmpattr)
goto label_found;
}
@@ -577,14 +579,13 @@ static int get_attr(struct sysfs_class_device *class_dev, struct device_attr *at
* as block partitions don't point to the physical device. Need to fix that
* up in the kernel...
*/
- if (strstr(class_dev->directory->path, "block")) {
+ if (strstr(class_dev->path, "block")) {
dbg_parse("looking at block device...");
- if (isdigit(class_dev->directory->path[strlen(class_dev->directory->path)-1])) {
+ if (isdigit(class_dev->path[strlen(class_dev->path)-1])) {
char path[SYSFS_PATH_MAX];
- struct sysfs_class_device *class_dev_parent;
dbg_parse("really is a partition...");
- strcpy(path, class_dev->directory->path);
+ strcpy(path, class_dev->path);
temp = strrchr(path, '/');
*temp = 0x00;
dbg_parse("looking for a class device at '%s'", path);
@@ -596,35 +597,36 @@ static int get_attr(struct sysfs_class_device *class_dev, struct device_attr *at
dbg_parse("class_dev_parent->name = %s", class_dev_parent->name);
/* try to find the attribute in the class device directory */
- temp = sysfs_get_value_from_attributes(class_dev_parent->directory->attributes, dev->sysfs_file);
- if (temp) {
- //sysfs_close_class_device(class_dev_parent);
+ tmpattr = sysfs_get_classdev_attr(class_dev_parent, dev->sysfs_file);
+ if (tmpattr)
goto label_found;
- }
/* look in the class device device directory if present */
if (class_dev_parent->sysdevice) {
- temp = sysfs_get_value_from_attributes(class_dev_parent->sysdevice->directory->attributes, dev->sysfs_file);
- if (temp) {
- // sysfs_close_class_device(class_dev_parent);
+ tmpattr = sysfs_get_classdev_attr(class_dev_parent, dev->sysfs_file);
+ if (tmpattr)
goto label_found;
- }
}
}
}
+ if (class_dev_parent)
+ sysfs_close_class_device(class_dev_parent);
+
continue;
label_found:
- temp[strlen(temp)-1] = 0x00;
- dbg_parse("file '%s' found with value '%s' compare with '%s'", dev->sysfs_file, temp, dev->sysfs_value);
- if (strcmp(dev->sysfs_value, temp) != 0)
+ tmpattr->value[strlen(tmpattr->value)-1] = 0x00;
+ dbg_parse("file '%s' found with value '%s' compare with '%s'", dev->sysfs_file, tmpattr->value, dev->sysfs_value);
+ if (strcmp(dev->sysfs_value, tmpattr->value) != 0) {
+ if (class_dev_parent)
+ sysfs_close_class_device(class_dev_parent);
continue;
+ }
strcpy(attr->name, dev->attr.name);
- if (isdigit(class_dev->directory->path[strlen(class_dev->directory->path)-1])) {
- temp[0] = class_dev->directory->path[strlen(class_dev->directory->path)-1];
- temp[1] = 0x00;
+ if (isdigit(class_dev->path[strlen(class_dev->path)-1])) {
+ temp = &class_dev->path[strlen(class_dev->path)-1];
strcat(attr->name, temp);
}
if (dev->attr.mode != 0) {
@@ -635,6 +637,8 @@ label_found:
dbg_parse("file '%s' with value '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
dev->sysfs_file, dev->sysfs_value, attr->name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
+ if (class_dev_parent)
+ sysfs_close_class_device(class_dev_parent);
goto done;
break;
}
@@ -646,7 +650,7 @@ label_found:
found = 0;
if (!class_dev->sysdevice)
continue;
- strcpy(path, class_dev->sysdevice->directory->path);
+ strcpy(path, class_dev->sysdevice->path);
temp = strrchr(path, '/');
dbg_parse("NUMBER path = '%s'", path);
dbg_parse("NUMBER temp = '%s' id = '%s'", temp, dev->id);
@@ -682,7 +686,7 @@ label_found:
if (!class_dev->sysdevice)
continue;
found = 0;
- strcpy(path, class_dev->sysdevice->directory->path);
+ strcpy(path, class_dev->sysdevice->path);
temp = strrchr(path, '/');
dbg_parse("TOPOLOGY path = '%s'", path);
dbg_parse("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);