]> git.karo-electronics.de Git - linux-beck.git/commitdiff
f2fs: verify file type early in f2fs_fallocate
authorChao Yu <chao2.yu@samsung.com>
Fri, 11 Sep 2015 06:39:02 +0000 (14:39 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 9 Oct 2015 23:20:50 +0000 (16:20 -0700)
This patch changes to verify file type early in f2fs_fallocate for
cleanup, meanwhile this also fixes to add missing verification for
expand_inode_data.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index b2fab9e2c09b44a3daa760a34adc2c3339960caf..a85bb14716e5c05a42a6ba3ac2864d09a3f4ba85 100644 (file)
@@ -765,9 +765,6 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
        loff_t off_start, off_end;
        int ret = 0;
 
-       if (!S_ISREG(inode->i_mode))
-               return -EOPNOTSUPP;
-
        if (f2fs_has_inline_data(inode)) {
                ret = f2fs_convert_inline_inode(inode);
                if (ret)
@@ -908,9 +905,6 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
        loff_t new_size;
        int ret;
 
-       if (!S_ISREG(inode->i_mode))
-               return -EINVAL;
-
        if (offset + len >= i_size_read(inode))
                return -EINVAL;
 
@@ -959,9 +953,6 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len,
        loff_t off_start, off_end;
        int ret = 0;
 
-       if (!S_ISREG(inode->i_mode))
-               return -EINVAL;
-
        ret = inode_newsize_ok(inode, (len + offset));
        if (ret)
                return ret;
@@ -1068,9 +1059,6 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len)
        loff_t new_size;
        int ret;
 
-       if (!S_ISREG(inode->i_mode))
-               return -EINVAL;
-
        new_size = i_size_read(inode) + len;
        if (new_size > inode->i_sb->s_maxbytes)
                return -EFBIG;
@@ -1228,6 +1216,10 @@ static long f2fs_fallocate(struct file *file, int mode,
        struct inode *inode = file_inode(file);
        long ret = 0;
 
+       /* f2fs only support ->fallocate for regular file */
+       if (!S_ISREG(inode->i_mode))
+               return -EINVAL;
+
        if (f2fs_encrypted_inode(inode) &&
                (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
                return -EOPNOTSUPP;