Skip to content

Commit

Permalink
ovl: add ovl_fallocate()
Browse files Browse the repository at this point in the history
Implement stacked fallocate.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Jul 18, 2018
1 parent 2f50283 commit aab8848
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions fs/overlayfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};

0 comments on commit aab8848

Please sign in to comment.