[OpenWrt-Devel] [PATCH fstools] block: always use st_dev (device ID) of / when looking for root

Rafał Miłecki zajec5 at gmail.com
Sat May 2 08:05:11 EDT 2020


From: Rafał Miłecki <rafal at milecki.pl>

Use this method even if UBIFS extroot support is enabled. This is needed
on x86 systems (using F2FS for overlay) as they may still come with F2FS
enabled.

Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2231
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 block.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/block.c b/block.c
index fd35d6b..c4ae88a 100644
--- a/block.c
+++ b/block.c
@@ -1316,8 +1316,7 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen)
 
 	return err;
 }
-
-#else
+#endif
 
 static int find_root_dev(char *buf, int len)
 {
@@ -1348,8 +1347,6 @@ static int find_root_dev(char *buf, int len)
 	return -1;
 }
 
-#endif
-
 static int test_fs_support(const char *name)
 {
 	char line[128], *p;
@@ -1392,26 +1389,25 @@ static int check_extroot(char *path)
 	char devpath[32];
 	char tag[64];
 	FILE *fp;
+	int err;
 
+	err = find_block_mtd("\"rootfs\"", devpath, sizeof(devpath));
 #ifdef UBIFS_EXTROOT
-	if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) {
-		int err = -1;
+	if (err) {
 		libubi_t libubi;
 
 		libubi = libubi_open();
 		err = find_block_ubi_RO(libubi, "rootfs", devpath, sizeof(devpath));
 		libubi_close(libubi);
-		if (err)
-			return -1;
-	}
-#else
-	if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) {
-		if (find_root_dev(devpath, sizeof(devpath))) {
-			ULOG_ERR("extroot: unable to determine root device\n");
-			return -1;
-		}
 	}
 #endif
+	if (err) {
+		err = find_root_dev(devpath, sizeof(devpath));
+	}
+	if (err) {
+		ULOG_ERR("extroot: unable to determine root device\n");
+		return -1;
+	}
 
 	/* Find root device probe_info so we know its UUID */
 	list_for_each_entry(tmp, &devices, list) {
-- 
2.26.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list