]> err.no Git - systemd/commitdiff
add link_priority to rule options, and store it in database
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 16 Mar 2007 14:16:08 +0000 (15:16 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 16 Mar 2007 14:16:08 +0000 (15:16 +0100)
udev.h
udev_db.c
udev_rules.c
udev_rules.h
udev_rules_parse.c

diff --git a/udev.h b/udev.h
index 7fc7fd3b82acf670ea727c6a38564294d8966805..31542243e2a4188a28be75d975b7ec57abb73097 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -86,6 +86,7 @@ struct udevice {
        int ignore_device;
        int ignore_remove;
        char program_result[PATH_SIZE];
+       int link_priority;
        int test_run;
 };
 
index 13d96894afdd6c9b7cd4effe679285f8f0d1f1b5..5ac016a051e904e819e7279a9431c1261fde54ce 100644 (file)
--- a/udev_db.c
+++ b/udev_db.c
@@ -118,6 +118,8 @@ int udev_db_add_device(struct udevice *udev)
                        name_index(udev->dev->devpath, name_loop->name, 1);
                }
                fprintf(f, "M:%u:%u\n", major(udev->devt), minor(udev->devt));
+               if (udev->link_priority)
+                       fprintf(f, "L:%u\n", udev->link_priority);
                if (udev->partitions)
                        fprintf(f, "A:%u\n", udev->partitions);
                if (udev->ignore_remove)
@@ -198,6 +200,13 @@ int udev_db_get_device(struct udevice *udev, const char *devpath)
                        line[count-2] = '\0';
                        name_list_add(&udev->symlink_list, line, 0);
                        break;
+               case 'L':
+                       if (count > sizeof(line))
+                               count =  sizeof(line);
+                       memcpy(line, &bufline[2], count-2);
+                       line[count-2] = '\0';
+                       udev->link_priority = atoi(line);
+                       break;
                case 'A':
                        if (count > sizeof(line))
                                count =  sizeof(line);
index 7ab3bba71c0361c7433f47b0f05bad28e93fb633..c0f4cd2077b1f643898eeb7e9e9a97cda5982413 100644 (file)
@@ -909,6 +909,10 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev)
                                udev->ignore_remove = 1;
                                dbg("remove event should be ignored");
                        }
+                       if (rule->link_priority) {
+                               udev->link_priority = rule->link_priority;
+                               info("link_priority=%i", udev->link_priority);
+                       }
                        /* apply all_partitions option only at a main block device */
                        if (rule->partitions &&
                            strcmp(udev->dev->subsystem, "block") == 0 && udev->dev->kernel_number[0] == '\0') {
index 56153519d4eaaa3f3d8b5dbfee5912cfb45bea21..7fbf88ba573a1c08b7b8a78ce3b49a5d3936c6c6 100644 (file)
@@ -87,6 +87,7 @@ struct udev_rule {
        mode_t mode;
        enum key_operation mode_operation;
 
+       unsigned int link_priority;
        unsigned int partitions;
        unsigned int last_rule:1,
                     ignore_device:1,
index 5ce91df383dfdb5c924b7008549b6d7b8679d70c..bfbad367e9d41e4dfda8f806e5b737c08099bb3c 100644 (file)
@@ -555,6 +555,8 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena
                }
 
                if (strcasecmp(key, "OPTIONS") == 0) {
+                       const char *pos;
+
                        if (strstr(value, "last_rule") != NULL) {
                                dbg("last rule to be applied");
                                rule->last_rule = 1;
@@ -567,6 +569,11 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena
                                dbg("remove event should be ignored");
                                rule->ignore_remove = 1;
                        }
+                       pos = strstr(value, "link_priority=");
+                       if (pos != NULL) {
+                               rule->link_priority = atoi(&pos[strlen("link_priority=")]);
+                               info("link priority=%i", rule->link_priority);
+                       }
                        if (strstr(value, "all_partitions") != NULL) {
                                dbg("creation of partition nodes requested");
                                rule->partitions = DEFAULT_PARTITIONS_COUNT;