+ {
+ char *temp;
+
+ 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)
+ 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)
+ goto label_found;
+ }
+
+ /* bah, let's go backwards up a level to see if the device is there,
+ * 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")) {
+ dbg_parse("looking at block device...");
+ if (isdigit(class_dev->directory->path[strlen(class_dev->directory->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);
+ temp = strrchr(path, '/');
+ *temp = 0x00;
+ dbg_parse("looking for a class device at '%s'", path);
+ class_dev_parent = sysfs_open_class_device(path);
+ if (class_dev_parent == NULL) {
+ dbg("sysfs_open_class_device at '%s' failed", path);
+ continue;
+ }
+ 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);
+ 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);
+ goto label_found;
+ }
+ }
+
+ }
+ }
+ 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)
+ 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;
+ strcat(attr->name, temp);
+ }
+ if (dev->attr.mode != 0) {
+ attr->mode = dev->attr.mode;
+ strcpy(attr->owner, dev->attr.owner);
+ strcpy(attr->group, dev->attr.group);
+ }
+ dbg_parse("file '%s' with value '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dev->sysfs_file, dev->sysfs_value, attr->name,