diff options
author | Namjae Jeon <namjae.jeon@samsung.com> | 2015-03-25 15:07:05 +1100 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-03-25 15:07:05 +1100 |
commit | dd46c787788d5bf5b974729d43e4c405814a4c7d (patch) | |
tree | 67ae36b5a9cbbec7b71995417f9350999dca6b9c /fs/open.c | |
parent | 444a702231412e82fb1c09679adc159301e9242c (diff) | |
download | op-kernel-dev-dd46c787788d5bf5b974729d43e4c405814a4c7d.zip op-kernel-dev-dd46c787788d5bf5b974729d43e4c405814a4c7d.tar.gz |
fs: Add support FALLOC_FL_INSERT_RANGE for fallocate
FALLOC_FL_INSERT_RANGE command is the opposite command of
FALLOC_FL_COLLAPSE_RANGE that is needed for someone who wants to add
some data in the middle of file.
FALLOC_FL_INSERT_RANGE will create space for writing new data within
a file after shifting extents to right as given length. This command
also has same limitations as FALLOC_FL_COLLAPSE_RANGE in that
operations need to be filesystem block boundary aligned and cannot
cross the current EOF.
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -231,8 +231,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) return -EINVAL; /* 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; /* 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)) 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)) return -EBADF; |