block: support builtin fstab config
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 17 Feb 2015 19:13:43 +0000 (20:13 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 17 Feb 2015 19:13:47 +0000 (20:13 +0100)
Fall back to /etc/config/fstab if the file on the overlay cannot be loaded.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
block.c

diff --git a/block.c b/block.c
index c29017d..de8a3b7 100644 (file)
--- a/block.c
+++ b/block.c
@@ -410,14 +410,16 @@ static int config_load(char *cfg)
                uci_set_confdir(ctx, path);
        }
 
                uci_set_confdir(ctx, path);
        }
 
-       if (uci_load(ctx, "fstab", &pkg))
-       {
-               char *err;
-               uci_get_errorstr(ctx, &err, "fstab");
-               ERROR("extroot: failed to load %s/etc/config/%s\n",
-                     cfg ? cfg : "", err);
-               free(err);
-               return -1;
+       if (uci_load(ctx, "fstab", &pkg)) {
+               uci_set_confdir(ctx, "/etc/config");
+               if (uci_load(ctx, "fstab", &pkg)) {
+                       char *err;
+                       uci_get_errorstr(ctx, &err, "fstab");
+                       ERROR("extroot: failed to load %s/etc/config/%s\n",
+                             cfg ? cfg : "", err);
+                       free(err);
+                       return -1;
+               }
        }
 
        vlist_update(&mounts);
        }
 
        vlist_update(&mounts);