lkml.org 
[lkml]   [2005]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 10/18] beginning of the shared-subtree proper
From
Date
From: Ram Pai <linuxram@us.ibm.com>
Date: 1131401947 -0500

A private mount does not forward or receive propagation. This patch provides
user the ability to convert any mount to private.

Signed-off-by: Ram Pai (linuxram@us.ibm.com)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

---

fs/Makefile | 2 +-
fs/namespace.c | 24 ++++++++++++++++++++++++
fs/pnode.c | 17 +++++++++++++++++
fs/pnode.h | 14 ++++++++++++++
include/linux/fs.h | 1 +
include/linux/mount.h | 10 +++++-----
6 files changed, 62 insertions(+), 6 deletions(-)
create mode 100644 fs/pnode.c
create mode 100644 fs/pnode.h

281805822dfdf14eb3503de6cc54906a849159d2
diff --git a/fs/Makefile b/fs/Makefile
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -10,7 +10,7 @@ obj-y := open.o read_write.o file_table.
ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \
- ioprio.o
+ ioprio.o pnode.o

obj-$(CONFIG_INOTIFY) += inotify.o
obj-$(CONFIG_EPOLL) += eventpoll.o
diff --git a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -24,6 +24,7 @@
#include <linux/mount.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
+#include "pnode.h"

extern int __init init_rootfs(void);

@@ -663,6 +664,27 @@ out_unlock:
}

/*
+ * recursively change the type of the mountpoint.
+ */
+static int do_change_type(struct nameidata *nd, int flag)
+{
+ struct vfsmount *m, *mnt = nd->mnt;
+ int recurse = flag & MS_REC;
+ int type = flag & ~MS_REC;
+
+ 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);
+ spin_unlock(&vfsmount_lock);
+ up_write(&namespace_sem);
+ return 0;
+}
+
+/*
* do loopback mount.
*/
static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
@@ -1091,6 +1113,8 @@ long do_mount(char *dev_name, char *dir_
data_page);
else if (flags & MS_BIND)
retval = do_loopback(&nd, dev_name, flags & MS_REC);
+ else if (flags & MS_PRIVATE)
+ retval = do_change_type(&nd, flags);
else if (flags & MS_MOVE)
retval = do_move_mount(&nd, dev_name);
else
diff --git a/fs/pnode.c b/fs/pnode.c
new file mode 100644
--- /dev/null
+++ b/fs/pnode.c
@@ -0,0 +1,17 @@
+/*
+ * linux/fs/pnode.c
+ *
+ * (C) Copyright IBM Corporation 2005.
+ * Released under GPL v2.
+ * Author : Ram Pai (linuxram@us.ibm.com)
+ *
+ */
+#include <linux/namespace.h>
+#include <linux/mount.h>
+#include <linux/fs.h>
+#include "pnode.h"
+
+void change_mnt_propagation(struct vfsmount *mnt, int type)
+{
+ mnt->mnt_flags &= ~MNT_PNODE_MASK;
+}
diff --git a/fs/pnode.h b/fs/pnode.h
new file mode 100644
--- /dev/null
+++ b/fs/pnode.h
@@ -0,0 +1,14 @@
+/*
+ * linux/fs/pnode.h
+ *
+ * (C) Copyright IBM Corporation 2005.
+ * Released under GPL v2.
+ *
+ */
+#ifndef _LINUX_PNODE_H
+#define _LINUX_PNODE_H
+
+#include <linux/list.h>
+#include <linux/mount.h>
+void change_mnt_propagation(struct vfsmount *, int);
+#endif /* _LINUX_PNODE_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -104,6 +104,7 @@ extern int dir_notify_enable;
#define MS_MOVE 8192
#define MS_REC 16384
#define MS_VERBOSE 32768
+#define MS_PRIVATE (1<<18) /* change to private */
#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
#define MS_ACTIVE (1<<30)
#define MS_NOUSER (1<<31)
diff --git a/include/linux/mount.h b/include/linux/mount.h
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -17,12 +17,12 @@
#include <linux/spinlock.h>
#include <asm/atomic.h>

-#define MNT_NOSUID 1
-#define MNT_NODEV 2
-#define MNT_NOEXEC 4
+#define MNT_NOSUID 0x01
+#define MNT_NODEV 0x02
+#define MNT_NOEXEC 0x04
+#define MNT_PNODE_MASK 0x30 /* propogation flag mask */

-struct vfsmount
-{
+struct vfsmount {
struct list_head mnt_hash;
struct vfsmount *mnt_parent; /* fs we are mounted on */
struct dentry *mnt_mountpoint; /* dentry of mountpoint */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-11-08 03:12    [W:0.022 / U:1.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site