block: try to find the root device on both / and /rom
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 3 Jan 2023 11:06:58 +0000 (12:06 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 28 May 2023 16:01:32 +0000 (17:01 +0100)
Sometimes / is already overlay mounted, assume /rom contains the real
rootfs.

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

diff --git a/block.c b/block.c
index 28eac598b37fc7f998e9ed26843fd364968983d8..7b2ea8fd31141d87baed7d0ca26372e1ff42daf3 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1397,14 +1397,14 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen)
 }
 #endif
 
-static int find_root_dev(char *buf, int len)
+static int find_dev(const char *path, char *buf, int len)
 {
        DIR *d;
        dev_t root;
        struct stat s;
        struct dirent *e;
 
-       if (stat("/", &s))
+       if (stat(path, &s))
                return -1;
 
        if (!(d = opendir("/dev")))
@@ -1426,6 +1426,15 @@ static int find_root_dev(char *buf, int len)
        return -1;
 }
 
+static int find_root_dev(char *buf, int len)
+{
+       int err = find_dev("/", buf, len);
+       if (err)
+           err = find_dev("/rom", buf, len);
+
+       return err;
+}
+
 static int test_fs_support(const char *name)
 {
        char line[128], *p;