[PATCH fstools] partname: add "fstools_use_partlabel" option to find part from label
INAGAKI Hiroshi
musashino.open at gmail.com
Fri Mar 11 20:05:17 PST 2022
This patch adds "fstools_use_partlabel" option to partname driver.
The Linux Kernel supports "root=PARTLABEL=<label>" syntax, but fstools
doesn't and fail to parse the path to the root device.
To use this syntax, add the option and find from all block devices.
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 | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libfstools/partname.c b/libfstools/partname.c
index f59c52e..7e57311 100644
--- a/libfstools/partname.c
+++ b/libfstools/partname.c
@@ -121,6 +121,7 @@ static struct volume *partname_volume_find(char *name)
char *rootdev = NULL, *devname, *tmp;
int j;
bool found = false;
+ bool use_label = false;
glob_t gl;
if (get_var_from_file("/proc/cmdline", "fstools_ignore_partname", rootparam, sizeof(rootparam))) {
@@ -128,12 +129,17 @@ 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", "fstools_use_partlabel", rootparam, sizeof(rootparam)))
+ if (!strcmp("1", rootparam))
+ use_label = true;
+
+ if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam)) &&
+ !use_label) {
rootdev = rootdevname(rootparam);
/* 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 */
+ /* no 'root=' kernel cmdline parameter or use_label=true, 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