chiark / gitweb /
remove all PHYSDEVPATH handling and warning about
[elogind.git] / udev / udev-rules.c
index 3751cbb36d55b311d41a19245cdd92205c15a156..fac418e526a625099d8b96adec4711b50fd2b3fb 100644 (file)
@@ -140,7 +140,7 @@ enum token_type {
        TK_A_IGNORE_DEVICE,
        TK_A_STRING_ESCAPE_NONE,
        TK_A_STRING_ESCAPE_REPLACE,
-       TK_A_INOTIFY_WATCH,
+       TK_A_INOTIFY_WATCH,             /* int */
        TK_A_NUM_FAKE_PART,             /* int */
        TK_A_DEVLINK_PRIO,              /* int */
        TK_A_OWNER,                     /* val */
@@ -183,7 +183,6 @@ struct token {
                        union {
                                unsigned int attr_off;
                                int ignore_error;
-                               int i;
                                unsigned int rule_goto;
                                mode_t  mode;
                                uid_t uid;
@@ -191,6 +190,7 @@ struct token {
                                int num_fake_part;
                                int devlink_prio;
                                int event_timeout;
+                               int watch;
                        };
                } key;
        };
@@ -354,7 +354,6 @@ static void dump_token(struct udev_rules *rules, struct token *token)
        case TK_A_IGNORE_DEVICE:
        case TK_A_STRING_ESCAPE_NONE:
        case TK_A_STRING_ESCAPE_REPLACE:
-       case TK_A_INOTIFY_WATCH:
        case TK_A_LAST_RULE:
        case TK_A_IGNORE_REMOVE:
                dbg(rules->udev, "%s\n", token_str(type));
@@ -363,6 +362,9 @@ static void dump_token(struct udev_rules *rules, struct token *token)
                dbg(rules->udev, "%s %s '%s'(%s) %#o\n",
                    token_str(type), operation_str(op), value, string_glob_str(glob), token->key.mode);
                break;
+       case TK_A_INOTIFY_WATCH:
+               dbg(rules->udev, "%s %u\n", token_str(type), token->key.watch);
+               break;
        case TK_A_NUM_FAKE_PART:
                dbg(rules->udev, "%s %u\n", token_str(type), token->key.num_fake_part);
                break;
@@ -735,7 +737,7 @@ static int import_program_into_properties(struct udev_device *dev, const char *p
 {
        struct udev *udev = udev_device_get_udev(dev);
        char **envp;
-       char result[2048];
+       char result[4096];
        size_t reslen;
        char *line;
 
@@ -1023,7 +1025,6 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
        case TK_A_IGNORE_DEVICE:
        case TK_A_STRING_ESCAPE_NONE:
        case TK_A_STRING_ESCAPE_REPLACE:
-       case TK_A_INOTIFY_WATCH:
        case TK_A_IGNORE_REMOVE:
        case TK_A_LAST_RULE:
                break;
@@ -1031,9 +1032,8 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
                token->key.value_off = add_string(rule_tmp->rules, value);
                token->key.ignore_error = *(int *)data;
                break;
+       case TK_A_INOTIFY_WATCH:
        case TK_A_NUM_FAKE_PART:
-               token->key.num_fake_part = *(int *)data;
-               break;
        case TK_A_DEVLINK_PRIO:
                token->key.devlink_prio = *(int *)data;
                break;
@@ -1137,8 +1137,6 @@ static int add_rule(struct udev_rules *rules, char *line,
 {
        char *linepos;
        char *attr;
-       int physdev = 0;
-       int waitfor = 0;
        struct rule_tmp rule_tmp;
 
        memset(&rule_tmp, 0x00, sizeof(struct rule_tmp));
@@ -1280,8 +1278,6 @@ static int add_rule(struct udev_rules *rules, char *line,
                                err(rules->udev, "error parsing ENV attribute\n");
                                goto invalid;
                        }
-                       if (strncmp(attr, "PHYSDEV", 7) == 0)
-                               physdev = 1;
                        if (op < OP_MATCH_MAX) {
                                if (rule_add_key(&rule_tmp, TK_M_ENV, op, value, attr) != 0)
                                        goto invalid;
@@ -1378,7 +1374,6 @@ static int add_rule(struct udev_rules *rules, char *line,
 
                if (strcasecmp(key, "WAIT_FOR") == 0 || strcasecmp(key, "WAIT_FOR_SYSFS") == 0) {
                        rule_add_key(&rule_tmp, TK_M_WAITFOR, 0, value, NULL);
-                       waitfor = 1;
                        continue;
                }
 
@@ -1516,20 +1511,26 @@ static int add_rule(struct udev_rules *rules, char *line,
                                rule_add_key(&rule_tmp, TK_A_NUM_FAKE_PART, 0, NULL, &num);
                                dbg(rules->udev, "creation of partition nodes requested\n");
                        }
-                       pos = strstr(value, "watch");
+                       pos = strstr(value, "nowatch");
                        if (pos != NULL) {
-                               rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, 0, NULL, NULL);
-                               dbg(rules->udev, "inotify watch of device requested\n");
+                               const int off = 0;
+
+                               rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, 0, NULL, &off);
+                               dbg(rules->udev, "inotify watch of device disabled\n");
+                       } else {
+                               pos = strstr(value, "watch");
+                               if (pos != NULL) {
+                                       const int on = 1;
+
+                                       rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, 0, NULL, &on);
+                                       dbg(rules->udev, "inotify watch of device requested\n");
+                               }
                        }
                        continue;
                }
                err(rules->udev, "unknown key '%s' in %s:%u\n", key, filename, lineno);
        }
 
-       if (physdev && !waitfor)
-               err(rules->udev, "PHYSDEV* values are deprecated and not available on recent kernels, "
-                   "please fix it in %s:%u\n", filename, lineno);
-
        /* add rule token */
        rule_tmp.rule.rule.token_count = 1 + rule_tmp.token_cur;
        if (add_token(rules, &rule_tmp.rule) != 0)
@@ -2254,7 +2255,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                        udev_device_set_num_fake_partitions(event->dev, cur->key.num_fake_part);
                        break;
                case TK_A_INOTIFY_WATCH:
-                       event->inotify_watch = 1;
+                       event->inotify_watch = cur->key.watch;
                        break;
                case TK_A_DEVLINK_PRIO:
                        udev_device_set_devlink_priority(event->dev, cur->key.devlink_prio);