Lines Matching full:file

7 #include <linux/file.h>
14 #include <linux/backing-file.h>
27 static struct file *ovl_open_realfile(const struct file *file, in ovl_open_realfile() argument
31 struct inode *inode = file_inode(file); in ovl_open_realfile()
33 struct file *realfile; in ovl_open_realfile()
35 int flags = file->f_flags | OVL_OPEN_FLAGS; in ovl_open_realfile()
51 realfile = backing_file_open(&file->f_path, flags, realpath, in ovl_open_realfile()
57 file, file, ovl_whatisit(inode, realinode), file->f_flags, in ovl_open_realfile()
65 static int ovl_change_flags(struct file *file, unsigned int flags) in ovl_change_flags() argument
67 struct inode *inode = file_inode(file); in ovl_change_flags()
72 if (((flags ^ file->f_flags) & O_APPEND) && IS_APPEND(inode)) in ovl_change_flags()
75 if ((flags & O_DIRECT) && !(file->f_mode & FMODE_CAN_ODIRECT)) in ovl_change_flags()
78 if (file->f_op->check_flags) { in ovl_change_flags()
79 err = file->f_op->check_flags(flags); in ovl_change_flags()
84 spin_lock(&file->f_lock); in ovl_change_flags()
85 file->f_flags = (file->f_flags & ~OVL_SETFL_MASK) | flags; in ovl_change_flags()
86 file->f_iocb_flags = iocb_flags(file); in ovl_change_flags()
87 spin_unlock(&file->f_lock); in ovl_change_flags()
92 static int ovl_real_fdget_meta(const struct file *file, struct fd *real, in ovl_real_fdget_meta() argument
95 struct dentry *dentry = file_dentry(file); in ovl_real_fdget_meta()
96 struct file *realfile = file->private_data; in ovl_real_fdget_meta()
117 struct file *f = ovl_open_realfile(file, &realpath); in ovl_real_fdget_meta()
125 if (unlikely((file->f_flags ^ realfile->f_flags) & ~OVL_OPEN_FLAGS)) in ovl_real_fdget_meta()
126 return ovl_change_flags(realfile, file->f_flags); in ovl_real_fdget_meta()
131 static int ovl_real_fdget(const struct file *file, struct fd *real) in ovl_real_fdget() argument
133 if (d_is_dir(file_dentry(file))) { in ovl_real_fdget()
134 struct file *f = ovl_dir_real_file(file, false); in ovl_real_fdget()
141 return ovl_real_fdget_meta(file, real, false); in ovl_real_fdget()
144 static int ovl_open(struct inode *inode, struct file *file) in ovl_open() argument
146 struct dentry *dentry = file_dentry(file); in ovl_open()
147 struct file *realfile; in ovl_open()
156 err = ovl_maybe_copy_up(dentry, file->f_flags); in ovl_open()
161 file->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); in ovl_open()
167 realfile = ovl_open_realfile(file, &realpath); in ovl_open()
171 file->private_data = realfile; in ovl_open()
176 static int ovl_release(struct inode *inode, struct file *file) in ovl_release() argument
178 fput(file->private_data); in ovl_release()
183 static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) in ovl_llseek() argument
185 struct inode *inode = file_inode(file); in ovl_llseek()
196 return file->f_pos; in ovl_llseek()
199 return vfs_setpos(file, 0, 0); in ovl_llseek()
202 ret = ovl_real_fdget(file, &real); in ovl_llseek()
207 * Overlay file f_pos is the master copy that is preserved in ovl_llseek()
211 * files, so we use the real file to perform seeks. in ovl_llseek()
214 fd_file(real)->f_pos = file->f_pos; in ovl_llseek()
220 file->f_pos = fd_file(real)->f_pos; in ovl_llseek()
228 static void ovl_file_modified(struct file *file) in ovl_file_modified() argument
231 ovl_copyattr(file_inode(file)); in ovl_file_modified()
234 static void ovl_file_end_write(struct file *file, loff_t pos, ssize_t ret) in ovl_file_end_write() argument
236 ovl_file_modified(file); in ovl_file_end_write()
239 static void ovl_file_accessed(struct file *file) in ovl_file_accessed() argument
245 if (file->f_flags & O_NOATIME) in ovl_file_accessed()
248 inode = file_inode(file); in ovl_file_accessed()
264 touch_atime(&file->f_path); in ovl_file_accessed()
269 struct file *file = iocb->ki_filp; in ovl_read_iter() local
273 .cred = ovl_creds(file_inode(file)->i_sb), in ovl_read_iter()
274 .user_file = file, in ovl_read_iter()
281 ret = ovl_real_fdget(file, &real); in ovl_read_iter()
294 struct file *file = iocb->ki_filp; in ovl_write_iter() local
295 struct inode *inode = file_inode(file); in ovl_write_iter()
301 .user_file = file, in ovl_write_iter()
312 ret = ovl_real_fdget(file, &real); in ovl_write_iter()
333 static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, in ovl_splice_read()
361 * the real file.
363 static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, in ovl_splice_write()
392 static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) in ovl_fsync() argument
398 ret = ovl_sync_status(OVL_FS(file_inode(file)->i_sb)); in ovl_fsync()
402 ret = ovl_real_fdget_meta(file, &real, !datasync); in ovl_fsync()
406 /* Don't sync lower file for fear of receiving EROFS error */ in ovl_fsync()
407 if (file_inode(fd_file(real)) == ovl_inode_upper(file_inode(file))) { in ovl_fsync()
408 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fsync()
418 static int ovl_mmap(struct file *file, struct vm_area_struct *vma) in ovl_mmap() argument
420 struct file *realfile = file->private_data; in ovl_mmap()
422 .cred = ovl_creds(file_inode(file)->i_sb), in ovl_mmap()
423 .user_file = file, in ovl_mmap()
430 static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len) in ovl_fallocate() argument
432 struct inode *inode = file_inode(file); in ovl_fallocate()
440 ret = file_remove_privs(file); in ovl_fallocate()
444 ret = ovl_real_fdget(file, &real); in ovl_fallocate()
448 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fallocate()
453 ovl_file_modified(file); in ovl_fallocate()
463 static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) in ovl_fadvise() argument
469 ret = ovl_real_fdget(file, &real); in ovl_fadvise()
473 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fadvise()
488 static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, in ovl_copyfile()
489 struct file *file_out, loff_t pos_out, in ovl_copyfile()
548 static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, in ovl_copy_file_range()
549 struct file *file_out, loff_t pos_out, in ovl_copy_file_range()
556 static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, in ovl_remap_file_range()
557 struct file *file_out, loff_t pos_out, in ovl_remap_file_range()
583 static int ovl_flush(struct file *file, fl_owner_t id) in ovl_flush() argument
589 err = ovl_real_fdget(file, &real); in ovl_flush()
594 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_flush()