]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
make the feature checks in ->fallocate future proof
authorChristoph Hellwig <hch@lst.de>
Fri, 14 Jan 2011 12:07:30 +0000 (13:07 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 17 Jan 2011 07:25:30 +0000 (02:25 -0500)
Instead of various home grown checks that might need updates for new
flags just check for any bit outside the mask of the features supported
by the filesystem.  This makes the check future proof for any newly
added flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/btrfs/inode.c
fs/ext4/extents.c
fs/gfs2/ops_inode.c
fs/ocfs2/file.c
fs/xfs/linux-2.6/xfs_iops.c

index a3798a3aa0d213823a977bbe46f65e2484bc7a7e..64daf2acd0d5296a67d320a83e8d48c169f16a4c 100644 (file)
@@ -7116,7 +7116,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
        alloc_end =  (offset + len + mask) & ~mask;
 
        /* We only support the FALLOC_FL_KEEP_SIZE mode */
-       if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+       if (mode & ~FALLOC_FL_KEEP_SIZE)
                return -EOPNOTSUPP;
 
        /*
index c4068f6abf03ce11ea653835ea22845aa3c0b2bf..4bdd160854ebb1a77a82145fb5e3063af40ded5e 100644 (file)
@@ -3645,7 +3645,7 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
        unsigned int credits, blkbits = inode->i_blkbits;
 
        /* We only support the FALLOC_FL_KEEP_SIZE mode */
-       if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+       if (mode & ~FALLOC_FL_KEEP_SIZE)
                return -EOPNOTSUPP;
 
        /*
index 040b5a2e65561f23049b8793f451b0b032e3be17..c09528c07f3d4f4a366120c16234bc33abbc8841 100644 (file)
@@ -1426,7 +1426,7 @@ static long gfs2_fallocate(struct inode *inode, int mode, loff_t offset,
        next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
 
        /* We only support the FALLOC_FL_KEEP_SIZE mode */
-       if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+       if (mode & ~FALLOC_FL_KEEP_SIZE)
                return -EOPNOTSUPP;
 
        offset = (offset >> sdp->sd_sb.sb_bsize_shift) <<
index 63e3fca266e006bf838c93abfad142c948721716..cf254ce8c941396d3c737ee45b54cf4e5f9c4d60 100644 (file)
@@ -1997,6 +1997,8 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
        int change_size = 1;
        int cmd = OCFS2_IOC_RESVSP64;
 
+       if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+               return -EOPNOTSUPP;
        if (!ocfs2_writes_unwritten_extents(osb))
                return -EOPNOTSUPP;
 
index da54403633b61032daee5d28786f9b0a1ca691de..a4ecc2188a098424fa74b3ac5d9d6b3be3ea1f62 100644 (file)
@@ -518,6 +518,9 @@ xfs_vn_fallocate(
        xfs_inode_t     *ip = XFS_I(inode);
        int             cmd = XFS_IOC_RESVSP;
 
+       if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+               return -EOPNOTSUPP;
+
        /* preallocation on directories not yet supported */
        error = -ENODEV;
        if (S_ISDIR(inode->i_mode))