]> err.no Git - systemd/commitdiff
libudev: device - get_attr_value() -> get_sysattr_value()
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 20 Oct 2008 16:12:36 +0000 (18:12 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 20 Oct 2008 16:12:36 +0000 (18:12 +0200)
extras/usb_id/usb_id.c
udev/Makefile.am
udev/lib/exported_symbols
udev/lib/libudev-device.c
udev/lib/libudev-enumerate.c
udev/lib/libudev.h
udev/lib/test-libudev.c
udev/udev-event.c
udev/udevadm-info.c
udev/udevadm-trigger.c

index 4d5265532dd258011763e6b75477b398a852e260..59cdd40b3101017070fdf751d0374a5683ccad48 100644 (file)
@@ -221,7 +221,7 @@ static int usb_id(struct udev_device *dev)
                return 1;
        }
 
-       if_class = udev_device_get_attr_value(dev_interface, "bInterfaceClass");
+       if_class = udev_device_get_sysattr_value(dev_interface, "bInterfaceClass");
        if (!if_class) {
                info(udev, "%s: cannot get bInterfaceClass attribute\n",
                     udev_device_get_sysname(dev));
@@ -229,7 +229,7 @@ static int usb_id(struct udev_device *dev)
        }
        if_class_num = strtoul(if_class, NULL, 16);
        if (if_class_num == 8) {
-               if_subclass = udev_device_get_attr_value(dev_interface, "bInterfaceSubClass");
+               if_subclass = udev_device_get_sysattr_value(dev_interface, "bInterfaceSubClass");
                if (if_subclass != NULL)
                        protocol = set_usb_mass_storage_ifsubtype(type_str, if_subclass, sizeof(type_str)-1);
        } else {
@@ -266,7 +266,7 @@ static int usb_id(struct udev_device *dev)
                }
 
                /* Generic SPC-2 device */
-               scsi_vendor = udev_device_get_attr_value(dev_scsi, "vendor");
+               scsi_vendor = udev_device_get_sysattr_value(dev_scsi, "vendor");
                if (!scsi_vendor) {
                        info(udev, "%s: cannot get SCSI vendor attribute\n",
                             udev_device_get_sysname(dev_scsi));
@@ -274,7 +274,7 @@ static int usb_id(struct udev_device *dev)
                }
                set_str(vendor_str, scsi_vendor, sizeof(vendor_str)-1);
 
-               scsi_model = udev_device_get_attr_value(dev_scsi, "model");
+               scsi_model = udev_device_get_sysattr_value(dev_scsi, "model");
                if (!scsi_model) {
                        info(udev, "%s: cannot get SCSI model attribute\n",
                             udev_device_get_sysname(dev_scsi));
@@ -282,7 +282,7 @@ static int usb_id(struct udev_device *dev)
                }
                set_str(model_str, scsi_model, sizeof(model_str)-1);
 
-               scsi_type = udev_device_get_attr_value(dev_scsi, "type");
+               scsi_type = udev_device_get_sysattr_value(dev_scsi, "type");
                if (!scsi_type) {
                        info(udev, "%s: cannot get SCSI type attribute\n",
                             udev_device_get_sysname(dev_scsi));
@@ -290,7 +290,7 @@ static int usb_id(struct udev_device *dev)
                }
                set_scsi_type(type_str, scsi_type, sizeof(type_str)-1);
 
-               scsi_rev = udev_device_get_attr_value(dev_scsi, "rev");
+               scsi_rev = udev_device_get_sysattr_value(dev_scsi, "rev");
                if (!scsi_rev) {
                        info(udev, "%s: cannot get SCSI revision attribute\n",
                             udev_device_get_sysname(dev_scsi));
@@ -311,10 +311,10 @@ fallback:
                const char *usb_vendor = NULL;
 
                if (!use_num_info)
-                       usb_vendor = udev_device_get_attr_value(dev_usb, "manufacturer");
+                       usb_vendor = udev_device_get_sysattr_value(dev_usb, "manufacturer");
 
                if (!usb_vendor)
-                       usb_vendor = udev_device_get_attr_value(dev_usb, "idVendor");
+                       usb_vendor = udev_device_get_sysattr_value(dev_usb, "idVendor");
 
                if (!usb_vendor) {
                        info(udev, "No USB vendor information available\n");
@@ -327,10 +327,10 @@ fallback:
                const char *usb_model = NULL;
 
                if (!use_num_info)
-                       usb_model = udev_device_get_attr_value(dev_usb, "product");
+                       usb_model = udev_device_get_sysattr_value(dev_usb, "product");
 
                if (!usb_model)
-                       usb_model = udev_device_get_attr_value(dev_usb, "idProduct");
+                       usb_model = udev_device_get_sysattr_value(dev_usb, "idProduct");
 
                if (!usb_model) {
                        dbg(udev, "No USB model information available\n");
@@ -342,7 +342,7 @@ fallback:
        if (revision_str[0] == '\0') {
                const char *usb_rev;
 
-               usb_rev = udev_device_get_attr_value(dev_usb, "bcdDevice");
+               usb_rev = udev_device_get_sysattr_value(dev_usb, "bcdDevice");
                if (usb_rev)
                        set_str(revision_str, usb_rev, sizeof(revision_str)-1);
        }
@@ -350,7 +350,7 @@ fallback:
        if (serial_str[0] == '\0') {
                const char *usb_serial;
 
-               usb_serial = udev_device_get_attr_value(dev_usb, "serial");
+               usb_serial = udev_device_get_sysattr_value(dev_usb, "serial");
                if (usb_serial)
                        set_str(serial_str, usb_serial, sizeof(serial_str)-1);
        }
index c374942c6e0ba7963a113d537be09aade6157000..faf68d6c4d34ec0883da9b0d8ece97ea5b840ce0 100644 (file)
@@ -17,7 +17,7 @@ common_files = \
        udev-sysdeps.h \
        udev-event.c \
        udev-node.c \
-       udev-rules.c \
+       udev-rules2.c \
        udev-util.c \
        lib/libudev.h \
        lib/libudev-private.h \
index 1fe0cc30befb1843afe55e17ec215c0bfa300991..da84a8939e2fb5f2bbb5735881bbcf91eff9f809 100644 (file)
@@ -32,7 +32,7 @@ udev_device_get_action
 udev_device_get_driver
 udev_device_get_devnum
 udev_device_get_seqnum
-udev_device_get_attr_value
+udev_device_get_sysattr_value
 udev_enumerate_new
 udev_enumerate_ref
 udev_enumerate_unref
@@ -40,8 +40,8 @@ udev_enumerate_get_udev
 udev_enumerate_get_list_entry
 udev_enumerate_add_match_subsystem
 udev_enumerate_add_nomatch_subsystem
-udev_enumerate_add_match_attr
-udev_enumerate_add_nomatch_attr
+udev_enumerate_add_match_sysattr
+udev_enumerate_add_nomatch_sysattr
 udev_enumerate_scan_devices
 udev_enumerate_scan_subsystems
 udev_enumerate_add_syspath
index c030eb058578851682fdbf4356e7db534d5ed167..b54c7271e7f2d3a32e0eb756e72160795df8d6e4 100644 (file)
@@ -60,7 +60,7 @@ struct udev_device {
        int num_fake_partitions;
        int devlink_priority;
        int ignore_remove;
-       struct udev_list_node attr_list;
+       struct udev_list_node sysattr_list;
        int info_loaded;
 };
 
@@ -244,7 +244,7 @@ struct udev_device *device_new(struct udev *udev)
        udev_device->udev = udev;
        udev_list_init(&udev_device->devlinks_list);
        udev_list_init(&udev_device->properties_list);
-       udev_list_init(&udev_device->attr_list);
+       udev_list_init(&udev_device->sysattr_list);
        udev_device->event_timeout = -1;
        /* copy global properties */
        udev_list_entry_foreach(list_entry, udev_get_properties_list_entry(udev))
@@ -610,7 +610,7 @@ void udev_device_unref(struct udev_device *udev_device)
        free(udev_device->driver);
        free(udev_device->devpath_old);
        free(udev_device->physdevpath);
-       udev_list_cleanup_entries(udev_device->udev, &udev_device->attr_list);
+       udev_list_cleanup_entries(udev_device->udev, &udev_device->sysattr_list);
        for (i = 0; i < ARRAY_SIZE(udev_device->envp) && udev_device->envp[i] != NULL; i++)
                free(udev_device->envp[i]);
        info(udev_device->udev, "udev_device: %p released\n", udev_device);
@@ -823,7 +823,7 @@ unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device)
        return udev_device->seqnum;
 }
 
-const char *udev_device_get_attr_value(struct udev_device *udev_device, const char *attr)
+const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr)
 {
        struct udev_list_entry *list_entry;
        char path[UTIL_PATH_SIZE];
@@ -835,25 +835,25 @@ const char *udev_device_get_attr_value(struct udev_device *udev_device, const ch
 
        if (udev_device == NULL)
                return NULL;
-       if (attr == NULL)
+       if (sysattr == NULL)
                return NULL;
 
        /* look for possibly already cached result */
-       udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_device->attr_list)) {
-               if (strcmp(udev_list_entry_get_name(list_entry), attr) == 0) {
+       udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_device->sysattr_list)) {
+               if (strcmp(udev_list_entry_get_name(list_entry), sysattr) == 0) {
                        info(udev_device->udev, "got '%s' (%s) from cache\n",
-                            attr, udev_list_entry_get_value(list_entry));
+                            sysattr, udev_list_entry_get_value(list_entry));
                        return udev_list_entry_get_value(list_entry);
                }
        }
 
        util_strlcpy(path, udev_device_get_syspath(udev_device), sizeof(path));
        util_strlcat(path, "/", sizeof(path));
-       util_strlcat(path, attr, sizeof(path));
+       util_strlcat(path, sysattr, sizeof(path));
 
        if (lstat(path, &statbuf) != 0) {
                info(udev_device->udev, "no attribute '%s', keep negative entry\n", path);
-               udev_list_entry_add(udev_device->udev, &udev_device->attr_list, attr, NULL, 0, 0);
+               udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, NULL, 0, 0);
                goto out;
        }
 
@@ -869,8 +869,8 @@ const char *udev_device_get_attr_value(struct udev_device *udev_device, const ch
                        pos = strrchr(target, '/');
                        if (pos != NULL) {
                                pos = &pos[1];
-                               info(udev_device->udev, "cache '%s' with link value '%s'\n", attr, pos);
-                               list_entry = udev_list_entry_add(udev_device->udev, &udev_device->attr_list, attr, pos, 0, 0);
+                               info(udev_device->udev, "cache '%s' with link value '%s'\n", sysattr, pos);
+                               list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, pos, 0, 0);
                                val = udev_list_entry_get_value(list_entry);
                        }
                }
@@ -902,7 +902,7 @@ const char *udev_device_get_attr_value(struct udev_device *udev_device, const ch
        value[size] = '\0';
        util_remove_trailing_chars(value, '\n');
        info(udev_device->udev, "'%s' has attribute value '%s'\n", path, value);
-       list_entry = udev_list_entry_add(udev_device->udev, &udev_device->attr_list, attr, value, 0, 0);
+       list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, value, 0, 0);
        val = udev_list_entry_get_value(list_entry);
 out:
        return val;
index 7a8c51c0785f86ba1dc2ba53acf508f5c08d3710..b35a82d0ceda8819fece12360eaf4edb3bdf627e 100644 (file)
@@ -35,8 +35,8 @@ static int devices_sort(struct udev_enumerate *udev_enumerate);
 struct udev_enumerate {
        struct udev *udev;
        int refcount;
-       struct udev_list_node attr_match_list;
-       struct udev_list_node attr_nomatch_list;
+       struct udev_list_node sysattr_match_list;
+       struct udev_list_node sysattr_nomatch_list;
        struct udev_list_node subsystem_match_list;
        struct udev_list_node subsystem_nomatch_list;
        struct udev_list_node devices_list;
@@ -60,8 +60,8 @@ struct udev_enumerate *udev_enumerate_new(struct udev *udev)
        udev_enumerate->refcount = 1;
        udev_enumerate->udev = udev;
        udev_list_init(&udev_enumerate->devices_list);
-       udev_list_init(&udev_enumerate->attr_match_list);
-       udev_list_init(&udev_enumerate->attr_nomatch_list);
+       udev_list_init(&udev_enumerate->sysattr_match_list);
+       udev_list_init(&udev_enumerate->sysattr_nomatch_list);
        udev_list_init(&udev_enumerate->subsystem_match_list);
        udev_list_init(&udev_enumerate->subsystem_nomatch_list);
        return udev_enumerate;
@@ -83,8 +83,8 @@ void udev_enumerate_unref(struct udev_enumerate *udev_enumerate)
        if (udev_enumerate->refcount > 0)
                return;
        udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->devices_list);
-       udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->attr_match_list);
-       udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->attr_nomatch_list);
+       udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->sysattr_match_list);
+       udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->sysattr_nomatch_list);
        udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->subsystem_match_list);
        udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->subsystem_nomatch_list);
        free(udev_enumerate);
@@ -130,31 +130,31 @@ int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate,
        return 0;
 }
 
-int udev_enumerate_add_match_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value)
+int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
 {
        if (udev_enumerate == NULL)
                return -EINVAL;
-       if (attr == NULL)
+       if (sysattr == NULL)
                return 0;
        if (udev_list_entry_add(udev_enumerate_get_udev(udev_enumerate),
-                          &udev_enumerate->attr_match_list, attr, value, 1, 0) == NULL)
+                          &udev_enumerate->sysattr_match_list, sysattr, value, 1, 0) == NULL)
                return -ENOMEM;
        return 0;
 }
 
-int udev_enumerate_add_nomatch_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value)
+int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
 {
        if (udev_enumerate == NULL)
                return -EINVAL;
-       if (attr == NULL)
+       if (sysattr == NULL)
                return 0;
        if (udev_list_entry_add(udev_enumerate_get_udev(udev_enumerate),
-                          &udev_enumerate->attr_nomatch_list, attr, value, 1, 0) == NULL)
+                          &udev_enumerate->sysattr_nomatch_list, sysattr, value, 1, 0) == NULL)
                return -ENOMEM;
        return 0;
 }
 
-static int match_attr_value(struct udev *udev, const char *syspath, const char *attr, const char *match_val)
+static int match_sysattr_value(struct udev *udev, const char *syspath, const char *sysattr, const char *match_val)
 {
        struct udev_device *device;
        const char *val = NULL;
@@ -163,7 +163,7 @@ static int match_attr_value(struct udev *udev, const char *syspath, const char *
        device = udev_device_new_from_syspath(udev, syspath);
        if (device == NULL)
                return -EINVAL;
-       val = udev_device_get_attr_value(device, attr);
+       val = udev_device_get_sysattr_value(device, sysattr);
        if (val == NULL)
                goto exit;
        if (match_val == NULL) {
@@ -179,23 +179,23 @@ exit:
        return match;
 }
 
-static int match_attr(struct udev_enumerate *udev_enumerate, const char *syspath)
+static int match_sysattr(struct udev_enumerate *udev_enumerate, const char *syspath)
 {
        struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
        struct udev_list_entry *list_entry;
 
        /* skip list */
-       udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->attr_nomatch_list)) {
-               if (match_attr_value(udev, syspath,
+       udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->sysattr_nomatch_list)) {
+               if (match_sysattr_value(udev, syspath,
                                     udev_list_entry_get_name(list_entry),
                                     udev_list_entry_get_value(list_entry)))
                        return 0;
        }
        /* include list */
-       if (udev_list_get_entry(&udev_enumerate->attr_match_list) != NULL) {
-               udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->attr_match_list)) {
+       if (udev_list_get_entry(&udev_enumerate->sysattr_match_list) != NULL) {
+               udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->sysattr_match_list)) {
                        /* anything that does not match, will make it FALSE */
-                       if (!match_attr_value(udev, syspath,
+                       if (!match_sysattr_value(udev, syspath,
                                              udev_list_entry_get_name(list_entry),
                                              udev_list_entry_get_value(list_entry)))
                                return 0;
@@ -247,7 +247,7 @@ static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
                util_strlcat(filename, "/uevent", sizeof(filename));
                if (stat(filename, &statbuf) != 0)
                        continue;
-               if (!match_attr(udev_enumerate, syspath))
+               if (!match_sysattr(udev_enumerate, syspath))
                        continue;
                udev_list_entry_add(udev, &udev_enumerate->devices_list, syspath, NULL, 1, 1);
        }
index 8949724844997bdba54ff9d437372e550572b0af..041ffd4dd9531ebc3ab348152edb6a80d8c63f10 100644 (file)
@@ -77,7 +77,7 @@ extern const char *udev_device_get_driver(struct udev_device *udev_device);
 extern dev_t udev_device_get_devnum(struct udev_device *udev_device);
 extern const char *udev_device_get_action(struct udev_device *udev_device);
 extern unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
-extern const char *udev_device_get_attr_value(struct udev_device *udev_device, const char *attr);
+extern const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
 
 /* udev and kernel device events */
 struct udev_monitor;
@@ -98,8 +98,8 @@ extern void udev_enumerate_unref(struct udev_enumerate *udev_enumerate);
 extern struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate);
 extern int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
 extern int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
-extern int udev_enumerate_add_match_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value);
-extern int udev_enumerate_add_nomatch_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value);
+extern int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
+extern int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
 extern int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath);
 extern int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate);
 extern int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate);
index ded65cca910c448b5b7f601b56cb44be530772ff..4c3bc16aed8c461a249f2f31955c85ec5511548f 100644 (file)
@@ -97,7 +97,7 @@ static void print_device(struct udev_device *device)
        if (count > 0)
                printf("found %i properties\n", count);
 
-       str = udev_device_get_attr_value(device, "dev");
+       str = udev_device_get_sysattr_value(device, "dev");
        if (str != NULL)
                printf("attr{dev}: '%s'\n", str);
 
index 54006b59270c4477e8b4b8c521fbed8420bf4053..007a14ebe92e31a290f7c241dde5b7eb93948d03 100644 (file)
@@ -141,7 +141,7 @@ int udev_event_apply_subsys_kernel(struct udev_event *udev_event, const char *st
        if (read_value) {
                const char *val;
 
-               val = udev_device_get_attr_value(dev, attr);
+               val = udev_device_get_sysattr_value(dev, attr);
                if (val != NULL)
                        util_strlcpy(result, val, maxsize);
                else
@@ -359,7 +359,7 @@ found:
                                if (value[0] == '\0' && event->dev_parent != NULL && event->dev_parent != event->dev) {
                                        const char *val;
 
-                                       val = udev_device_get_attr_value(event->dev_parent, attr);
+                                       val = udev_device_get_sysattr_value(event->dev_parent, attr);
                                        if (val != NULL)
                                                util_strlcpy(value, val, sizeof(value));
                                }
@@ -371,7 +371,7 @@ found:
 
                                        do {
                                                dbg(event->udev, "looking at '%s'\n", udev_device_get_syspath(dev_parent));
-                                               val = udev_device_get_attr_value(dev_parent, attr);
+                                               val = udev_device_get_sysattr_value(dev_parent, attr);
                                                if (val != NULL) {
                                                        util_strlcpy(value, val, sizeof(value));
                                                        break;
index 78c218eef0b22355d2d08a74c4d76a309b1f3a8a..d30fc0031ce23b8183207e70dadb6520fdfe9f49 100644 (file)
@@ -60,7 +60,7 @@ static void print_all_attributes(struct udev_device *device, const char *key)
                        if (S_ISLNK(statbuf.st_mode))
                                continue;
 
-                       value = udev_device_get_attr_value(device, dent->d_name);
+                       value = udev_device_get_sysattr_value(device, dent->d_name);
                        if (value == NULL)
                                continue;
                        dbg(udev, "attr '%s'='%s'(%zi)\n", dent->d_name, value, len);
index eb46a2983c046a427134d14036eb66d689e72885..e475e409495fdacd209c9d7e4274e3181b39829d 100644 (file)
@@ -156,7 +156,7 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[])
                                val[0] = 0;
                                val = &val[1];
                        }
-                       udev_enumerate_add_match_attr(udev_enumerate, attr, val);
+                       udev_enumerate_add_match_sysattr(udev_enumerate, attr, val);
                        break;
                case 'A':
                        util_strlcpy(attr, optarg, sizeof(attr));
@@ -165,7 +165,7 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[])
                                val[0] = 0;
                                val = &val[1];
                        }
-                       udev_enumerate_add_nomatch_attr(udev_enumerate, attr, val);
+                       udev_enumerate_add_nomatch_sysattr(udev_enumerate, attr, val);
                        break;
                case 'h':
                        printf("Usage: udevadm trigger OPTIONS\n"