From 8b9e601160712f74ff46313579d0225a7f90ca3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Sat, 2 May 2020 14:05:11 +0200 Subject: [PATCH] block: always use st_dev (device ID) of / when looking for root MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- 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.30.2