Skip to content

Commit

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

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Jul 18, 2018
1 parent de30dfd commit 2f50283
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions fs/overlayfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,43 @@ static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync)
return ret;
}

static int ovl_mmap(struct file *file, struct vm_area_struct *vma)
{
struct file *realfile = file->private_data;
const struct cred *old_cred;
int ret;

if (!realfile->f_op->mmap)
return -ENODEV;

if (WARN_ON(file != vma->vm_file))
return -EIO;

vma->vm_file = get_file(realfile);

old_cred = ovl_override_creds(file_inode(file)->i_sb);
ret = call_mmap(vma->vm_file, vma);
revert_creds(old_cred);

if (ret) {
/* Drop reference count from new vm_file value */
fput(realfile);
} else {
/* Drop reference count from previous vm_file value */
fput(file);
}

ovl_file_accessed(file);

return ret;
}

const struct file_operations ovl_file_operations = {
.open = ovl_open,
.release = ovl_release,
.llseek = ovl_llseek,
.read_iter = ovl_read_iter,
.write_iter = ovl_write_iter,
.fsync = ovl_fsync,
.mmap = ovl_mmap,
};

0 comments on commit 2f50283

Please sign in to comment.