Hello, This patch adds readonly inode flag support. A file with this flag can't be modified, but can be deleted. Regards YZ --- diff -r 067ba546ac2c ctree.h --- a/ctree.h Wed Jan 09 15:55:33 2008 -0500 +++ b/ctree.h Mon Jan 14 14:25:01 2008 +0800 @@ -451,8 +451,9 @@ struct btrfs_root { /* * Inode flags */ -#define BTRFS_INODE_NODATASUM 0x1 -#define BTRFS_INODE_NODATACOW 0x2 +#define BTRFS_INODE_NODATASUM (1 << 0) +#define BTRFS_INODE_NODATACOW (1 << 1) +#define BTRFS_INODE_READONLY (1 << 2) #define btrfs_clear_flag(inode, flag) (BTRFS_I(inode)->flags &= \ ~BTRFS_INODE_##flag) diff -r 067ba546ac2c inode.c --- a/inode.c Wed Jan 09 15:55:33 2008 -0500 +++ b/inode.c Mon Jan 14 14:25:01 2008 +0800 @@ -2851,6 +2851,14 @@ out_fail: return err; } +static int btrfs_permission(struct inode *inode, int mask, + struct nameidata *nd) +{ + if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE)) + return -EACCES; + return generic_permission(inode, mask, NULL); +} + static struct inode_operations btrfs_dir_inode_operations = { .lookup = btrfs_lookup, .create = btrfs_create, @@ -2866,10 +2874,12 @@ static struct inode_operations btrfs_dir .getxattr = generic_getxattr, .listxattr = btrfs_listxattr, .removexattr = generic_removexattr, + .permission = btrfs_permission, }; static struct inode_operations btrfs_dir_ro_inode_operations = { .lookup = btrfs_lookup, + .permission = btrfs_permission, }; static struct file_operations btrfs_dir_file_operations = { @@ -2916,15 +2926,18 @@ static struct inode_operations btrfs_fil .getxattr = generic_getxattr, .listxattr = btrfs_listxattr, .removexattr = generic_removexattr, + .permission = btrfs_permission, }; static struct inode_operations btrfs_special_inode_operations = { .getattr = btrfs_getattr, .setattr = btrfs_setattr, + .permission = btrfs_permission, }; static struct inode_operations btrfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = page_follow_link_light, .put_link = page_put_link, + .permission = btrfs_permission, };