aboutsummaryrefslogtreecommitdiffstats
path: root/nlplug-findfs.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2015-10-09 08:00:44 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2015-10-09 08:00:44 +0000
commit6e60376d7096e8d1d74a90a571513a487a188f35 (patch)
treed461c88a992e22d3ecf8b067f76ab42380619b91 /nlplug-findfs.c
parent2aeed4fdf55d94f2fdb08107108a3e79fda1aee9 (diff)
downloadmkinitfs-6e60376d7096e8d1d74a90a571513a487a188f35.tar.bz2
mkinitfs-6e60376d7096e8d1d74a90a571513a487a188f35.tar.xz
nlplug-findfs: allow user to override timeout with -t option
Diffstat (limited to 'nlplug-findfs.c')
-rw-r--r--nlplug-findfs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/nlplug-findfs.c b/nlplug-findfs.c
index e07cff6..9b145d5 100644
--- a/nlplug-findfs.c
+++ b/nlplug-findfs.c
@@ -37,7 +37,7 @@
#include "arg.h"
-#define EVENT_TIMEOUT 2000
+#define DEFAULT_EVENT_TIMEOUT 250
#define FOUND_DEVICE 0x1
#define FOUND_BOOTREPO 0x2
@@ -87,6 +87,7 @@ struct ueventconf {
int fork_count;
char *bootrepos;
char *apkovls;
+ int timeout;
};
@@ -604,6 +605,7 @@ void usage(int rc)
" -d enable debugging ouput\n"
" -f SUBSYSTEM filter subsystem\n"
" -p PROGRAM use PROGRAM as handler for every event with DEVNAME\n"
+ " -t TIMEOUT timeout after TIMEOUT milliseconds without uevents\n"
"\n", argv0);
exit(rc);
@@ -623,6 +625,7 @@ int main(int argc, char *argv[])
memset(&conf, 0, sizeof(conf));
conf.program_argv = program_argv;
+ conf.timeout = DEFAULT_EVENT_TIMEOUT;
argv0 = strrchr(argv[0], '/');
if (argv0++ == NULL)
argv0 = argv[0];
@@ -652,6 +655,9 @@ int main(int argc, char *argv[])
case 'p':
conf.program_argv[0] = EARGF(usage(1));
break;
+ case 't':
+ conf.timeout = atoi(EARGF(usage(1)));
+ break;
default:
usage(1);
} ARGEND;
@@ -669,7 +675,7 @@ int main(int argc, char *argv[])
pthread_create(&tid, NULL, trigger_thread, &fds[1].fd);
- while ((r = poll(fds, numfds, EVENT_TIMEOUT)) > 0) {
+ while ((r = poll(fds, numfds, conf.timeout)) > 0) {
size_t len;
struct iovec iov;
char cbuf[CMSG_SPACE(sizeof(struct ucred))];