add OPTIONS+="event_timeout=<seconds>"
This commit is contained in:
parent
6b795c99e0
commit
bf50425b58
|
@ -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);
|
||||
|
||||
|
|
5
udev.7
5
udev.7
|
@ -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\.
|
||||
|
|
3
udev.h
3
udev.h
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
7
udev.xml
7
udev.xml
|
@ -441,6 +441,13 @@
|
|||
detected.</para>
|
||||
</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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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=")];
|
||||
|
|
6
udevd.c
6
udevd.c
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue