diff options
author | Ram Pai <linuxram@us.ibm.com> | 2005-11-07 17:19:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 21:18:10 -0500 |
commit | 07b20889e3052c7e77d6a6a54e7e83446eb1ba84 (patch) | |
tree | 616ac5b7eef3092e105d3b41e7bd2052558b064b | |
parent | 390c684367de37e1c2f9005cf92f7a746c69fdd3 (diff) |
[PATCH] beginning of the shared-subtree proper
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>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/Makefile | 2 | ||||
-rw-r--r-- | fs/namespace.c | 24 | ||||
-rw-r--r-- | fs/pnode.c | 17 | ||||
-rw-r--r-- | fs/pnode.h | 14 | ||||
-rw-r--r-- | include/linux/fs.h | 1 | ||||
-rw-r--r-- | include/linux/mount.h | 10 |
6 files changed, 62 insertions, 6 deletions
diff --git a/fs/Makefile b/fs/Makefile index 1972da186272..4c2655759078 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -10,7 +10,7 @@ obj-y := open.o read_write.o file_table.o buffer.o bio.o super.o \ | |||
10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ | 10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ |
11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ | 11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ |
12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ | 12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ |
13 | ioprio.o | 13 | ioprio.o pnode.o |
14 | 14 | ||
15 | obj-$(CONFIG_INOTIFY) += inotify.o | 15 | obj-$(CONFIG_INOTIFY) += inotify.o |
16 | obj-$(CONFIG_EPOLL) += eventpoll.o | 16 | obj-$(CONFIG_EPOLL) += eventpoll.o |
diff --git a/fs/namespace.c b/fs/namespace.c index 4abee9ab009f..3782923d6d4d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/mount.h> | 24 | #include <linux/mount.h> |
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | #include <asm/unistd.h> | 26 | #include <asm/unistd.h> |
27 | #include "pnode.h" | ||
27 | 28 | ||
28 | extern int __init init_rootfs(void); | 29 | extern int __init init_rootfs(void); |
29 | 30 | ||
@@ -663,6 +664,27 @@ out_unlock: | |||
663 | } | 664 | } |
664 | 665 | ||
665 | /* | 666 | /* |
667 | * recursively change the type of the mountpoint. | ||
668 | */ | ||
669 | static int do_change_type(struct nameidata *nd, int flag) | ||
670 | { | ||
671 | struct vfsmount *m, *mnt = nd->mnt; | ||
672 | int recurse = flag & MS_REC; | ||
673 | int type = flag & ~MS_REC; | ||
674 | |||
675 | if (nd->dentry != nd->mnt->mnt_root) | ||
676 | return -EINVAL; | ||
677 | |||
678 | down_write(&namespace_sem); | ||
679 | spin_lock(&vfsmount_lock); | ||
680 | for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) | ||
681 | change_mnt_propagation(m, type); | ||
682 | spin_unlock(&vfsmount_lock); | ||
683 | up_write(&namespace_sem); | ||
684 | return 0; | ||
685 | } | ||
686 | |||
687 | /* | ||
666 | * do loopback mount. | 688 | * do loopback mount. |
667 | */ | 689 | */ |
668 | static int do_loopback(struct nameidata *nd, char *old_name, int recurse) | 690 | static int do_loopback(struct nameidata *nd, char *old_name, int recurse) |
@@ -1091,6 +1113,8 @@ long do_mount(char *dev_name, char *dir_name, char *type_page, | |||
1091 | data_page); | 1113 | data_page); |
1092 | else if (flags & MS_BIND) | 1114 | else if (flags & MS_BIND) |
1093 | retval = do_loopback(&nd, dev_name, flags & MS_REC); | 1115 | retval = do_loopback(&nd, dev_name, flags & MS_REC); |
1116 | else if (flags & MS_PRIVATE) | ||
1117 | retval = do_change_type(&nd, flags); | ||
1094 | else if (flags & MS_MOVE) | 1118 | else if (flags & MS_MOVE) |
1095 | retval = do_move_mount(&nd, dev_name); | 1119 | retval = do_move_mount(&nd, dev_name); |
1096 | else | 1120 | else |
diff --git a/fs/pnode.c b/fs/pnode.c new file mode 100644 index 000000000000..aaa0dffda12a --- /dev/null +++ b/fs/pnode.c | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * linux/fs/pnode.c | ||
3 | * | ||
4 | * (C) Copyright IBM Corporation 2005. | ||
5 | * Released under GPL v2. | ||
6 | * Author : Ram Pai (linuxram@us.ibm.com) | ||
7 | * | ||
8 | */ | ||
9 | #include <linux/namespace.h> | ||
10 | #include <linux/mount.h> | ||
11 | #include <linux/fs.h> | ||
12 | #include "pnode.h" | ||
13 | |||
14 | void change_mnt_propagation(struct vfsmount *mnt, int type) | ||
15 | { | ||
16 | mnt->mnt_flags &= ~MNT_PNODE_MASK; | ||
17 | } | ||
diff --git a/fs/pnode.h b/fs/pnode.h new file mode 100644 index 000000000000..33549a3a74eb --- /dev/null +++ b/fs/pnode.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * linux/fs/pnode.h | ||
3 | * | ||
4 | * (C) Copyright IBM Corporation 2005. | ||
5 | * Released under GPL v2. | ||
6 | * | ||
7 | */ | ||
8 | #ifndef _LINUX_PNODE_H | ||
9 | #define _LINUX_PNODE_H | ||
10 | |||
11 | #include <linux/list.h> | ||
12 | #include <linux/mount.h> | ||
13 | void change_mnt_propagation(struct vfsmount *, int); | ||
14 | #endif /* _LINUX_PNODE_H */ | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 9a593ef262ef..6c431086abb3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -104,6 +104,7 @@ extern int dir_notify_enable; | |||
104 | #define MS_MOVE 8192 | 104 | #define MS_MOVE 8192 |
105 | #define MS_REC 16384 | 105 | #define MS_REC 16384 |
106 | #define MS_VERBOSE 32768 | 106 | #define MS_VERBOSE 32768 |
107 | #define MS_PRIVATE (1<<18) /* change to private */ | ||
107 | #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */ | 108 | #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */ |
108 | #define MS_ACTIVE (1<<30) | 109 | #define MS_ACTIVE (1<<30) |
109 | #define MS_NOUSER (1<<31) | 110 | #define MS_NOUSER (1<<31) |
diff --git a/include/linux/mount.h b/include/linux/mount.h index ffb0b5089880..8eadd3b65899 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
@@ -17,12 +17,12 @@ | |||
17 | #include <linux/spinlock.h> | 17 | #include <linux/spinlock.h> |
18 | #include <asm/atomic.h> | 18 | #include <asm/atomic.h> |
19 | 19 | ||
20 | #define MNT_NOSUID 1 | 20 | #define MNT_NOSUID 0x01 |
21 | #define MNT_NODEV 2 | 21 | #define MNT_NODEV 0x02 |
22 | #define MNT_NOEXEC 4 | 22 | #define MNT_NOEXEC 0x04 |
23 | #define MNT_PNODE_MASK 0x30 /* propogation flag mask */ | ||
23 | 24 | ||
24 | struct vfsmount | 25 | struct vfsmount { |
25 | { | ||
26 | struct list_head mnt_hash; | 26 | struct list_head mnt_hash; |
27 | struct vfsmount *mnt_parent; /* fs we are mounted on */ | 27 | struct vfsmount *mnt_parent; /* fs we are mounted on */ |
28 | struct dentry *mnt_mountpoint; /* dentry of mountpoint */ | 28 | struct dentry *mnt_mountpoint; /* dentry of mountpoint */ |