diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-04-21 19:00:54 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-04-21 19:00:54 +0200 |
commit | bf50425b58da6f112197f79241dd6d64af2e9ea7 (patch) | |
tree | 2e3f961beaff4d62404ae9191c4c8a996f608cbc | |
parent | 6b795c99e00c92dd29abafcc1022cace7bbcb795 (diff) |
add OPTIONS+="event_timeout=<seconds>"
-rw-r--r-- | test-udev.c | 6 | ||||
-rw-r--r-- | udev.7 | 5 | ||||
-rw-r--r-- | udev.h | 3 | ||||
-rw-r--r-- | udev.xml | 7 | ||||
-rw-r--r-- | udev_device.c | 2 | ||||
-rw-r--r-- | udev_rules.c | 4 | ||||
-rw-r--r-- | udev_rules.h | 1 | ||||
-rw-r--r-- | udev_rules_parse.c | 6 | ||||
-rw-r--r-- | udevd.c | 6 | ||||
-rw-r--r-- | udevtest.c | 4 |
10 files changed, 41 insertions, 3 deletions
diff --git a/test-udev.c b/test-udev.c index e341b74f2f..4ac2d5a889 100644 --- a/test-udev.c +++ b/test-udev.c @@ -105,7 +105,7 @@ int main(int argc, char *argv[], char *envp[]) sigaction(SIGTERM, &act, NULL); /* trigger timeout to prevent hanging processes */ - alarm(UDEV_ALARM_TIMEOUT); + alarm(UDEV_EVENT_TIMEOUT); action = getenv("ACTION"); devpath = getenv("DEVPATH"); @@ -154,6 +154,10 @@ int main(int argc, char *argv[], char *envp[]) retval = udev_device_event(&rules, udev); + /* rules may change/disable the timeout */ + if (udev->event_timeout >= 0) + alarm(udev->event_timeout); + if (retval == 0 && !udev->ignore_device && udev_run) udev_rules_run(udev); @@ -291,6 +291,11 @@ Specify the priority of the created symlinks\. Devices with higher priorities ov Create the device nodes for all available partitions of a block device\. This may be useful for removable media devices where media changes are not detected\. .RE .PP +\fBevent_timeout=\fR +.RS 4 +Number of seconds an event will wait for operations to finish, before it will terminate itself\. +.RE +.PP \fBstring_escape=\fR\fB\fInone|replace\fR\fR .RS 4 Usually control and other possibly unsafe characters are replaced in strings used for device naming\. The mode of replacement can be specified with this option\. @@ -39,7 +39,7 @@ #define ALLOWED_CHARS_INPUT ALLOWED_CHARS_FILE " $%?," #define DEFAULT_PARTITIONS_COUNT 15 -#define UDEV_ALARM_TIMEOUT 180 +#define UDEV_EVENT_TIMEOUT 180 #define UDEV_MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -93,6 +93,7 @@ struct udevice { int ignore_remove; char program_result[PATH_SIZE]; int link_priority; + int event_timeout; int test_run; }; @@ -442,6 +442,13 @@ </listitem> </varlistentry> <varlistentry> + <term><option>event_timeout=</option></term> + <listitem> + <para>Number of seconds an event will wait for operations to finish, before it + will terminate itself.</para> + </listitem> + </varlistentry> + <varlistentry> <term><option>string_escape=<replaceable>none|replace</replaceable></option></term> <listitem> <para>Usually control and other possibly unsafe characters are replaced diff --git a/udev_device.c b/udev_device.c index 6546db482c..cf21191ca0 100644 --- a/udev_device.c +++ b/udev_device.c @@ -53,6 +53,8 @@ struct udevice *udev_device_init(struct udevice *udev) strcpy(udev->owner, "root"); strcpy(udev->group, "root"); + udev->event_timeout = -1; + return udev; } diff --git a/udev_rules.c b/udev_rules.c index d476e699e4..55a079be87 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -1397,6 +1397,10 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev) udev->link_priority = rule->link_priority; info("link_priority=%i\n", udev->link_priority); } + if (rule->event_timeout >= 0) { + udev->event_timeout = rule->event_timeout; + info("event_timeout=%i\n", udev->event_timeout); + } /* apply all_partitions option only at a main block device */ if (rule->partitions && strcmp(udev->dev->subsystem, "block") == 0 && udev->dev->kernel_number[0] == '\0') { diff --git a/udev_rules.h b/udev_rules.h index a84b0de837..da5ac3ea18 100644 --- a/udev_rules.h +++ b/udev_rules.h @@ -97,6 +97,7 @@ struct udev_rule { enum escape_type string_escape; unsigned int link_priority; + int event_timeout; unsigned int partitions; unsigned int last_rule:1, run_ignore_error:1, diff --git a/udev_rules_parse.c b/udev_rules_parse.c index b586df1324..5119b7e84f 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -245,6 +245,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena memset(buf, 0x00, sizeof(buf)); rule = (struct udev_rule *) buf; + rule->event_timeout = -1; linepos = line; valid = 0; @@ -604,6 +605,11 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena rule->link_priority = atoi(&pos[strlen("link_priority=")]); dbg("link priority=%i\n", rule->link_priority); } + pos = strstr(value, "event_timeout="); + if (pos != NULL) { + rule->event_timeout = atoi(&pos[strlen("event_timeout=")]); + dbg("event timout=%i\n", rule->event_timeout); + } pos = strstr(value, "string_escape="); if (pos != NULL) { pos = &pos[strlen("string_escape=")]; @@ -115,7 +115,7 @@ static int udev_event_process(struct udevd_uevent_msg *msg) sigaction(SIGHUP, &act, NULL); /* trigger timeout to prevent hanging processes */ - alarm(UDEV_ALARM_TIMEOUT); + alarm(UDEV_EVENT_TIMEOUT); /* reconstruct event environment from message */ for (i = 0; msg->envp[i]; i++) @@ -131,6 +131,10 @@ static int udev_event_process(struct udevd_uevent_msg *msg) retval = udev_device_event(&rules, udev); + /* rules may change/disable the timeout */ + if (udev->event_timeout >= 0) + alarm(udev->event_timeout); + /* run programs collected by RUN-key*/ if (retval == 0 && !udev->ignore_device && udev_run) retval = udev_rules_run(udev); diff --git a/udevtest.c b/udevtest.c index 8beba217ea..d5e90b02c6 100644 --- a/udevtest.c +++ b/udevtest.c @@ -183,6 +183,10 @@ int udevtest(int argc, char *argv[], char *envp[]) info("looking at device '%s' from subsystem '%s'\n", udev->dev->devpath, udev->dev->subsystem); retval = udev_device_event(&rules, udev); + + if (udev->event_timeout >= 0) + info("custom event timeout: %i\n", udev->event_timeout); + if (retval == 0 && !udev->ignore_device && udev_run) { struct name_entry *name_loop; |