Commit 64c23e86 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent eb745dbc
...@@ -7116,7 +7116,7 @@ static long btrfs_fallocate(struct inode *inode, int mode, ...@@ -7116,7 +7116,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
alloc_end = (offset + len + mask) & ~mask; alloc_end = (offset + len + mask) & ~mask;
/* We only support the FALLOC_FL_KEEP_SIZE mode */ /* We only support the FALLOC_FL_KEEP_SIZE mode */
if (mode && (mode != FALLOC_FL_KEEP_SIZE)) if (mode & ~FALLOC_FL_KEEP_SIZE)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* /*
......
...@@ -3645,7 +3645,7 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len) ...@@ -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; unsigned int credits, blkbits = inode->i_blkbits;
/* We only support the FALLOC_FL_KEEP_SIZE mode */ /* We only support the FALLOC_FL_KEEP_SIZE mode */
if (mode && (mode != FALLOC_FL_KEEP_SIZE)) if (mode & ~FALLOC_FL_KEEP_SIZE)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* /*
......
...@@ -1426,7 +1426,7 @@ static long gfs2_fallocate(struct inode *inode, int mode, loff_t offset, ...@@ -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; next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
/* We only support the FALLOC_FL_KEEP_SIZE mode */ /* We only support the FALLOC_FL_KEEP_SIZE mode */
if (mode && (mode != FALLOC_FL_KEEP_SIZE)) if (mode & ~FALLOC_FL_KEEP_SIZE)
return -EOPNOTSUPP; return -EOPNOTSUPP;
offset = (offset >> sdp->sd_sb.sb_bsize_shift) << offset = (offset >> sdp->sd_sb.sb_bsize_shift) <<
......
...@@ -1997,6 +1997,8 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset, ...@@ -1997,6 +1997,8 @@ static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset,
int change_size = 1; int change_size = 1;
int cmd = OCFS2_IOC_RESVSP64; int cmd = OCFS2_IOC_RESVSP64;
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return -EOPNOTSUPP;
if (!ocfs2_writes_unwritten_extents(osb)) if (!ocfs2_writes_unwritten_extents(osb))
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -518,6 +518,9 @@ xfs_vn_fallocate( ...@@ -518,6 +518,9 @@ xfs_vn_fallocate(
xfs_inode_t *ip = XFS_I(inode); xfs_inode_t *ip = XFS_I(inode);
int cmd = XFS_IOC_RESVSP; int cmd = XFS_IOC_RESVSP;
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return -EOPNOTSUPP;
/* preallocation on directories not yet supported */ /* preallocation on directories not yet supported */
error = -ENODEV; error = -ENODEV;
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment