chiark / gitweb /
[PATCH] fix udev-test/udev-test.pl to work with again
[elogind.git] / namedev_parse.c
index 4afa85cfa991a6dbbb03469f1dd4ce16f06d4ba4..5b8c5ab2d6989a32d8648b6ce048128116d8f144 100644 (file)
@@ -36,7 +36,7 @@
 #include <errno.h>
 
 #include "udev.h"
-#include "udev_lib.h"
+#include "udev_utils.h"
 #include "logging.h"
 #include "namedev.h"
 
@@ -79,12 +79,19 @@ static int add_perm_dev(struct perm_device *new_dev)
        struct perm_device *dev;
        struct perm_device *tmp_dev;
 
-       /* update the values if we already have the device */
+       /* if we already have that entry, just update the values */
        list_for_each_entry(dev, &perm_device_list, node) {
                if (strcmp(new_dev->name, dev->name) != 0)
                        continue;
 
-               set_empty_perms(dev, new_dev->mode, new_dev->owner, new_dev->group);
+               /* don't overwrite values from earlier entries */
+               if (dev->mode == 0000)
+                       dev->mode = new_dev->mode;
+               if (dev->owner[0] == '\0')
+                       strfieldcpy(dev->owner, new_dev->owner);
+               if (dev->owner[0] == '\0')
+                       strfieldcpy(dev->group, new_dev->group);
+
                return 0;
        }
 
@@ -95,7 +102,8 @@ static int add_perm_dev(struct perm_device *new_dev)
 
        memcpy(tmp_dev, new_dev, sizeof(*tmp_dev));
        list_add_tail(&tmp_dev->node, &perm_device_list);
-       //dump_perm_dev(tmp_dev);
+       /* dump_perm_dev(tmp_dev); */
+
        return 0;
 }
 
@@ -278,10 +286,16 @@ static int namedev_parse_rules(const char *filename, void *data)
 
                        if (strncasecmp(temp2, FIELD_NAME, sizeof(FIELD_NAME)-1) == 0) {
                                attr = get_key_attribute(temp2 + sizeof(FIELD_NAME)-1);
-                               if (attr != NULL && strcasecmp(attr, ATTR_PARTITIONS) == 0) {
+                               if (attr != NULL) {
+                                       if (strstr(attr, ATTR_PARTITIONS) != NULL) {
                                                dbg_parse("creation of partition nodes requested");
                                                dev.partitions = PARTITIONS_COUNT;
                                        }
+                                       if (strstr(attr, ATTR_IGNORE_REMOVE) != NULL) {
+                                               dbg_parse("remove event should be ignored");
+                                               dev.ignore_remove = 1;
+                                       }
+                               }
                                strfieldcpy(dev.name, temp3);
                                valid = 1;
                                continue;