From cf100ca71bf365d8898e97d4ec9dd05c3941cae8 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 18 Apr 2008 21:07:29 +0200 Subject: [PATCH] allow setting of MODE="0000" --- test/udev-test.pl | 10 ++++++++++ udev_rules.c | 10 +++++----- udev_rules.h | 3 +-- udev_rules_parse.c | 3 +-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/test/udev-test.pl b/test/udev-test.pl index 2621e2b1..fee62a64 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -1605,6 +1605,16 @@ EOF exp_name => "found-subdir", rules => < "TEST MODE=0000", + subsys => "block", + devpath => "/block/sda", + exp_name => "sda", + exp_perms => "0:0:0000", + rules => <mode_final && rule->mode != 0000) { - if (rule->mode_operation == KEY_OP_ASSIGN_FINAL) + if (!udev->mode_final && rule->mode.operation != KEY_OP_UNSET) { + if (rule->mode.operation == KEY_OP_ASSIGN_FINAL) udev->mode_final = 1; - udev->mode = rule->mode; - dbg("applied mode=%#o to '%s'", rule->mode, udev->dev->kernel); + udev->mode = strtol(key_val(rule, &rule->mode), NULL, 8); + dbg("applied mode=%#o to '%s'", udev->mode, udev->dev->kernel); } if (!udev->owner_final && rule->owner.operation != KEY_OP_UNSET) { if (rule->owner.operation == KEY_OP_ASSIGN_FINAL) @@ -1534,7 +1534,7 @@ int udev_rules_get_run(struct udev_rules *rules, struct udevice *udev) rule->symlink.operation == KEY_OP_ASSIGN || rule->symlink.operation == KEY_OP_ASSIGN_FINAL || rule->symlink.operation == KEY_OP_ADD || - rule->mode_operation != KEY_OP_UNSET || + rule->mode.operation != KEY_OP_UNSET || rule->owner.operation != KEY_OP_UNSET || rule->group.operation != KEY_OP_UNSET) { dbg("skip rule that names a device"); continue; diff --git a/udev_rules.h b/udev_rules.h index 0ad4ec32..a84b0de8 100644 --- a/udev_rules.h +++ b/udev_rules.h @@ -93,8 +93,7 @@ struct udev_rule { struct key symlink_match; struct key owner; struct key group; - mode_t mode; - enum key_operation mode_operation; + struct key mode; enum escape_type string_escape; unsigned int link_priority; diff --git a/udev_rules_parse.c b/udev_rules_parse.c index ce659d73..6d88354d 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -579,8 +579,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena } if (strcasecmp(key, "MODE") == 0) { - rule->mode = strtol(value, NULL, 8); - rule->mode_operation = operation; + add_rule_key(rule, &rule->mode, operation, value); valid = 1; continue; } -- 2.39.5