[LEDE-DEV] [LEDE-DEV,fstools] mount_extroot: repeat detection for slow devices

sam_ at centrum.sk sam_ at centrum.sk
Sat Feb 10 04:41:49 PST 2018


I'm using extroot on SD card in 4G dongle attached to USB of my TP-Link Archer C2. For reasons unknown to me it started to take more than 10 seconds to show among devices, this patch adds 2 more detection attempts/delays to already existing 5s.
---
diff --git a/block.c b/block.c
index b377429..c01deb0 100644
--- a/block.c
+++ b/block.c
@@ -497,6 +497,15 @@
     return probe_path(path);
 }
 
+static void _add_absent(struct probe_info *pr)
+{
+    struct probe_info *existing;
+    list_for_each_entry(existing, &devices, list)
+        if (!strcasecmp(existing->dev, pr->dev))
+            return;
+    list_add_tail(&pr->list, &devices);
+}
+
 static int _cache_load(const char *path)
 {
     int gl_flags = GLOB_NOESCAPE | GLOB_MARK;
@@ -509,7 +518,7 @@
     for (j = 0; j < gl.gl_pathc; j++) {
         struct probe_info *pr = _probe_path(gl.gl_pathv[j]);
         if (pr)
-            list_add_tail(&pr->list, &devices);
+            _add_absent(pr);
     }
 
     globfree(&gl);
@@ -1407,6 +1416,7 @@
     struct probe_info *pr;
     struct mount *m;
     int err = -1;
+    int delay_count = 3;    // better safe than sorry, 2 should be enough, hell, even 1
 
     /* Load @cfg/etc/config/fstab */
     if (config_load(cfg))
@@ -1426,7 +1436,7 @@
     /* Find block device pointed by the mount config */
     pr = find_block_info(m->uuid, m->label, m->device);
 
-    if (!pr && delay_root){
+    while (!pr && delay_root && delay_count--) {
         ULOG_INFO("extroot: device not present, retrying in %u seconds\n", delay_root);
         sleep(delay_root);
         make_devs();



More information about the Lede-dev mailing list