]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: remove WAIT_FOR key 434/head
authorKay Sievers <kay@vrfy.org>
Tue, 30 Jun 2015 17:54:37 +0000 (19:54 +0200)
committerKay Sievers <kay@vrfy.org>
Tue, 30 Jun 2015 17:57:40 +0000 (19:57 +0200)
This facility was never a proper solution, but only papered over
real bugs in the kernel. There are no known sysfs "timing bugs"
since a long time.

man/udev.xml
src/udev/udev-rules.c
test/rule-syntax-check.py

index 4c2e13ee7bb65d92cfaba169f3075a572ba5b952..2e1655bf553137da4c5309f38e7de37a1b00c57c 100644 (file)
           </listitem>
         </varlistentry>
 
-        <varlistentry>
-          <term><varname>WAIT_FOR</varname></term>
-          <listitem>
-            <para>Wait for a file to become available or until a timeout of
-            10 seconds expires. The path is relative to the sysfs device;
-            if no path is specified, this waits for an attribute to appear.</para>
-          </listitem>
-        </varlistentry>
-
         <varlistentry>
           <term><varname>OPTIONS</varname></term>
           <listitem>
index 8ebc061eb179c02e0a3baa90f87304aa346ea6af..86531a21b6016588c52ca0656c2df1d765772339 100644 (file)
@@ -682,41 +682,6 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi
         return 0;
 }
 
-#define WAIT_LOOP_PER_SECOND                50
-static int wait_for_file(struct udev_device *dev, const char *file, int timeout) {
-        char filepath[UTIL_PATH_SIZE];
-        char devicepath[UTIL_PATH_SIZE];
-        struct stat stats;
-        int loop = timeout * WAIT_LOOP_PER_SECOND;
-
-        /* a relative path is a device attribute */
-        devicepath[0] = '\0';
-        if (file[0] != '/') {
-                strscpyl(devicepath, sizeof(devicepath), udev_device_get_syspath(dev), NULL);
-                strscpyl(filepath, sizeof(filepath), devicepath, "/", file, NULL);
-                file = filepath;
-        }
-
-        while (--loop) {
-                const struct timespec duration = { 0, 1000 * 1000 * 1000 / WAIT_LOOP_PER_SECOND };
-
-                /* lookup file */
-                if (stat(file, &stats) == 0) {
-                        log_debug("file '%s' appeared after %i loops", file, (timeout * WAIT_LOOP_PER_SECOND) - loop-1);
-                        return 0;
-                }
-                /* make sure, the device did not disappear in the meantime */
-                if (devicepath[0] != '\0' && stat(devicepath, &stats) != 0) {
-                        log_debug("device disappeared while waiting for '%s'", file);
-                        return -2;
-                }
-                log_debug("wait for '%s' for %i mseconds", file, 1000 / WAIT_LOOP_PER_SECOND);
-                nanosleep(&duration, NULL);
-        }
-        log_debug("waiting for '%s' failed", file);
-        return -1;
-}
-
 static int attr_subst_subdir(char *attr, size_t len) {
         bool found = false;
 
@@ -1397,15 +1362,6 @@ static int add_rule(struct udev_rules *rules, char *line,
                         continue;
                 }
 
-                if (streq(key, "WAIT_FOR") || streq(key, "WAIT_FOR_SYSFS")) {
-                        if (op == OP_REMOVE) {
-                                log_error("invalid WAIT_FOR/WAIT_FOR_SYSFS operation");
-                                goto invalid;
-                        }
-                        rule_add_key(&rule_tmp, TK_M_WAITFOR, 0, value, NULL);
-                        continue;
-                }
-
                 if (streq(key, "LABEL")) {
                         if (op == OP_REMOVE) {
                                 log_error("invalid LABEL operation");
@@ -1999,16 +1955,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
                         if (match_key(rules, cur, udev_device_get_driver(event->dev)) != 0)
                                 goto nomatch;
                         break;
-                case TK_M_WAITFOR: {
-                        char filename[UTIL_PATH_SIZE];
-                        int found;
-
-                        udev_event_apply_format(event, rules_str(rules, cur->key.value_off), filename, sizeof(filename));
-                        found = (wait_for_file(event->dev, filename, 10) == 0);
-                        if (!found && (cur->key.op != OP_NOMATCH))
-                                goto nomatch;
-                        break;
-                }
                 case TK_M_ATTR:
                         if (match_attr(rules, event->dev, event, cur) != 0)
                                 goto nomatch;
index 80bbe65bea0d763542f2c3585175fe09141a43ac..e43a3daeb3c31c6a2c0c15d1a4ee5034c6fa23ed 100644 (file)
@@ -35,7 +35,7 @@ else:
 
 no_args_tests = re.compile('(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|RESULT|TEST)\s*(?:=|!)=\s*"([^"]*)"$')
 args_tests = re.compile('(ATTRS?|ENV|TEST){([a-zA-Z0-9/_.*%-]+)}\s*(?:=|!)=\s*"([^"]*)"$')
-no_args_assign = re.compile('(NAME|SYMLINK|OWNER|GROUP|MODE|TAG|PROGRAM|RUN|LABEL|GOTO|WAIT_FOR|OPTIONS|IMPORT)\s*(?:\+=|:=|=)\s*"([^"]*)"$')
+no_args_assign = re.compile('(NAME|SYMLINK|OWNER|GROUP|MODE|TAG|PROGRAM|RUN|LABEL|GOTO|OPTIONS|IMPORT)\s*(?:\+=|:=|=)\s*"([^"]*)"$')
 args_assign = re.compile('(ATTR|ENV|IMPORT|RUN){([a-zA-Z0-9/_.*%-]+)}\s*(=|\+=)\s*"([^"]*)"$')
 
 result = 0