summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmount/src/context.c14
-rw-r--r--sys-utils/mount.818
2 files changed, 29 insertions, 3 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c
index fdbb02585..7c34cad95 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -2045,7 +2045,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, isremount = 0;
+ int rc = -1, isremount = 0, iscmdbind = 0;
struct libmnt_table *tab = NULL;
const char *src = NULL, *tgt = NULL;
unsigned long mflags = 0;
@@ -2070,8 +2070,10 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
cxt->optsmode &= ~MNT_OMODE_FORCE;
}
- if (mnt_context_get_mflags(cxt, &mflags) == 0 && mflags & MS_REMOUNT)
- isremount = 1;
+ if (mnt_context_get_mflags(cxt, &mflags) == 0) {
+ isremount = !!(mflags & MS_REMOUNT);
+ iscmdbind = !!(mflags & MS_BIND);
+ }
if (cxt->fs) {
src = mnt_fs_get_source(cxt->fs);
@@ -2138,6 +2140,12 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
* not found are not so important and may be misinterpreted by
* applications... */
rc = -MNT_ERR_NOFSTAB;
+
+
+ } else if (isremount && !iscmdbind) {
+
+ /* remove "bind" from fstab (or no-op if not present) */
+ mnt_optstr_remove_option(&cxt->fs->optstr, "bind");
}
return rc;
}
diff --git a/sys-utils/mount.8 b/sys-utils/mount.8
index ac410640e..3bd278e6a 100644
--- a/sys-utils/mount.8
+++ b/sys-utils/mount.8
@@ -385,6 +385,20 @@ will be read-only.
It's also possible to change nosuid, nodev, noexec, noatime, nodiratime and
relatime VFS entry flags by "remount,bind" operation. It's impossible to change
mount options recursively (for example with \fB-o rbind,ro\fR).
+
+.BR mount (8)
+since v2.31 ignores the \fBbind\fR flag from
+.I /etc/fstab
+on
+.B remount operation
+(if "-o remount" specified on command line). This is necessary to fully control
+mount options on remount by command line. In the previous versions the bind
+flag has been always applied and it was impossible to re-define mount options
+without interaction with the bind semantic. This
+.BR mount (8)
+behavior does not affect situations when "remount,bind" is specified in the
+.I /etc/fstab
+file.
.RE
.SS The move operation
@@ -1088,6 +1102,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 operation together with the
+.B bind
+flag has special semantic. See above, the subsection \fBBind mounts\fR.
+
The remount functionality follows the standard way the mount command works
with options from fstab. This means that \fBmount\fR does not
read fstab (or mtab) only when both