From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@linux-foundation.org, serue@us.ibm.com,
viro@ftp.linux.org.uk, linuxram@us.ibm.com,
ebiederm@xmission.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
containers@lists.osdl.org
Subject: [patch 04/10] allow per-mount flags to be set/cleared individually
Date: Mon, 16 Apr 2007 13:03:12 +0200 [thread overview]
Message-ID: <20070416110409.741907051@szeredi.hu> (raw)
In-Reply-To: 20070416110308.739051445@szeredi.hu
[-- Attachment #1: set_clear_mount_flags.patch --]
[-- Type: text/plain, Size: 3016 bytes --]
With MS_REMOUNT, it is difficult to change mount flags individually,
without touching other mount flags or options, having to parse
/proc/mounts to get the old flag values and options.
It is also difficult to change a mount flag recursively, having to
walk the mount tree in userspace.
This patch solves this problem by generalizing do_change_type() so
that not only the propagation property can be changed, but mnt_flags
can be set/cleared individually.
From: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2007-04-13 13:04:04.000000000 +0200
+++ linux/fs/namespace.c 2007-04-13 13:04:29.000000000 +0200
@@ -955,19 +956,28 @@ out_unlock:
/*
* recursively change the type of the mountpoint.
*/
-static int do_change_type(struct nameidata *nd, int flag)
+static int do_change_mnt(struct nameidata *nd, int flag, int mnt_flags)
{
struct vfsmount *m, *mnt = nd->mnt;
int recurse = flag & MS_REC;
- int type = flag & ~MS_REC;
+ int type = flag & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE);
if (nd->dentry != nd->mnt->mnt_root)
return -EINVAL;
down_write(&namespace_sem);
spin_lock(&vfsmount_lock);
- for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
- change_mnt_propagation(m, type);
+ for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) {
+ if (type)
+ change_mnt_propagation(m, type);
+
+ if (flag & (MS_SETFLAGS | MS_CLEARFLAGS))
+ m->mnt_flags = mnt_flags;
+ else if (flag & MS_SETFLAGS)
+ m->mnt_flags |= mnt_flags;
+ else if (flag & MS_CLEARFLAGS)
+ m->mnt_flags &= ~mnt_flags;
+ }
spin_unlock(&vfsmount_lock);
up_write(&namespace_sem);
return 0;
@@ -1514,8 +1526,9 @@ long do_mount(char *dev_name, char *dir_
data_page);
else if (flags & MS_BIND)
retval = do_loopback(&nd, dev_name, flags);
- else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
- retval = do_change_type(&nd, flags);
+ else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE |
+ MS_SETFLAGS | MS_CLEARFLAGS))
+ retval = do_change_mnt(&nd, flags, mnt_flags);
else if (flags & MS_MOVE)
retval = do_move_mount(&nd, dev_name);
else
Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h 2007-04-13 13:04:04.000000000 +0200
+++ linux/include/linux/fs.h 2007-04-13 13:04:29.000000000 +0200
@@ -127,6 +127,9 @@ extern int dir_notify_enable;
#define MS_SHARED (1<<20) /* change to shared */
#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
#define MS_SETUSER (1<<22) /* set mnt_uid to current user */
+#define MS_SETFLAGS (1<<23) /* set specified mount flags */
+#define MS_CLEARFLAGS (1<<24) /* clear specified mount flags */
+/* MS_SETFLAGS | MS_CLEARFLAGS: change mount flags to specified */
#define MS_ACTIVE (1<<30)
#define MS_NOUSER (1<<31)
--
next prev parent reply other threads:[~2007-04-16 11:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-16 11:03 [patch 00/10] mount ownership and unprivileged mount syscall (v3) Miklos Szeredi
2007-04-16 11:03 ` [patch 01/10] add user mounts to the kernel Miklos Szeredi
2007-04-16 11:03 ` [patch 02/10] allow unprivileged umount Miklos Szeredi
2007-04-16 19:39 ` Eric W. Biederman
2007-04-16 19:58 ` Greg KH
2007-04-16 11:03 ` [patch 03/10] account user mounts Miklos Szeredi
2007-04-16 11:03 ` Miklos Szeredi [this message]
2007-04-16 11:03 ` [patch 05/10] Add "permit user submounts" flag to vfsmount Miklos Szeredi
2007-04-16 19:20 ` Serge E. Hallyn
2007-04-17 10:44 ` Miklos Szeredi
2007-04-17 14:33 ` Serge E. Hallyn
2007-04-17 16:08 ` Miklos Szeredi
2007-04-17 16:54 ` Serge E. Hallyn
2007-04-16 11:03 ` [patch 06/10] propagate error values from clone_mnt Miklos Szeredi
2007-04-16 11:03 ` [patch 07/10] allow unprivileged bind mounts Miklos Szeredi
2007-04-16 11:03 ` [patch 08/10] put declaration of put_filesystem() in fs.h Miklos Szeredi
2007-04-16 11:03 ` [patch 09/10] allow unprivileged mounts Miklos Szeredi
2007-04-16 11:03 ` [patch 10/10] allow unprivileged fuse mounts Miklos Szeredi
2007-04-18 7:08 ` [patch 00/10] mount ownership and unprivileged mount syscall (v3) Jeremy Maitin-Shepard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070416110409.741907051@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=serue@us.ibm.com \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox