From dc3d3b810a644dfa329efaa230cd514226f8981d Mon Sep 17 00:00:00 2001 From: Ryusuke Konishi Date: Sun, 15 Aug 2010 23:33:57 +0900 Subject: 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 --- fs/nilfs2/inode.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'fs/nilfs2/inode.c') 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: return err; } +int nilfs_permission(struct inode *inode, int mask) +{ + struct nilfs_root *root = NILFS_I(inode)->i_root; + + if ((mask & MAY_WRITE) && root && + root->cno != NILFS_CPTREE_CURRENT_CNO) + return -EROFS; /* snapshot is not writable */ + + return generic_permission(inode, mask, NULL); +} + int nilfs_load_inode_block(struct nilfs_sb_info *sbi, struct inode *inode, struct buffer_head **pbh) { -- cgit v1.2.2