[PATCH fstools v2] partname: check "PARTLABEL" in root= parameter

INAGAKI Hiroshi musashino.open at gmail.com
Sat Mar 12 07:09:05 PST 2022


This patch adds "PARTLABEL=" checking of root= parameter to
partname_volume_find function.

The Linux Kernel supports "root=PARTLABEL=<label>" syntax, but fstools
doesn't and fail to parse the path to the root device.
So check the parameter and skip parsing, find partition from all block
devices if this syntax is used.

Note:
This change is required for I-O DATA HDL-A/HDL2-A. On they, kernel and
rootfs are stored in the storage device connected to SATA, port1 or
port2 and the path to the partition will be assigned dynamically. So
"root=PARTLABEL=<label>" syntax is required instead of "/dev/sdXN".

Signed-off-by: INAGAKI Hiroshi <musashino.open at gmail.com>
---
 libfstools/partname.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libfstools/partname.c b/libfstools/partname.c
index f59c52e..fd499c7 100644
--- a/libfstools/partname.c
+++ b/libfstools/partname.c
@@ -128,12 +128,13 @@ static struct volume *partname_volume_find(char *name)
 			return NULL;
 	}
 
-	if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam))) {
+	if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam)) &&
+	    strncmp(rootparam, "PARTLABEL=", 10)) {
 		rootdev = rootdevname(rootparam);
-		/* find partition on same device as rootfs */
+		/* root= is not PARTLABEL, find partition on same device as rootfs */
 		snprintf(ueventgstr, sizeof(ueventgstr), "%s/%s/*/uevent", block_dir_name, rootdev);
 	} else {
-		/* no 'root=' kernel cmdline parameter, find on any block device */
+		/* PARTLABEL or no 'root=' kernel cmdline parameter, find on any block device */
 		snprintf(ueventgstr, sizeof(ueventgstr), "%s/*/uevent", block_dir_name);
 	}
 
-- 
2.34.1.windows.1




More information about the openwrt-devel mailing list