|
@@ -231,8 +231,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
/* Return error if mode is not supported */
|
|
/* Return error if mode is not supported */
|
|
- if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
|
|
|
|
- FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE))
|
|
|
|
|
|
+ if (mode & ~FALLOC_FL_SUPPORTED_MASK)
|
|
return -EOPNOTSUPP;
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
/* Punch hole and zero range are mutually exclusive */
|
|
/* Punch hole and zero range are mutually exclusive */
|
|
@@ -250,6 +249,11 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
|
|
(mode & ~FALLOC_FL_COLLAPSE_RANGE))
|
|
(mode & ~FALLOC_FL_COLLAPSE_RANGE))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
+ /* Insert range should only be used exclusively. */
|
|
|
|
+ if ((mode & FALLOC_FL_INSERT_RANGE) &&
|
|
|
|
+ (mode & ~FALLOC_FL_INSERT_RANGE))
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
if (!(file->f_mode & FMODE_WRITE))
|
|
if (!(file->f_mode & FMODE_WRITE))
|
|
return -EBADF;
|
|
return -EBADF;
|
|
|
|
|