]> err.no Git - systemd/commitdiff
libudev: add global property list
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 16 Oct 2008 11:51:29 +0000 (13:51 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 16 Oct 2008 11:51:29 +0000 (13:51 +0200)
extras/ata_id/Makefile.am
extras/cdrom_id/Makefile.am
extras/edd_id/Makefile.am
extras/floppy/Makefile.am
extras/fstab_import/Makefile.am
extras/scsi_id/Makefile.am
extras/volume_id/Makefile.am
udev/lib/libudev-private.h
udev/lib/libudev.c

index 34ded29ded08ad72435c972ca57d0d652f5dac46..47ab0d6631459ddc3d060eebf3db5f71888a703c 100644 (file)
@@ -8,6 +8,7 @@ ata_id_SOURCES = \
        ata_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
+       ../../udev/lib/libudev-list.c \
        ../../udev/lib/libudev-util.c
 
 dist_man_MANS = \
index f8c4bbff0a549d5871c480cfc311386103bb7ae2..bb97d96dc042b364367cdbdbe720e78f6c08640d 100644 (file)
@@ -12,6 +12,7 @@ cdrom_id_SOURCES = \
        cdrom_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
+       ../../udev/lib/libudev-list.c \
        ../../udev/lib/libudev-util.c
 
 dist_man_MANS = \
index 67199fd235dff12737077b21115f1f3aa8ae38a3..28ff8aa46ebbcf8c609dcb20d6cab553baf0a3b7 100644 (file)
@@ -12,6 +12,7 @@ edd_id_SOURCES = \
        edd_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
+       ../../udev/lib/libudev-list.c \
        ../../udev/lib/libudev-util.c
 
 dist_man_MANS = \
index 357129e33691c02a5b44057be6b602dc70dcfe61..0b154498d07b87a1aed30ab531334efb6bbc154d 100644 (file)
@@ -8,6 +8,7 @@ create_floppy_devices_SOURCES = \
        create_floppy_devices.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
+       ../../udev/lib/libudev-list.c \
        ../../udev/lib/libudev-util.c \
        ../../udev/udev_utils.c
 
index c1204782b5765b237173f660c8cc924a013baab9..d16c681ad1235de8be291ba2e5d4e1eff7c3cecf 100644 (file)
@@ -12,6 +12,7 @@ fstab_import_SOURCES = \
        fstab_import.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
+       ../../udev/lib/libudev-list.c \
        ../../udev/lib/libudev-util.c
 
 distclean-local:
index e6798eea6003f0523e8a3424def6f304fc9da89b..08da1c9de55a8347b483bda4b87cff3965c6807a 100644 (file)
@@ -12,6 +12,7 @@ scsi_id_SOURCES = \
        bsg.h \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
+       ../../udev/lib/libudev-list.c \
        ../../udev/lib/libudev-util.c
 
 dist_sysconf_DATA = \
index 5b68e4321da664cc6bb5d1afa56675dec41cedb3..c58f1a8782ab395798b3e6041b2507feec783a04 100644 (file)
@@ -11,6 +11,7 @@ vol_id_SOURCES = \
        vol_id.c \
        ../../udev/lib/libudev.h \
        ../../udev/lib/libudev.c \
+       ../../udev/lib/libudev-list.c \
        ../../udev/lib/libudev-util.c
 
 vol_id_LDADD = \
index e9f2c9893bd49a914924a2e568679e051c42a56d..60d995aa780e2502273e39b5e650f81385a6b5f1 100644 (file)
@@ -50,6 +50,8 @@ void udev_log(struct udev *udev,
 extern struct udev_device *device_new(struct udev *udev);
 extern const char *udev_get_rules_path(struct udev *udev);
 extern int udev_get_run(struct udev *udev);
+extern struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value);
+extern struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev);
 
 /* libudev-device */
 extern int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath);
index 3f7d0e547e61a774f5ff4c07d00dd2d97ac235cd..c698be6e466c3f7bf48d58a84018f9e0b28553ae 100644 (file)
@@ -38,6 +38,7 @@ struct udev {
        char *sys_path;
        char *dev_path;
        char *rules_path;
+       struct udev_list_node properties_list;
        int log_priority;
        int run;
 };
@@ -102,6 +103,7 @@ struct udev *udev_new(void)
        udev->refcount = 1;
        udev->log_fn = log_stderr;
        udev->log_priority = LOG_ERR;
+       udev_list_init(&udev->properties_list);
        udev->run = 1;
        udev->dev_path = strdup(UDEV_PREFIX "/dev");
        udev->sys_path = strdup("/sys");
@@ -117,6 +119,7 @@ struct udev *udev_new(void)
                free(udev->sys_path);
                udev->sys_path = strdup(env);
                util_remove_trailing_chars(udev->sys_path, '/');
+               udev_add_property(udev, "SYSFS_PATH", udev->sys_path);
        }
 
        env = getenv("UDEV_RUN");
@@ -219,11 +222,12 @@ struct udev *udev_new(void)
                free(udev->dev_path);
                udev->dev_path = strdup(env);
                util_remove_trailing_chars(udev->dev_path, '/');
+               udev_add_property(udev, "UDEV_ROOT", udev->dev_path);
        }
 
        env = getenv("UDEV_LOG");
        if (env != NULL)
-               udev->log_priority = util_log_priority(env);
+               udev_set_log_priority(udev, util_log_priority(env));
 
        if (udev->dev_path == NULL || udev->sys_path == NULL)
                goto err;
@@ -274,6 +278,7 @@ void udev_unref(struct udev *udev)
        udev->refcount--;
        if (udev->refcount > 0)
                return;
+       udev_list_cleanup(udev, &udev->properties_list);
        free(udev->dev_path);
        free(udev->sys_path);
        free(udev->rules_path);
@@ -307,7 +312,11 @@ int udev_get_log_priority(struct udev *udev)
 
 void udev_set_log_priority(struct udev *udev, int priority)
 {
+       char num[32];
+
        udev->log_priority = priority;
+       snprintf(num, sizeof(num), "%u", udev->log_priority);
+       udev_add_property(udev, "UDEV_LOG", num);
 }
 
 const char *udev_get_rules_path(struct udev *udev)
@@ -353,3 +362,22 @@ const char *udev_get_dev_path(struct udev *udev)
                return NULL;
        return udev->dev_path;
 }
+
+struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value)
+{
+       if (value == NULL) {
+               struct udev_list_entry *list_entry;
+
+               list_entry = udev_get_properties_list_entry(udev);
+               list_entry = udev_list_entry_get_by_name(list_entry, key);
+               if (list_entry != NULL)
+                       udev_list_entry_remove(list_entry);
+               return NULL;
+       }
+       return udev_list_entry_add(udev, &udev->properties_list, key, value, 1, 0);
+}
+
+struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev)
+{
+       return udev_list_get_entry(&udev->properties_list);
+}