summaryrefslogtreecommitdiff
path: root/fs/overlayfs
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2018-07-18 15:44:42 +0200
committerMiklos Szeredi <mszeredi@redhat.com>2018-07-18 15:44:42 +0200
commitaab8848cee5eca1003fc146b35b0c3293830a660 (patch)
tree3bf214469d48be6f6da5b22f692f1d10ee3ef2c1 /fs/overlayfs
parent2f502839e85ab265f03f25f30d6463154aee5473 (diff)
ovl: add ovl_fallocate()
Implement stacked fallocate. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r--fs/overlayfs/file.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 4c8bf77e048f..58b37fec133d 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -286,6 +286,29 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma)
return ret;
}
+static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
+{
+ struct inode *inode = file_inode(file);
+ struct fd real;
+ const struct cred *old_cred;
+ int ret;
+
+ ret = ovl_real_fdget(file, &real);
+ if (ret)
+ return ret;
+
+ old_cred = ovl_override_creds(file_inode(file)->i_sb);
+ ret = vfs_fallocate(real.file, mode, offset, len);
+ revert_creds(old_cred);
+
+ /* Update size */
+ ovl_copyattr(ovl_inode_real(inode), inode);
+
+ fdput(real);
+
+ return ret;
+}
+
const struct file_operations ovl_file_operations = {
.open = ovl_open,
.release = ovl_release,
@@ -294,4 +317,5 @@ const struct file_operations ovl_file_operations = {
.write_iter = ovl_write_iter,
.fsync = ovl_fsync,
.mmap = ovl_mmap,
+ .fallocate = ovl_fallocate,
};