All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec-tools: find sysfs smarter
@ 2016-06-01 20:26 Josef Bacik
  2016-06-02  3:35 ` Pratyush Anand
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2016-06-01 20:26 UTC (permalink / raw)
  To: kexec, kernel-team

Some systems may not have /etc/mtab, so fall back to using /proc/mounts if we
fail to open /etc/mtab.  Also if a user does

mount -t sysfs none /sys

we won't find the sysfs directory.  We need to check mnt->mnt_type, not
mnt->mnt_fsname.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 kexec/arch/i386/x86-linux-setup.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index c75adaa..c24abaa 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -425,10 +425,13 @@ char *find_mnt_by_fsname(char *fsname)
 	char *mntdir;
 
 	mtab = setmntent("/etc/mtab", "r");
-	if (!mtab)
-		return NULL;
+	if (!mtab) {
+		mtab = setmntent("/proc/mounts", "r");
+		if (!mtab)
+			return NULL;
+	}
 	for(mnt = getmntent(mtab); mnt; mnt = getmntent(mtab)) {
-		if (strcmp(mnt->mnt_fsname, fsname) == 0)
+		if (strcmp(mnt->mnt_type, fsname) == 0)
 			break;
 	}
 	mntdir = mnt ? strdup(mnt->mnt_dir) : NULL;
-- 
2.5.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-02  3:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 20:26 [PATCH] kexec-tools: find sysfs smarter Josef Bacik
2016-06-02  3:35 ` Pratyush Anand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.