Skip to content

Commit 07b2088

Browse files
Ram PaiLinus Torvalds
authored andcommitted
[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>
1 parent 390c684 commit 07b2088

File tree

6 files changed

+62
-6
lines changed

6 files changed

+62
-6
lines changed

fs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ obj-y := open.o read_write.o file_table.o buffer.o bio.o super.o \
1010
ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \
1111
attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \
1212
seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \
13-
ioprio.o
13+
ioprio.o pnode.o
1414

1515
obj-$(CONFIG_INOTIFY) += inotify.o
1616
obj-$(CONFIG_EPOLL) += eventpoll.o

fs/namespace.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/mount.h>
2525
#include <asm/uaccess.h>
2626
#include <asm/unistd.h>
27+
#include "pnode.h"
2728

2829
extern int __init init_rootfs(void);
2930

@@ -662,6 +663,27 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
662663
return err;
663664
}
664665

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+
665687
/*
666688
* do loopback mount.
667689
*/
@@ -1091,6 +1113,8 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
10911113
data_page);
10921114
else if (flags & MS_BIND)
10931115
retval = do_loopback(&nd, dev_name, flags & MS_REC);
1116+
else if (flags & MS_PRIVATE)
1117+
retval = do_change_type(&nd, flags);
10941118
else if (flags & MS_MOVE)
10951119
retval = do_move_mount(&nd, dev_name);
10961120
else

fs/pnode.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

fs/pnode.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */

include/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ extern int dir_notify_enable;
104104
#define MS_MOVE 8192
105105
#define MS_REC 16384
106106
#define MS_VERBOSE 32768
107+
#define MS_PRIVATE (1<<18) /* change to private */
107108
#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
108109
#define MS_ACTIVE (1<<30)
109110
#define MS_NOUSER (1<<31)

include/linux/mount.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#include <linux/spinlock.h>
1818
#include <asm/atomic.h>
1919

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

24-
struct vfsmount
25-
{
25+
struct vfsmount {
2626
struct list_head mnt_hash;
2727
struct vfsmount *mnt_parent; /* fs we are mounted on */
2828
struct dentry *mnt_mountpoint; /* dentry of mountpoint */

0 commit comments

Comments
 (0)