[PATCH 1/2] x86: Check /proc/mounts before mtab for mounts

Niklas Hambüchen mail at nh2.me
Mon Apr 29 01:22:26 PDT 2019


In many situations, especially on read-only file systems
and initial ramdisks (intramfs/initrd), /etc/mtab does not exist.

Before this commit, kexec would fail to read mounts on such systems
in `find_mnt_by_fsname()`, such that `get_bootparam()` would not
`boot_params/data`, which would then lead to e.g. `setup_efi_data()`
not being called in `setup_efi_info()`.

As a result, kexec'ed kernels would not obtain EFI data,
subsequentially lack an `ACPI RSDP` entry, emitting:

    ACPI BIOS Error (bug): A valid RSDP was not found (20180810/tbxfroot-210)

and thus fail to turn off the machine on poweroff, instead printing only:

		reboot: System halted

This problem had to be worked around by passing `acpi_rsdp=` manually
before. This commit obviates this workaround.

See also:

* https://github.com/coreos/bugs/issues/167#issuecomment-487320879
* http://lists.infradead.org/pipermail/kexec/2012-October/006924.html

Signed-off-by: Niklas Hambüchen <mail at nh2.me>
---
 kexec/arch/i386/x86-linux-setup.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index 8fad115..74fb0c4 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -432,7 +432,7 @@ out:
 /*
  * This really only makes sense for virtual filesystems that are only expected
  * to be mounted once (sysfs, debugsfs, proc), as it will return the first
- * instance listed in mtab.
+ * instance listed in /proc/mounts, falling back to mtab if absent.
  */
 char *find_mnt_by_fsname(char *fsname)
 {
@@ -440,7 +440,11 @@ char *find_mnt_by_fsname(char *fsname)
 	struct mntent *mnt;
 	char *mntdir;
 
-	mtab = setmntent("/etc/mtab", "r");
+	mtab = setmntent("/proc/mounts", "r");
+	if (!mtab) {
+		// Fall back to mtab
+		mtab = setmntent("/etc/mtab", "r");
+	}
 	if (!mtab)
 		return NULL;
 	for(mnt = getmntent(mtab); mnt; mnt = getmntent(mtab)) {
-- 
2.19.1




More information about the kexec mailing list