aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/inode.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-15 10:33:57 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:35 -0400
commitdc3d3b810a644dfa329efaa230cd514226f8981d (patch)
treee0a2c2bfb3edb6b1fa4383cb2d1f52adb653c9e2 /fs/nilfs2/inode.c
parentfd52202930b7e8db48bee5a6fc6b1f438e822a23 (diff)
nilfs2: deny write access to inodes in snapshots
Snapshots of nilfs are read-only. After super block instances (sb) will be unified, nilfs will need to check write access by a way other than implicit test with IS_RDONLY(inode). This is because IS_RDONLY() refers to MS_RDONLY bit of inode->i_sb->s_flags and it will become inaccurate after the unification of sb. To prepare for the issue, this uses i_op->permission to deny write access to inodes in snapshots. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/inode.c')
-rw-r--r--fs/nilfs2/inode.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index ca09e4362d66..3efef0ecfa24 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -764,6 +764,17 @@ out_err:
764 return err; 764 return err;
765} 765}
766 766
767int nilfs_permission(struct inode *inode, int mask)
768{
769 struct nilfs_root *root = NILFS_I(inode)->i_root;
770
771 if ((mask & MAY_WRITE) && root &&
772 root->cno != NILFS_CPTREE_CURRENT_CNO)
773 return -EROFS; /* snapshot is not writable */
774
775 return generic_permission(inode, mask, NULL);
776}
777
767int nilfs_load_inode_block(struct nilfs_sb_info *sbi, struct inode *inode, 778int nilfs_load_inode_block(struct nilfs_sb_info *sbi, struct inode *inode,
768 struct buffer_head **pbh) 779 struct buffer_head **pbh)
769{ 780{