]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: allow unspecified source on remount
authorKarel Zak <kzak@redhat.com>
Thu, 18 Dec 2014 09:30:14 +0000 (10:30 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 18 Dec 2014 09:47:39 +0000 (10:47 +0100)
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 <kzak@redhat.com>
libmount/src/context.c
sys-utils/mount.8

index a320b3e6b67d103466668540650d7e0bd3ff2165..14fa44b52e49b0da91203ee38b227b408f623fc4 100644 (file)
@@ -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
index 272fd7d809e7f5aae0c8e703d03346fd7ee94e37..6fa8a275a4df69667546147eeb7008c6ccfe71c8 100644 (file)
@@ -1072,9 +1072,10 @@ Attempt to remount an already-mounted filesystem.  This is commonly
 used to change the mount flags for a filesystem, especially to make a
 readonly filesystem writable.  It does not change device or mount point.
 
-The remount functionality follows the standard way the mount command works
-with options from fstab.  This means that the mount command only doesn't
-read fstab (or mtab) when both the
+The remount functionality follows the standard way the mount command works with
+options, but preferred source for the options is mtab (or /proc/self/mouninfo)
+rather than fstab.  The mount command only does not read mtab 
+when both the
 .I device
 and
 .I dir
@@ -1083,15 +1084,16 @@ are specified.
 .B "mount \-o remount,rw /dev/foo /dir"
 
 After this call all old mount options are replaced and arbitrary stuff from
-fstab is ignored, except the loop= option which is internally generated and
+mtab is ignored, except the loop= option which is internally generated and
 maintained by the mount command.
 
 .B "mount \-o remount,rw  /dir"
 
-After this call mount reads fstab (or mtab) and merges these options with
+After this call mount reads mtab and merges these options with
 the options from the command line (\c
 .B \-o\c
-).
+). If no mtab (or /proc/self/mountinfo) is available than remount with unspecified
+source is allowed.
 .TP
 .B ro
 Mount the filesystem read-only.