aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-06-04 05:30:04 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-08-09 16:47:39 -0400
commit2c27c65ed0696f0b5df2dad2cf6462d72164d547 (patch)
tree7d9036e3dea98938f7fd7074366ee73929e9b2e5 /fs/ext2
parentdb78b877f7744bec4a9d9f9e7d10da3931d7cd39 (diff)
check ATTR_SIZE contraints in inode_change_ok
Make sure we check the truncate constraints early on in ->setattr by adding those checks to inode_change_ok. Also clean up and document inode_change_ok to make this obvious. As a fallout we don't have to call inode_newsize_ok from simple_setsize and simplify it down to a truncate_setsize which doesn't return an error. This simplifies a lot of setattr implementations and means we use truncate_setsize almost everywhere. Get rid of fat_setsize now that it's trivial and mark ext2_setsize static to make the calling convention obvious. Keep the inode_newsize_ok in vmtruncate for now as all callers need an audit for its removal anyway. Note: setattr code in ecryptfs doesn't call inode_change_ok at all and needs a deeper audit, but that is left for later. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/inode.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 7dee7b3f3688..069620b30d4d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1156,15 +1156,10 @@ static void ext2_truncate_blocks(struct inode *inode, loff_t offset)
1156 __ext2_truncate_blocks(inode, offset); 1156 __ext2_truncate_blocks(inode, offset);
1157} 1157}
1158 1158
1159int ext2_setsize(struct inode *inode, loff_t newsize) 1159static int ext2_setsize(struct inode *inode, loff_t newsize)
1160{ 1160{
1161 loff_t oldsize;
1162 int error; 1161 int error;
1163 1162
1164 error = inode_newsize_ok(inode, newsize);
1165 if (error)
1166 return error;
1167
1168 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 1163 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1169 S_ISLNK(inode->i_mode))) 1164 S_ISLNK(inode->i_mode)))
1170 return -EINVAL; 1165 return -EINVAL;
@@ -1184,10 +1179,7 @@ int ext2_setsize(struct inode *inode, loff_t newsize)
1184 if (error) 1179 if (error)
1185 return error; 1180 return error;
1186 1181
1187 oldsize = inode->i_size; 1182 truncate_setsize(inode, newsize);
1188 i_size_write(inode, newsize);
1189 truncate_pagecache(inode, oldsize, newsize);
1190
1191 __ext2_truncate_blocks(inode, newsize); 1183 __ext2_truncate_blocks(inode, newsize);
1192 1184
1193 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; 1185 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;