Lines Matching refs:file

40 static struct file *ovl_open_realfile(const struct file *file,  in ovl_open_realfile()  argument
43 struct inode *inode = file_inode(file); in ovl_open_realfile()
44 struct file *realfile; in ovl_open_realfile()
46 int flags = file->f_flags | OVL_OPEN_FLAGS; in ovl_open_realfile()
61 realfile = open_with_fake_path(&file->f_path, flags, realinode, in ovl_open_realfile()
67 file, file, ovl_whatisit(inode, realinode), file->f_flags, in ovl_open_realfile()
75 static int ovl_change_flags(struct file *file, unsigned int flags) in ovl_change_flags() argument
77 struct inode *inode = file_inode(file); in ovl_change_flags()
82 if (((flags ^ file->f_flags) & O_APPEND) && IS_APPEND(inode)) in ovl_change_flags()
86 if (!file->f_mapping->a_ops || in ovl_change_flags()
87 !file->f_mapping->a_ops->direct_IO) in ovl_change_flags()
91 if (file->f_op->check_flags) { in ovl_change_flags()
92 err = file->f_op->check_flags(flags); in ovl_change_flags()
97 spin_lock(&file->f_lock); in ovl_change_flags()
98 file->f_flags = (file->f_flags & ~OVL_SETFL_MASK) | flags; in ovl_change_flags()
99 spin_unlock(&file->f_lock); in ovl_change_flags()
104 static int ovl_real_fdget_meta(const struct file *file, struct fd *real, in ovl_real_fdget_meta() argument
107 struct inode *inode = file_inode(file); in ovl_real_fdget_meta()
111 real->file = file->private_data; in ovl_real_fdget_meta()
119 if (unlikely(file_inode(real->file) != realinode)) { in ovl_real_fdget_meta()
121 real->file = ovl_open_realfile(file, realinode); in ovl_real_fdget_meta()
123 return PTR_ERR_OR_ZERO(real->file); in ovl_real_fdget_meta()
127 if (unlikely((file->f_flags ^ real->file->f_flags) & ~OVL_OPEN_FLAGS)) in ovl_real_fdget_meta()
128 return ovl_change_flags(real->file, file->f_flags); in ovl_real_fdget_meta()
133 static int ovl_real_fdget(const struct file *file, struct fd *real) in ovl_real_fdget() argument
135 if (d_is_dir(file_dentry(file))) { in ovl_real_fdget()
137 real->file = ovl_dir_real_file(file, false); in ovl_real_fdget()
139 return PTR_ERR_OR_ZERO(real->file); in ovl_real_fdget()
142 return ovl_real_fdget_meta(file, real, false); in ovl_real_fdget()
145 static int ovl_open(struct inode *inode, struct file *file) in ovl_open() argument
147 struct file *realfile; in ovl_open()
150 err = ovl_maybe_copy_up(file_dentry(file), file->f_flags); in ovl_open()
155 file->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); in ovl_open()
157 realfile = ovl_open_realfile(file, ovl_inode_realdata(inode)); in ovl_open()
161 file->private_data = realfile; in ovl_open()
166 static int ovl_release(struct inode *inode, struct file *file) in ovl_release() argument
168 fput(file->private_data); in ovl_release()
173 static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) in ovl_llseek() argument
175 struct inode *inode = file_inode(file); in ovl_llseek()
186 return file->f_pos; in ovl_llseek()
189 return vfs_setpos(file, 0, 0); in ovl_llseek()
192 ret = ovl_real_fdget(file, &real); in ovl_llseek()
204 real.file->f_pos = file->f_pos; in ovl_llseek()
207 ret = vfs_llseek(real.file, offset, whence); in ovl_llseek()
210 file->f_pos = real.file->f_pos; in ovl_llseek()
218 static void ovl_file_accessed(struct file *file) in ovl_file_accessed() argument
222 if (file->f_flags & O_NOATIME) in ovl_file_accessed()
225 inode = file_inode(file); in ovl_file_accessed()
237 touch_atime(&file->f_path); in ovl_file_accessed()
295 struct file *file = iocb->ki_filp; in ovl_read_iter() local
303 ret = ovl_real_fdget(file, &real); in ovl_read_iter()
309 (!real.file->f_mapping->a_ops || in ovl_read_iter()
310 !real.file->f_mapping->a_ops->direct_IO)) in ovl_read_iter()
313 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_read_iter()
315 ret = vfs_iter_read(real.file, iter, &iocb->ki_pos, in ovl_read_iter()
328 kiocb_clone(&aio_req->iocb, iocb, real.file); in ovl_read_iter()
331 ret = vfs_iocb_iter_read(real.file, &aio_req->iocb, iter); in ovl_read_iter()
338 ovl_file_accessed(file); in ovl_read_iter()
347 struct file *file = iocb->ki_filp; in ovl_write_iter() local
348 struct inode *inode = file_inode(file); in ovl_write_iter()
360 ret = file_remove_privs(file); in ovl_write_iter()
364 ret = ovl_real_fdget(file, &real); in ovl_write_iter()
370 (!real.file->f_mapping->a_ops || in ovl_write_iter()
371 !real.file->f_mapping->a_ops->direct_IO)) in ovl_write_iter()
377 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_write_iter()
379 file_start_write(real.file); in ovl_write_iter()
380 ret = vfs_iter_write(real.file, iter, &iocb->ki_pos, in ovl_write_iter()
382 file_end_write(real.file); in ovl_write_iter()
393 file_start_write(real.file); in ovl_write_iter()
395 __sb_writers_release(file_inode(real.file)->i_sb, in ovl_write_iter()
400 kiocb_clone(&aio_req->iocb, iocb, real.file); in ovl_write_iter()
404 ret = vfs_iocb_iter_write(real.file, &aio_req->iocb, iter); in ovl_write_iter()
428 static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, in ovl_splice_write()
449 file_start_write(real.file); in ovl_splice_write()
451 ret = iter_file_splice_write(pipe, real.file, ppos, len, flags); in ovl_splice_write()
453 file_end_write(real.file); in ovl_splice_write()
465 static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) in ovl_fsync() argument
471 ret = ovl_sync_status(OVL_FS(file_inode(file)->i_sb)); in ovl_fsync()
475 ret = ovl_real_fdget_meta(file, &real, !datasync); in ovl_fsync()
480 if (file_inode(real.file) == ovl_inode_upper(file_inode(file))) { in ovl_fsync()
481 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fsync()
482 ret = vfs_fsync_range(real.file, start, end, datasync); in ovl_fsync()
491 static int ovl_mmap(struct file *file, struct vm_area_struct *vma) in ovl_mmap() argument
493 struct file *realfile = file->private_data; in ovl_mmap()
500 if (WARN_ON(file != vma->vm_file)) in ovl_mmap()
505 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_mmap()
508 ovl_file_accessed(file); in ovl_mmap()
513 static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len) in ovl_fallocate() argument
515 struct inode *inode = file_inode(file); in ovl_fallocate()
520 ret = ovl_real_fdget(file, &real); in ovl_fallocate()
524 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fallocate()
525 ret = vfs_fallocate(real.file, mode, offset, len); in ovl_fallocate()
536 static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) in ovl_fadvise() argument
542 ret = ovl_real_fdget(file, &real); in ovl_fadvise()
546 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fadvise()
547 ret = vfs_fadvise(real.file, offset, len, advice); in ovl_fadvise()
561 static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, in ovl_copyfile()
562 struct file *file_out, loff_t pos_out, in ovl_copyfile()
583 ret = vfs_copy_file_range(real_in.file, pos_in, in ovl_copyfile()
584 real_out.file, pos_out, len, flags); in ovl_copyfile()
588 ret = vfs_clone_file_range(real_in.file, pos_in, in ovl_copyfile()
589 real_out.file, pos_out, len, flags); in ovl_copyfile()
593 ret = vfs_dedupe_file_range_one(real_in.file, pos_in, in ovl_copyfile()
594 real_out.file, pos_out, len, in ovl_copyfile()
609 static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, in ovl_copy_file_range()
610 struct file *file_out, loff_t pos_out, in ovl_copy_file_range()
617 static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, in ovl_remap_file_range()
618 struct file *file_out, loff_t pos_out, in ovl_remap_file_range()
644 static int ovl_flush(struct file *file, fl_owner_t id) in ovl_flush() argument
650 err = ovl_real_fdget(file, &real); in ovl_flush()
654 if (real.file->f_op->flush) { in ovl_flush()
655 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_flush()
656 err = real.file->f_op->flush(real.file, id); in ovl_flush()