block: consider currently mounted root device first
authorDaniel Golle <daniel@makrotopia.org>
Tue, 3 Jan 2023 12:07:15 +0000 (13:07 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 28 May 2023 16:01:52 +0000 (17:01 +0100)
First look for the currently mounted root device and then fallback to
looking for rootfs.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
block.c

diff --git a/block.c b/block.c
index 7b2ea8fd31141d87baed7d0ca26372e1ff42daf3..c015fe16a028b3df4c1726620bdf080b85dfd760 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1479,7 +1479,9 @@ static int check_extroot(char *path)
        FILE *fp;
        int err;
 
-       err = find_block_mtd("\"rootfs\"", devpath, sizeof(devpath));
+       err = find_root_dev(devpath, sizeof(devpath));
+       if (err)
+               err = find_block_mtd("\"rootfs\"", devpath, sizeof(devpath));
 #ifdef UBIFS_EXTROOT
        if (err) {
                libubi_t libubi;
@@ -1489,9 +1491,6 @@ static int check_extroot(char *path)
                libubi_close(libubi);
        }
 #endif
-       if (err) {
-               err = find_root_dev(devpath, sizeof(devpath));
-       }
        if (err) {
                ULOG_ERR("extroot: unable to determine root device\n");
                return -1;