aboutsummaryrefslogtreecommitdiffstats
path: root/fs/configfs
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 /fs/configfs
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 'fs/configfs')
-rw-r--r--fs/configfs/dir.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 2f436d4f1d6d..50ed691098bc 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -142,7 +142,7 @@ static int init_dir(struct inode * inode)
142 return 0; 142 return 0;
143} 143}
144 144
145static int init_file(struct inode * inode) 145static int configfs_init_file(struct inode * inode)
146{ 146{
147 inode->i_size = PAGE_SIZE; 147 inode->i_size = PAGE_SIZE;
148 inode->i_fop = &configfs_file_operations; 148 inode->i_fop = &configfs_file_operations;
@@ -283,7 +283,8 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
283 283
284 dentry->d_fsdata = configfs_get(sd); 284 dentry->d_fsdata = configfs_get(sd);
285 sd->s_dentry = dentry; 285 sd->s_dentry = dentry;
286 error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG, init_file); 286 error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG,
287 configfs_init_file);
287 if (error) { 288 if (error) {
288 configfs_put(sd); 289 configfs_put(sd);
289 return error; 290 return error;