diff options
-rw-r--r-- | libfstools/partname.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/libfstools/partname.c b/libfstools/partname.c index f42322a..53ee600 100644 --- a/libfstools/partname.c +++ b/libfstools/partname.c @@ -121,6 +121,8 @@ static struct volume *partname_volume_find(char *name) char *rootdev = NULL, *devname, *tmp; int j; bool found = false; + bool allow_fallback = false; + bool has_root = false; glob_t gl; if (get_var_from_file("/proc/cmdline", "fstools_ignore_partname", rootparam, sizeof(rootparam))) { @@ -128,22 +130,28 @@ static struct volume *partname_volume_find(char *name) return NULL; } - if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam)) && rootparam[0] == '/') { + /* + * Some device may contains a GPT partition named rootfs_data that may not be suitable. + * To save from regression with old implementation that doesn't use fstools_ignore_partname to + * explicitly say that that partname scan should be ignored, make explicit that scanning each + * partition should be done by providing fstools_partname_fallback_scan=1 and skip partname scan + * in every other case. + */ + if (get_var_from_file("/proc/cmdline", "fstools_partname_fallback_scan", rootparam, sizeof(rootparam))) { + if (!strcmp("1", rootparam)) + allow_fallback = true; + } + + if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam))) + has_root = true; + + if (has_root && rootparam[0] == '/') { rootdev = rootdevname(rootparam); /* find partition on same device as rootfs */ snprintf(ueventgstr, sizeof(ueventgstr), "%s/%s/*/uevent", block_dir_name, rootdev); } else { - /* - * Some device may contains a GPT partition named rootfs_data that may not be suitable. - * To save from regression with old implementation that doesn't use fstools_ignore_partname to - * explicitly say that that parname scan should be ignored, make explicit that scanning each - * partition should be done by providing fstools_partname_fallback_scan=1 and skip partname scan - * in every other case. - */ - if (!get_var_from_file("/proc/cmdline", "fstools_partname_fallback_scan", rootparam, sizeof(rootparam))) - return NULL; - - if (!strcmp("1", rootparam)) + /* For compatibility, devices with root= params must explicitly opt into this fallback. */ + if (has_root && !allow_fallback) return NULL; /* no useful 'root=' kernel cmdline parameter, find on any block device */ |