diff mbox series

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

Message ID 20220312150905.2665-1-musashino.open@gmail.com
State New
Headers show
Series [fstools,v2] partname: check "PARTLABEL" in root= parameter | expand

Commit Message

INAGAKI Hiroshi March 12, 2022, 3:09 p.m. UTC
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@gmail.com>
---
 libfstools/partname.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

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);
 	}