From e5432e3f5601126ec8c19bbb5a8c62268d5c0148 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 9 Oct 2015 09:56:11 +0000 Subject: nlplug-findfs: increase timeout if usb-storage was found usb storage need some time to settle, we increase the timeout with 2 seconds if we detext usb-storage. --- nlplug-findfs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nlplug-findfs.c b/nlplug-findfs.c index 9b145d5..be112d9 100644 --- a/nlplug-findfs.c +++ b/nlplug-findfs.c @@ -37,7 +37,8 @@ #include "arg.h" -#define DEFAULT_EVENT_TIMEOUT 250 +#define DEFAULT_EVENT_TIMEOUT 250 +#define USB_STORAGE_TIMEOUT 2000 #define FOUND_DEVICE 0x1 #define FOUND_BOOTREPO 0x2 @@ -74,6 +75,7 @@ struct uevent { char *devname; char *major; char *minor; + char *driver; char devnode[256]; }; @@ -475,6 +477,8 @@ int searchdev(char *devname, const char *searchdev, char *bootrepos, int dispatch_uevent(struct uevent *ev, struct ueventconf *conf) { + static int timeout_increment = USB_STORAGE_TIMEOUT; + if (conf->subsystem_filter && ev->subsystem && strcmp(ev->subsystem, conf->subsystem_filter) != 0) { dbg("subsystem '%s' filtered out (by '%s').", @@ -489,6 +493,10 @@ int dispatch_uevent(struct uevent *ev, struct ueventconf *conf) load_kmod(ev->modalias); conf->modalias_count++; + } else if (ev->driver != NULL && strcmp(ev->driver, "usb-storage") == 0) { + conf->timeout += timeout_increment; + timeout_increment = 0; + } else if (ev->devname != NULL) { if (conf->program_argv[0] != NULL) { run_child(conf->program_argv); @@ -557,6 +565,8 @@ int process_uevent(char *buf, const size_t len, struct ueventconf *conf) ev.major = value; } else if (strcmp(key, "MINOR") == 0) { ev.minor = value; + } else if (strcmp(key, "DRIVER") == 0) { + ev.driver = value; } if (strcmp(key, "PATH")) { -- cgit v1.2.3