From 01966ce852ac6c46e7e35a8e4f981dea88620ff8 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 18 Dec 2014 10:30:14 +0100 Subject: libmount: allow unspecified source on remount kernel does not require mount source (e.g. device name) on remount, it means that fstab/mtab/mountinfo should be optional in this case. For example: mount -o rw,remount / has to work on system without mounted /proc. Signed-off-by: Karel Zak --- libmount/src/context.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libmount/src/context.c') diff --git a/libmount/src/context.c b/libmount/src/context.c index a320b3e6b..14fa44b52 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -2025,7 +2025,7 @@ static int apply_table(struct libmnt_context *cxt, struct libmnt_table *tb, */ int mnt_context_apply_fstab(struct libmnt_context *cxt) { - int rc = -1; + int rc = -1, isremount = 0; struct libmnt_table *tab = NULL; const char *src = NULL, *tgt = NULL; unsigned long mflags = 0; @@ -2056,6 +2056,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt) DBG(CXT, ul_debugobj(cxt, "force mtab parsing on remount")); cxt->optsmode |= MNT_OMODE_MTAB; cxt->optsmode &= ~MNT_OMODE_FSTAB; + isremount = 1; } if (cxt->fs) { @@ -2109,6 +2110,13 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt) rc = apply_table(cxt, tab, MNT_ITER_BACKWARD); } if (rc) { + if (!mnt_context_is_restricted(cxt) + && tgt && !src + && isremount) { + DBG(CXT, ul_debugobj(cxt, "only target; ignore missing mtab entry on remount")); + return 0; + } + DBG(CXT, ul_debugobj(cxt, "failed to find entry in fstab/mtab [rc=%d]: %m", rc)); /* force to "not found in fstab/mtab" error, the details why -- cgit v1.2.3-55-g7522