aboutsummaryrefslogtreecommitdiffstats
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorDave Hansen <haveblue@us.ibm.com>2007-10-17 02:31:13 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:43:04 -0400
commitce8d2cdf3d2b73e346c82e6f0a46da331df6364c (patch)
treebf3597f2d4f57d6e30a7703d7fce0dbf8c757962 /mm/shmem.c
parent348366b963e4e1462c8354827a9cb910aa865bf2 (diff)
r/o bind mounts: filesystem helpers for custom 'struct file's
Why do we need r/o bind mounts? This feature allows a read-only view into a read-write filesystem. In the process of doing that, it also provides infrastructure for keeping track of the number of writers to any given mount. This has a number of uses. It allows chroots to have parts of filesystems writable. It will be useful for containers in the future because users may have root inside a container, but should not be allowed to write to somefilesystems. This also replaces patches that vserver has had out of the tree for several years. It allows security enhancement by making sure that parts of your filesystem read-only (such as when you don't trust your FTP server), when you don't want to have entire new filesystems mounted, or when you want atime selectively updated. I've been using the following script to test that the feature is working as desired. It takes a directory and makes a regular bind and a r/o bind mount of it. It then performs some normal filesystem operations on the three directories, including ones that are expected to fail, like creating a file on the r/o mount. This patch: Some filesystems forego the vfs and may_open() and create their own 'struct file's. This patch creates a couple of helper functions which can be used by these filesystems, and will provide a unified place which the r/o bind mount code may patch. Also, rename an existing, static-scope init_file() to a less generic name. Signed-off-by: Dave Hansen <haveblue@us.ibm.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 6fa20a84daa0..289dbb0a6fd6 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2543,11 +2543,8 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
2543 d_instantiate(dentry, inode); 2543 d_instantiate(dentry, inode);
2544 inode->i_size = size; 2544 inode->i_size = size;
2545 inode->i_nlink = 0; /* It is unlinked */ 2545 inode->i_nlink = 0; /* It is unlinked */
2546 file->f_path.mnt = mntget(shm_mnt); 2546 init_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ,
2547 file->f_path.dentry = dentry; 2547 &shmem_file_operations);
2548 file->f_mapping = inode->i_mapping;
2549 file->f_op = &shmem_file_operations;
2550 file->f_mode = FMODE_WRITE | FMODE_READ;
2551 return file; 2548 return file;
2552 2549
2553close_file: 2550close_file: