diff options
-rw-r--r-- | fs/open.c | 7 | ||||
-rw-r--r-- | include/linux/falloc.h | 1 |
2 files changed, 7 insertions, 1 deletions
@@ -223,7 +223,12 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
223 | return -EINVAL; | 223 | return -EINVAL; |
224 | 224 | ||
225 | /* Return error if mode is not supported */ | 225 | /* Return error if mode is not supported */ |
226 | if (mode && !(mode & FALLOC_FL_KEEP_SIZE)) | 226 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) |
227 | return -EOPNOTSUPP; | ||
228 | |||
229 | /* Punch hole must have keep size set */ | ||
230 | if ((mode & FALLOC_FL_PUNCH_HOLE) && | ||
231 | !(mode & FALLOC_FL_KEEP_SIZE)) | ||
227 | return -EOPNOTSUPP; | 232 | return -EOPNOTSUPP; |
228 | 233 | ||
229 | if (!(file->f_mode & FMODE_WRITE)) | 234 | if (!(file->f_mode & FMODE_WRITE)) |
diff --git a/include/linux/falloc.h b/include/linux/falloc.h index 3c155107d61f..73e0b628e058 100644 --- a/include/linux/falloc.h +++ b/include/linux/falloc.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _FALLOC_H_ | 2 | #define _FALLOC_H_ |
3 | 3 | ||
4 | #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ | 4 | #define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ |
5 | #define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ | ||
5 | 6 | ||
6 | #ifdef __KERNEL__ | 7 | #ifdef __KERNEL__ |
7 | 8 | ||