All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] udevd: fix WAIT_FOR_SYSFS
Date: Thu, 23 Oct 2008 18:37:30 +0000	[thread overview]
Message-ID: <4900C46A.7070501@tuffmail.co.uk> (raw)

The wait should be ordered after matching KERNEL, ENV, etc.
but before ATTR.

Without this, WAIT_FOR_SYSFS rules will be applied unconditionally
to all events.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>

diff --git a/udev/udev-rules.c b/udev/udev-rules.c
index 55e27b7..168867b 100644
--- a/udev/udev-rules.c
+++ b/udev/udev-rules.c
@@ -52,7 +52,6 @@ enum token_type {
 	TK_UNDEF,
 	TK_RULE,
 
-	TK_M_WAITFOR,			/* val */
 	TK_M_ACTION,			/* val */
 	TK_M_DEVPATH,			/* val */
 	TK_M_KERNEL,			/* val */
@@ -61,6 +60,7 @@ enum token_type {
 	TK_M_ENV,			/* val, attr */
 	TK_M_SUBSYSTEM,			/* val */
 	TK_M_DRIVER,			/* val */
+	TK_M_WAITFOR,			/* val */
 	TK_M_ATTR,			/* val, attr */
 
 	TK_M_KERNELS,			/* val */
@@ -104,7 +104,6 @@ static const char *token_str[] = {
 	[TK_UNDEF] =			"UNDEF",
 	[TK_RULE] =			"RULE",
 
-	[TK_M_WAITFOR] =		"M WAITFOR",
 	[TK_M_ACTION] =			"M ACTION",
 	[TK_M_DEVPATH] =		"M DEVPATH",
 	[TK_M_KERNEL] =			"M KERNEL",
@@ -113,6 +112,7 @@ static const char *token_str[] = {
 	[TK_M_ENV] =			"M ENV",
 	[TK_M_SUBSYSTEM] =		"M SUBSYSTEM",
 	[TK_M_DRIVER] =			"M DRIVER",
+	[TK_M_WAITFOR] =		"M WAITFOR",
 	[TK_M_ATTR] =			"M ATTR",
 
 	[TK_M_KERNELS] =		"M KERNELS",
@@ -591,12 +591,12 @@ static int rule_add_token(struct rule_tmp *rule_tmp, enum token_type type,
 	mode_t mode = 0000;
 
 	switch (type) {
-	case TK_M_WAITFOR:
 	case TK_M_ACTION:
 	case TK_M_DEVPATH:
 	case TK_M_KERNEL:
 	case TK_M_SUBSYSTEM:
 	case TK_M_DRIVER:
+	case TK_M_WAITFOR:
 	case TK_M_DEVLINK:
 	case TK_M_NAME:
 	case TK_M_KERNELS:
@@ -696,12 +696,12 @@ static void dump_token(struct udev_rules *rules, struct token *token)
 			    &rules->buf[token->rule.label_off]);
 			break;
 		}
-	case TK_M_WAITFOR:
 	case TK_M_ACTION:
 	case TK_M_DEVPATH:
 	case TK_M_KERNEL:
 	case TK_M_SUBSYSTEM:
 	case TK_M_DRIVER:
+	case TK_M_WAITFOR:
 	case TK_M_DEVLINK:
 	case TK_M_NAME:
 	case TK_M_KERNELS:
@@ -1612,18 +1612,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
 			rule = cur;
 			esc = ESCAPE_UNSET;
 			break;
-		case TK_M_WAITFOR:
-			{
-				char filename[UTIL_PATH_SIZE];
-				int found;
-
-				util_strlcpy(filename, &rules->buf[cur->key.value_off], sizeof(filename));
-				udev_event_apply_format(event, filename, sizeof(filename));
-				found = (wait_for_file(event->dev, filename, 10) = 0);
-				if (!found && (cur->key.op != KEY_OP_NOMATCH))
-					goto nomatch;
-				break;
-			}
 		case TK_M_ACTION:
 			if (match_key(rules, cur, udev_device_get_action(event->dev)) != 0)
 				goto nomatch;
@@ -1684,6 +1672,18 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
 			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;
+
+				util_strlcpy(filename, &rules->buf[cur->key.value_off], sizeof(filename));
+				udev_event_apply_format(event, filename, sizeof(filename));
+				found = (wait_for_file(event->dev, filename, 10) = 0);
+				if (!found && (cur->key.op != KEY_OP_NOMATCH))
+					goto nomatch;
+				break;
+			}
 		case TK_M_ATTR:
 			if (match_attr(rules, event->dev, event, cur) != 0)
 				goto nomatch;



             reply	other threads:[~2008-10-23 18:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-23 18:37 Alan Jenkins [this message]
2008-10-23 19:03 ` [PATCH] udevd: fix WAIT_FOR_SYSFS Kay Sievers
2008-10-23 19:12 ` Kay Sievers
2008-10-23 19:56 ` Alan Jenkins
2008-10-25 13:33 ` Kay Sievers
2008-10-25 16:19 ` Alan Jenkins
2008-10-25 17:19 ` Alan Jenkins
2008-10-25 17:46 ` Kay Sievers
2008-10-25 17:48 ` Kay Sievers
2008-10-25 17:57 ` Alan Jenkins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4900C46A.7070501@tuffmail.co.uk \
    --to=alan-jenkins@tuffmail.co.uk \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.