X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=namedev_parse.c;h=5b8c5ab2d6989a32d8648b6ce048128116d8f144;hb=6fbecf3547a02be2475f275d6862ed9dcfcce2fe;hp=73828a83b2f864d436c222d1085779db74bacd78;hpb=af4b05d4917fdfa55eff3d8d53a830464d8162a1;p=elogind.git diff --git a/namedev_parse.c b/namedev_parse.c index 73828a83b..5b8c5ab2d 100644 --- a/namedev_parse.c +++ b/namedev_parse.c @@ -36,7 +36,7 @@ #include #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; } @@ -113,7 +121,7 @@ void dump_perm_dev_list(void) dump_perm_dev(dev); } -/* extract possible KEY{attr} or KEY_attr */ +/* extract possible KEY{attr} */ static char *get_key_attribute(char *str) { char *pos; @@ -132,13 +140,6 @@ static char *get_key_attribute(char *str) return attr; } - attr = strchr(str, '_'); - if (attr != NULL) { - attr++; - dbg("attribute='%s'", attr); - return attr; - } - return NULL; } @@ -258,6 +259,18 @@ static int namedev_parse_rules(const char *filename, void *data) continue; } + if (strcasecmp(temp2, FIELD_SUBSYSTEM) == 0) { + strfieldcpy(dev.subsystem, temp3); + valid = 1; + continue; + } + + if (strcasecmp(temp2, FIELD_DRIVER) == 0) { + strfieldcpy(dev.driver, temp3); + valid = 1; + continue; + } + if (strcasecmp(temp2, FIELD_PROGRAM) == 0) { program_given = 1; strfieldcpy(dev.program, temp3); @@ -273,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;