From: Christoph Hellwig Date: Fri, 14 Jan 2011 12:07:30 +0000 (+0100) Subject: make the feature checks in ->fallocate future proof X-Git-Tag: MMI-PSA29.97-13-9~20992^2~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=64c23e86873ee410554d6d1c76b60da47025e96f;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git make the feature checks in ->fallocate future proof 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 Signed-off-by: Al Viro --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a3798a3aa0d2..64daf2acd0d5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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; /* diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index c4068f6abf03..4bdd160854eb 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -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; /* diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 040b5a2e6556..c09528c07f3d 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -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) << diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 63e3fca266e0..cf254ce8c941 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -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; diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index da54403633b6..a4ecc2188a09 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c @@ -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))