diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2016-06-10 14:18:24 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2016-06-10 14:19:33 +0000 |
commit | dcaf26487297f51012317be637b89376212aba19 (patch) | |
tree | addbcbfd0f2a7c331a845658172057a16ac74d2c | |
parent | 95dcaa5e90f702f241425cf37f16bb3c99dd8bb6 (diff) | |
download | aports-dcaf26487297f51012317be637b89376212aba19.tar.bz2 aports-dcaf26487297f51012317be637b89376212aba19.tar.xz |
main/mkinitfs: increase max timeout
Avoid boot into error too early.
ref #5479
-rw-r--r-- | main/mkinitfs/0001-nlplug-findfs-increase-max-delay.patch | 125 | ||||
-rw-r--r-- | main/mkinitfs/APKBUILD | 12 | ||||
-rw-r--r-- | main/mkinitfs/git.patch | 37 |
3 files changed, 133 insertions, 41 deletions
diff --git a/main/mkinitfs/0001-nlplug-findfs-increase-max-delay.patch b/main/mkinitfs/0001-nlplug-findfs-increase-max-delay.patch new file mode 100644 index 0000000000..e341103137 --- /dev/null +++ b/main/mkinitfs/0001-nlplug-findfs-increase-max-delay.patch @@ -0,0 +1,125 @@ +From 7389119f3283687adb521aec1397f8db996207fb Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Fri, 10 Jun 2016 14:11:01 +0000 +Subject: [PATCH] nlplug-findfs: increase max delay + +Increase timeout to 5sec if we have not found anything so we don't get +error too early. + +If boot repos are found then reduce the event timeout to 250ms. If +usb_storage is found, then always add 1 second of delay in addition, to +let the usb host settle. +--- + nlplug-findfs.c | 31 +++++++++++++++++++++---------- + 1 file changed, 21 insertions(+), 10 deletions(-) + +diff --git a/nlplug-findfs.c b/nlplug-findfs.c +index b11b7b8..7a3a136 100644 +--- a/nlplug-findfs.c ++++ b/nlplug-findfs.c +@@ -40,6 +40,7 @@ + + #include "arg.h" + ++#define MAX_EVENT_TIMEOUT 5000 + #define DEFAULT_EVENT_TIMEOUT 250 + /* usb mass storage needs 1 sec to settle */ + #define USB_STORAGE_TIMEOUT 1000 +@@ -204,6 +205,7 @@ struct ueventconf { + char *bootrepos; + char *apkovls; + int timeout; ++ int usb_storage_timeout; + int efd; + unsigned running_threads; + pthread_t cryptsetup_tid; +@@ -682,8 +684,6 @@ static int searchdev(struct uevent *ev, const char *searchdev, char *bootrepos, + + static 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').", +@@ -701,10 +701,8 @@ static int dispatch_uevent(struct uevent *ev, struct ueventconf *conf) + conf->modalias_count++; + + /* increase timeout so usb drives gets time to settle */ +- if (strcmp(buf, "usb_storage") == 0) { +- conf->timeout += timeout_increment; +- timeout_increment = 0; +- } ++ if (strcmp(buf, "usb_storage") == 0) ++ conf->usb_storage_timeout = USB_STORAGE_TIMEOUT; + + } else if (ev->devname != NULL) { + if (conf->program_argv[0] != NULL) { +@@ -842,6 +840,7 @@ int main(int argc, char *argv[]) + size_t total_bytes = 0; + int found = 0; + int not_found_is_ok = 0; ++ int timeout = DEFAULT_EVENT_TIMEOUT; + char *program_argv[2] = {0,0}; + pthread_t tid; + sigset_t sigchldmask; +@@ -853,7 +852,8 @@ int main(int argc, char *argv[]) + + memset(&conf, 0, sizeof(conf)); + conf.program_argv = program_argv; +- conf.timeout = DEFAULT_EVENT_TIMEOUT; ++ conf.timeout = MAX_EVENT_TIMEOUT; ++ conf.usb_storage_timeout = 0; + use_lvm = access(LVM_PATH, X_OK) == 0; + use_mdadm = access(MDADM_PATH, X_OK) == 0; + +@@ -890,7 +890,7 @@ int main(int argc, char *argv[]) + conf.program_argv[0] = EARGF(usage(1)); + break; + case 't': +- conf.timeout = atoi(EARGF(usage(1))); ++ timeout = atoi(EARGF(usage(1))); + break; + default: + usage(1); +@@ -921,14 +921,15 @@ int main(int argc, char *argv[]) + conf.running_threads |= TRIGGER_THREAD; + + while (1) { +- r = poll(fds, numfds, (spawn_active(&spawnmgr) || conf.running_threads) ? -1 : conf.timeout); ++ int t = conf.timeout + conf.usb_storage_timeout; ++ r = poll(fds, numfds, (spawn_active(&spawnmgr) || conf.running_threads) ? -1 : t); + if (r == -1) { + if (errno == EINTR || errno == ERESTART) + continue; + err(1, "poll"); + } + if (r == 0) { +- dbg("exit due to timeout (%i)", conf.timeout); ++ dbg("exit due to timeout (%i)", t); + break; + } + +@@ -977,9 +978,19 @@ int main(int argc, char *argv[]) + if ((found & FOUND_DEVICE) + || ((found & FOUND_BOOTREPO) && + (found & FOUND_APKOVL))) { ++ /* we have found everything we need, so no ++ no need to wait for anything new event */ + if (conf.timeout) + dbg("FOUND! setting timeout to 0"); + conf.timeout = 0; ++ conf.usb_storage_timeout= 0; ++ } else if ((found & FOUND_BOOTREPO) && conf.timeout) { ++ /* we have found boot repo, but not apkovl ++ we reduce timeout to default timeout */ ++ if (conf.timeout != timeout) ++ dbg("Setting timeout to %d", ++ timeout); ++ conf.timeout = timeout; + } + } + +-- +2.8.4 + diff --git a/main/mkinitfs/APKBUILD b/main/mkinitfs/APKBUILD index f68c0828e3..62fc99de3e 100644 --- a/main/mkinitfs/APKBUILD +++ b/main/mkinitfs/APKBUILD @@ -2,7 +2,7 @@ pkgname=mkinitfs pkgver=3.0.4 _ver=${pkgver%_git*} -pkgrel=2 +pkgrel=3 pkgdesc="Tool to generate initramfs images for Alpine" url="http://git.alpinelinux.org/cgit/mkinitfs" makedepends="kmod-dev util-linux-dev cryptsetup-dev linux-headers" @@ -12,6 +12,7 @@ triggers="$pkgname.trigger=/usr/share/kernel/*" source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$_ver.tar.xz 0001-nlplug-findfs-increase-the-sys-recursion-limit.patch 0001-init-add-crc32-modules-for-raid5.patch + 0001-nlplug-findfs-increase-max-delay.patch " arch="all" license="GPL2" @@ -39,10 +40,13 @@ package() { } md5sums="682a28918a7013d198b443e6b71a4df2 mkinitfs-3.0.4.tar.xz fc43c3f1f037b6902179c5d90c97c8fc 0001-nlplug-findfs-increase-the-sys-recursion-limit.patch -0253c3bba385402a7bfa4a7e364dd36c 0001-init-add-crc32-modules-for-raid5.patch" +0253c3bba385402a7bfa4a7e364dd36c 0001-init-add-crc32-modules-for-raid5.patch +9e1d633a37d1e6200ec54123e3c37f44 delay.patch" sha256sums="f8ca92bf99870ba3076117e4af7fa56659bf2fa3f18a924507b6541ad10475cc mkinitfs-3.0.4.tar.xz f7b983025fdb5cfdeedced11e445989e384e5d5773daf6f062ec32f8853b3cb7 0001-nlplug-findfs-increase-the-sys-recursion-limit.patch -cfd3db306374cfdb53b894e1397f8a26764553e060ebeac44ca436f20d580982 0001-init-add-crc32-modules-for-raid5.patch" +cfd3db306374cfdb53b894e1397f8a26764553e060ebeac44ca436f20d580982 0001-init-add-crc32-modules-for-raid5.patch +25f65c27228b8fa7ee154c4019768d44616204904c3057197991742b65697ce3 delay.patch" sha512sums="c0d2f6fb9d03afe2358dc0c1aecfd6aac46f69c63ed62e8513d525e54d3abb077f6b91ded4085c10480480d7ee3e8d0d6e91495b723ae2dc78c455d92329021d mkinitfs-3.0.4.tar.xz fae8f44e2e2fa0898ee837fd88de5ada4ffb4c89c65fdda4ed3cffac7ae56c5dd6e01617f9b99a5e4aceacbd53ebdb879ea7c5562ecf0cbd7dce21af2f6da539 0001-nlplug-findfs-increase-the-sys-recursion-limit.patch -3b66146e77fe7ee46a3ae73016148c932954f1460a26eeb65cd430d61c3a2347ddaddc2cdd25a0cbfc3601f715af9c32fc0da2d0b7479d07234546ebfc712476 0001-init-add-crc32-modules-for-raid5.patch" +3b66146e77fe7ee46a3ae73016148c932954f1460a26eeb65cd430d61c3a2347ddaddc2cdd25a0cbfc3601f715af9c32fc0da2d0b7479d07234546ebfc712476 0001-init-add-crc32-modules-for-raid5.patch +f8fe8410d5213bbe605b0abcb07acd0290c26f27967794ebf81c7f468f496ade12acfb3ad7b24eb13166beed33c04190ec93e94d717be67f6ece85016424c88b delay.patch" diff --git a/main/mkinitfs/git.patch b/main/mkinitfs/git.patch deleted file mode 100644 index 02cab69771..0000000000 --- a/main/mkinitfs/git.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff --git a/nlplug-findfs.c b/nlplug-findfs.c -index b11b7b8..fd8f18f 100644 ---- a/nlplug-findfs.c -+++ b/nlplug-findfs.c -@@ -527,6 +527,7 @@ static int find_apkovl(const char *dir, const char *outfile) - char pattern[PATH_MAX]; - glob_t gl; - int r, fd; -+ int rc = 0; - - if (outfile == NULL) - return 0; -@@ -542,13 +543,21 @@ static int find_apkovl(const char *dir, const char *outfile) - err(1, "%s", outfile); - - for (r = 0; r < gl.gl_pathc; r++) { -- dbg("Found apkovl: %s", gl.gl_pathv[r]); -- write(fd, gl.gl_pathv[r], strlen(gl.gl_pathv[r])); -+ const char *filename = gl.gl_pathv[r]; -+ int len = strlen(filename); -+ dbg("Found apkovl: %s", filename); -+ write(fd, filename, len); - write(fd, "\n", 1); -+ /* we don't indicate that apkovl was found if we find -+ encrypted apkovls, because we need load keyboard drivers -+ before we exit -+ */ -+ if (len>=7 && strcmp(&filename[len - 7], ".tar.gz") == 0) -+ rc = FOUND_APKOVL; - } - close(fd); - globfree(&gl); -- return FOUND_APKOVL; -+ return rc; - } - - static int find_bootrepos(const char *devnode, const char *type, |