From 964d1e3af0e111bad6d393f8a3be702e334c2398 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Fri, 19 Mar 2021 12:13:33 +0000 Subject: [PATCH] partname: allow skipping existing 'rootfs_data' partition Apparently some devices with eMMC (e.g. ZyXEL NBG6817) got an exsiting GPT partition called 'rootfs_data'. This partition is then selected as rootfs_data eventhough it may not be suitable for that (too small) or serve another purpose (ie. used by vendor firmware). To avoid this, check if the kernel cmdline contains a variable fstools_ignore_partname=1 and if so, skip partname detection of volumes alltogether. Signed-off-by: Daniel Golle --- libfstools/partname.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libfstools/partname.c b/libfstools/partname.c index 4560125..5d4fde5 100644 --- a/libfstools/partname.c +++ b/libfstools/partname.c @@ -85,7 +85,7 @@ static char* get_cmdline_val(const char* name, char* out, int len) continue; strncpy(out, &sep[1], len); - out[len-1] = 0; + out[len-1] = '\0'; return out; } @@ -120,6 +120,11 @@ static struct volume *partname_volume_find(char *name) bool found = false; glob_t gl; + if (get_cmdline_val("fstools_ignore_partname", rootparam, sizeof(rootparam))) { + if (!strcmp("1", rootparam)) + return NULL; + } + if (get_cmdline_val("root", rootparam, sizeof(rootparam))) { rootdev = rootdevname(rootparam); /* find partition on same device as rootfs */ -- 2.30.2