Skip to contentSkip to conversation

Bind Mount Extensions (RO --bind mounts)

DISCUSSION Herbert Poetzl 1 participant 2 messages Sep 28, 2003 – Sep 29, 2003 1 message not in the archive ext2 file system

lore
Share & tools
lore
#0 lore raw

Greetings!

verified that the patches apply on linux-2.6.0-test6 and work as expected ...

FYI, this patch (hopefully) allows RO --bind mounts to 'behave' like other ro mounted filesystems, and I hope that they will be included in the mainline in the near future ;)

AFAIK, it handles the following cases as expected:

- open (read/write/trunc), create
- link, symlink, unlink
- mknod (reg/block/char/fifo), mkfifo
- mkdir, rmdir
- (f)chown, (f)chmod, utimes
- ioctl (gen/ext2/ext3/reiser)
- access, truncate

it doesn't handle update_atime() yet (Al Viro is still busy ;) and it doesn't change current intermezzo code (but this would be easy to add, because it's almost the same as the vfs_*()s at least regarding ro --bind mounts)

you can get them at:

http://vserver.13thfloor.at/Experimental/patch-2.4.22-rc2-bme0.03.diff
http://vserver.13thfloor.at/Experimental/patch-2.4.22-rc2-bme0.03.diff.bz2
http://vserver.13thfloor.at/Experimental/patch-2.6.0-test3-bme0.03.diff
http://vserver.13thfloor.at/Experimental/patch-2.6.0-test3-bme0.03.diff.bz2

enjoy,
Herbert

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 10 lines · Gábor Lénárt

tatus: O
Content-Length: 1317
Lines: 31

Hi!

Quoted 3 lines · Herbert Poetzl

verified that the patches apply on linux-2.6.0-test6 and work as expected ...

Quoted 6 lines
Quoted 4 lines

FYI, this patch (hopefully) allows RO --bind mounts to 'behave' like other ro mounted filesystems, and I hope that they will be included in the mainline in the near future ;)

Maybe (sure ;-) it will be somewhat newbie question ...

you are welcome to ask!

Quoted 2 lines

I don't know too much on kernel internals, but imho --bind mounts and likes should be implemented at VFS layer.

yes they are

Quoted 1 line

So then why the patch effects filesystems like ext2 and ext3?

because ext2 and ext3 (and the other FS too) use them ;)

Quoted 4 lines

Till now I've thought that VFS is a general layer, and syscalls about file operations use general VFS functions which of course call the desired functions from filesystem implementations to do a certain work.

except for FS specific ioctls/features this is true ...

Quoted 2 lines

If it's true (is it?) why not only VFS is needed to change to support eg ro --bind?

hmm, IIRC I never mentioned any filesystem except intermezzo which is a special case ...

Quoted 4 lines

Does your patch mean that reiserfs or something else does not work with it? Because your patch contains filesystem code modifications so I can inmagine that it won't work with a great number of filesystems, like Minix, AFFS, msdos, etc etc ...

I've extracted the relevant hunks from the patch, and you can see, that those FS specific modifications only affect the FS specific ioctls, which do not use the VFS layer (yet?) ... (at end of mail)

Quoted 3 lines

BTW. It would be much more funny to have --bind mounts supporting all general mount options, like ro (ok so this is the patch), noexec, and such.

yes, I will implement them, but until now, only a few people seem to care about this stuff, so there seems no hurry, but you are right, all the other mount features should be implemented for --bind mounts too ...

best,
Herbert

fs/ext2/ioctl.c +2 -2
@@ -29,7 +30,7 @@
 	case EXT2_IOC_SETFLAGS: {
 		unsigned int oldflags;
 
-		if (IS_RDONLY(inode))
+		if (IS_RDONLY(inode) || MNT_IS_RDONLY(filp->f_vfsmnt))
 			return -EROFS;
 
 		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
@@ -68,7 +69,7 @@
 	case EXT2_IOC_SETVERSION:
 		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
 			return -EPERM;
-		if (IS_RDONLY(inode))
+		if (IS_RDONLY(inode) || MNT_IS_RDONLY(filp->f_vfsmnt))
 			return -EROFS;
 		if (get_user(inode->i_generation, (int *) arg))
 			return -EFAULT;	
fs/ext3/ioctl.c +2 -2
@@ -34,7 +35,7 @@
 		unsigned int oldflags;
 		unsigned int jflag;
 
-		if (IS_RDONLY(inode))
+		if (IS_RDONLY(inode) || MNT_IS_RDONLY(filp->f_vfsmnt))
 			return -EROFS;
 
 		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
@@ -110,7 +111,7 @@
 
 		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
 			return -EPERM;
-		if (IS_RDONLY(inode))
+		if (IS_RDONLY(inode) || MNT_IS_RDONLY(filp->f_vfsmnt))
 			return -EROFS;
 		if (get_user(generation, (int *) arg))
 			return -EFAULT;
fs/reiserfs/ioctl.c +2 -2
@@ -38,7 +39,7 @@
 		i_attrs_to_sd_attrs( inode, ( __u16 * ) &flags );
 		return put_user(flags, (int *) arg);
 	case REISERFS_IOC_SETFLAGS: {
-		if (IS_RDONLY(inode))
+		if (IS_RDONLY(inode) || MNT_IS_RDONLY(filp->f_vfsmnt))
 			return -EROFS;
 
 		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
@@ -70,7 +71,7 @@
 	case REISERFS_IOC_SETVERSION:
 		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
 			return -EPERM;
-		if (IS_RDONLY(inode))
+		if (IS_RDONLY(inode) || MNT_IS_RDONLY(filp->f_vfsmnt))
 			return -EROFS;
 		if (get_user(inode->i_generation, (int *) arg))
 			return -EFAULT;