• Home
  • Raw
  • Download

Lines Matching refs:file

24 static struct file *ovl_open_realfile(const struct file *file,  in ovl_open_realfile()  argument
27 struct inode *inode = file_inode(file); in ovl_open_realfile()
28 struct file *realfile; in ovl_open_realfile()
30 int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY; in ovl_open_realfile()
33 realfile = open_with_fake_path(&file->f_path, flags, realinode, in ovl_open_realfile()
38 file, file, ovl_whatisit(inode, realinode), file->f_flags, in ovl_open_realfile()
46 static int ovl_change_flags(struct file *file, unsigned int flags) in ovl_change_flags() argument
48 struct inode *inode = file_inode(file); in ovl_change_flags()
55 if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK)) in ovl_change_flags()
60 if (((flags ^ file->f_flags) & O_APPEND) && IS_APPEND(inode)) in ovl_change_flags()
64 if (!file->f_mapping->a_ops || in ovl_change_flags()
65 !file->f_mapping->a_ops->direct_IO) in ovl_change_flags()
69 if (file->f_op->check_flags) { in ovl_change_flags()
70 err = file->f_op->check_flags(flags); in ovl_change_flags()
75 spin_lock(&file->f_lock); in ovl_change_flags()
76 file->f_flags = (file->f_flags & ~OVL_SETFL_MASK) | flags; in ovl_change_flags()
77 spin_unlock(&file->f_lock); in ovl_change_flags()
82 static int ovl_real_fdget_meta(const struct file *file, struct fd *real, in ovl_real_fdget_meta() argument
85 struct inode *inode = file_inode(file); in ovl_real_fdget_meta()
89 real->file = file->private_data; in ovl_real_fdget_meta()
97 if (unlikely(file_inode(real->file) != realinode)) { in ovl_real_fdget_meta()
99 real->file = ovl_open_realfile(file, realinode); in ovl_real_fdget_meta()
101 return PTR_ERR_OR_ZERO(real->file); in ovl_real_fdget_meta()
105 if (unlikely((file->f_flags ^ real->file->f_flags) & ~O_NOATIME)) in ovl_real_fdget_meta()
106 return ovl_change_flags(real->file, file->f_flags); in ovl_real_fdget_meta()
111 static int ovl_real_fdget(const struct file *file, struct fd *real) in ovl_real_fdget() argument
113 return ovl_real_fdget_meta(file, real, false); in ovl_real_fdget()
116 static int ovl_open(struct inode *inode, struct file *file) in ovl_open() argument
118 struct file *realfile; in ovl_open()
121 err = ovl_maybe_copy_up(file_dentry(file), file->f_flags); in ovl_open()
126 file->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); in ovl_open()
128 realfile = ovl_open_realfile(file, ovl_inode_realdata(inode)); in ovl_open()
132 file->private_data = realfile; in ovl_open()
137 static int ovl_release(struct inode *inode, struct file *file) in ovl_release() argument
139 fput(file->private_data); in ovl_release()
144 static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) in ovl_llseek() argument
146 struct inode *inode = file_inode(file); in ovl_llseek()
157 return file->f_pos; in ovl_llseek()
160 return vfs_setpos(file, 0, 0); in ovl_llseek()
163 ret = ovl_real_fdget(file, &real); in ovl_llseek()
175 real.file->f_pos = file->f_pos; in ovl_llseek()
178 ret = vfs_llseek(real.file, offset, whence); in ovl_llseek()
181 file->f_pos = real.file->f_pos; in ovl_llseek()
189 static void ovl_file_accessed(struct file *file) in ovl_file_accessed() argument
193 if (file->f_flags & O_NOATIME) in ovl_file_accessed()
196 inode = file_inode(file); in ovl_file_accessed()
208 touch_atime(&file->f_path); in ovl_file_accessed()
230 struct file *file = iocb->ki_filp; in ovl_read_iter() local
238 ret = ovl_real_fdget(file, &real); in ovl_read_iter()
242 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_read_iter()
243 ret = vfs_iter_read(real.file, iter, &iocb->ki_pos, in ovl_read_iter()
245 ovl_revert_creds(file_inode(file)->i_sb, old_cred); in ovl_read_iter()
247 ovl_file_accessed(file); in ovl_read_iter()
256 struct file *file = iocb->ki_filp; in ovl_write_iter() local
257 struct inode *inode = file_inode(file); in ovl_write_iter()
268 ret = file_remove_privs(file); in ovl_write_iter()
272 ret = ovl_real_fdget(file, &real); in ovl_write_iter()
276 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_write_iter()
277 file_start_write(real.file); in ovl_write_iter()
278 ret = vfs_iter_write(real.file, iter, &iocb->ki_pos, in ovl_write_iter()
280 file_end_write(real.file); in ovl_write_iter()
281 ovl_revert_creds(file_inode(file)->i_sb, old_cred); in ovl_write_iter()
294 static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) in ovl_fsync() argument
300 ret = ovl_real_fdget_meta(file, &real, !datasync); in ovl_fsync()
305 if (file_inode(real.file) == ovl_inode_upper(file_inode(file))) { in ovl_fsync()
306 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fsync()
307 ret = vfs_fsync_range(real.file, start, end, datasync); in ovl_fsync()
308 ovl_revert_creds(file_inode(file)->i_sb, old_cred); in ovl_fsync()
316 static int ovl_mmap(struct file *file, struct vm_area_struct *vma) in ovl_mmap() argument
318 struct file *realfile = file->private_data; in ovl_mmap()
325 if (WARN_ON(file != vma->vm_file)) in ovl_mmap()
330 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_mmap()
332 ovl_revert_creds(file_inode(file)->i_sb, old_cred); in ovl_mmap()
339 fput(file); in ovl_mmap()
342 ovl_file_accessed(file); in ovl_mmap()
347 static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len) in ovl_fallocate() argument
349 struct inode *inode = file_inode(file); in ovl_fallocate()
354 ret = ovl_real_fdget(file, &real); in ovl_fallocate()
358 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fallocate()
359 ret = vfs_fallocate(real.file, mode, offset, len); in ovl_fallocate()
360 ovl_revert_creds(file_inode(file)->i_sb, old_cred); in ovl_fallocate()
370 static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) in ovl_fadvise() argument
376 ret = ovl_real_fdget(file, &real); in ovl_fadvise()
380 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fadvise()
381 ret = vfs_fadvise(real.file, offset, len, advice); in ovl_fadvise()
382 ovl_revert_creds(file_inode(file)->i_sb, old_cred); in ovl_fadvise()
389 static long ovl_real_ioctl(struct file *file, unsigned int cmd, in ovl_real_ioctl() argument
396 ret = ovl_real_fdget(file, &real); in ovl_real_ioctl()
400 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_real_ioctl()
401 ret = vfs_ioctl(real.file, cmd, arg); in ovl_real_ioctl()
402 ovl_revert_creds(file_inode(file)->i_sb, old_cred); in ovl_real_ioctl()
409 static long ovl_ioctl_set_flags(struct file *file, unsigned int cmd, in ovl_ioctl_set_flags() argument
413 struct inode *inode = file_inode(file); in ovl_ioctl_set_flags()
419 ret = mnt_want_write_file(file); in ovl_ioctl_set_flags()
432 ret = ovl_maybe_copy_up(file_dentry(file), O_WRONLY); in ovl_ioctl_set_flags()
436 ret = ovl_real_ioctl(file, cmd, arg); in ovl_ioctl_set_flags()
442 mnt_drop_write_file(file); in ovl_ioctl_set_flags()
464 static long ovl_ioctl_set_fsflags(struct file *file, unsigned int cmd, in ovl_ioctl_set_fsflags() argument
472 return ovl_ioctl_set_flags(file, cmd, arg, in ovl_ioctl_set_fsflags()
492 static long ovl_ioctl_set_fsxflags(struct file *file, unsigned int cmd, in ovl_ioctl_set_fsxflags() argument
501 return ovl_ioctl_set_flags(file, cmd, arg, in ovl_ioctl_set_fsxflags()
505 static long ovl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) in ovl_ioctl() argument
512 ret = ovl_real_ioctl(file, cmd, arg); in ovl_ioctl()
516 ret = ovl_ioctl_set_fsflags(file, cmd, arg); in ovl_ioctl()
520 ret = ovl_ioctl_set_fsxflags(file, cmd, arg); in ovl_ioctl()
530 static long ovl_compat_ioctl(struct file *file, unsigned int cmd, in ovl_compat_ioctl() argument
546 return ovl_ioctl(file, cmd, arg); in ovl_compat_ioctl()
555 static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, in ovl_copyfile()
556 struct file *file_out, loff_t pos_out, in ovl_copyfile()
577 ret = vfs_copy_file_range(real_in.file, pos_in, in ovl_copyfile()
578 real_out.file, pos_out, len, flags); in ovl_copyfile()
582 ret = vfs_clone_file_range(real_in.file, pos_in, in ovl_copyfile()
583 real_out.file, pos_out, len, flags); in ovl_copyfile()
587 ret = vfs_dedupe_file_range_one(real_in.file, pos_in, in ovl_copyfile()
588 real_out.file, pos_out, len, in ovl_copyfile()
603 static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, in ovl_copy_file_range()
604 struct file *file_out, loff_t pos_out, in ovl_copy_file_range()
611 static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, in ovl_remap_file_range()
612 struct file *file_out, loff_t pos_out, in ovl_remap_file_range()