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()
93 struct file *realfile;
94 struct file *upperfile;
97 struct ovl_file *ovl_file_alloc(struct file *realfile) in ovl_file_alloc()
116 static bool ovl_is_real_file(const struct file *realfile, in ovl_is_real_file()
122 static struct file *ovl_real_file_path(const struct file *file, in ovl_real_file_path() argument
125 struct ovl_file *of = file->private_data; in ovl_real_file_path()
126 struct file *realfile = of->realfile; in ovl_real_file_path()
134 * metacopied file. We need the upperfile either way, so see if it in ovl_real_file_path()
138 struct file *upperfile = READ_ONCE(of->upperfile); in ovl_real_file_path()
139 struct file *old; in ovl_real_file_path()
142 upperfile = ovl_open_realfile(file, realpath); in ovl_real_file_path()
154 * Stored file must be from the right inode, unless someone's in ovl_real_file_path()
164 if (unlikely((file->f_flags ^ realfile->f_flags) & ~OVL_OPEN_FLAGS)) { in ovl_real_file_path()
165 int err = ovl_change_flags(realfile, file->f_flags); in ovl_real_file_path()
174 static struct file *ovl_real_file(const struct file *file) in ovl_real_file() argument
176 struct dentry *dentry = file_dentry(file); in ovl_real_file()
181 struct file *f = ovl_dir_real_file(file, false); in ovl_real_file()
195 return ovl_real_file_path(file, &realpath); in ovl_real_file()
198 static int ovl_open(struct inode *inode, struct file *file) in ovl_open() argument
200 struct dentry *dentry = file_dentry(file); in ovl_open()
201 struct file *realfile; in ovl_open()
211 err = ovl_maybe_copy_up(dentry, file->f_flags); in ovl_open()
216 file->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); in ovl_open()
222 realfile = ovl_open_realfile(file, &realpath); in ovl_open()
232 file->private_data = of; in ovl_open()
237 static int ovl_release(struct inode *inode, struct file *file) in ovl_release() argument
239 ovl_file_free(file->private_data); in ovl_release()
243 static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) in ovl_llseek() argument
245 struct inode *inode = file_inode(file); in ovl_llseek()
246 struct file *realfile; in ovl_llseek()
256 return file->f_pos; in ovl_llseek()
259 return vfs_setpos(file, 0, 0); in ovl_llseek()
262 realfile = ovl_real_file(file); in ovl_llseek()
267 * Overlay file f_pos is the master copy that is preserved in ovl_llseek()
271 * files, so we use the real file to perform seeks. in ovl_llseek()
274 realfile->f_pos = file->f_pos; in ovl_llseek()
280 file->f_pos = realfile->f_pos; in ovl_llseek()
286 static void ovl_file_modified(struct file *file) in ovl_file_modified() argument
289 ovl_copyattr(file_inode(file)); in ovl_file_modified()
297 static void ovl_file_accessed(struct file *file) in ovl_file_accessed() argument
303 if (file->f_flags & O_NOATIME) in ovl_file_accessed()
306 inode = file_inode(file); in ovl_file_accessed()
322 touch_atime(&file->f_path); in ovl_file_accessed()
327 struct file *file = iocb->ki_filp; in ovl_read_iter() local
328 struct file *realfile; in ovl_read_iter()
330 .cred = ovl_creds(file_inode(file)->i_sb), in ovl_read_iter()
337 realfile = ovl_real_file(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()
349 struct file *realfile; in ovl_write_iter()
364 realfile = ovl_real_file(file); in ovl_write_iter()
385 static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, in ovl_splice_read()
389 struct file *realfile; in ovl_splice_read()
415 * the real file.
417 static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, in ovl_splice_write()
420 struct file *realfile; in ovl_splice_write()
449 static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) in ovl_fsync() argument
451 struct dentry *dentry = file_dentry(file); in ovl_fsync()
454 struct file *upperfile; in ovl_fsync()
458 ret = ovl_sync_status(OVL_FS(file_inode(file)->i_sb)); in ovl_fsync()
462 /* Don't sync lower file for fear of receiving EROFS error */ in ovl_fsync()
468 upperfile = ovl_real_file_path(file, &upperpath); in ovl_fsync()
472 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fsync()
479 static int ovl_mmap(struct file *file, struct vm_area_struct *vma) in ovl_mmap() argument
481 struct ovl_file *of = file->private_data; in ovl_mmap()
483 .cred = ovl_creds(file_inode(file)->i_sb), in ovl_mmap()
490 static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len) in ovl_fallocate() argument
492 struct inode *inode = file_inode(file); in ovl_fallocate()
493 struct file *realfile; in ovl_fallocate()
500 ret = file_remove_privs(file); in ovl_fallocate()
504 realfile = ovl_real_file(file); in ovl_fallocate()
509 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fallocate()
514 ovl_file_modified(file); in ovl_fallocate()
522 static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) in ovl_fadvise() argument
524 struct file *realfile; in ovl_fadvise()
528 realfile = ovl_real_file(file); in ovl_fadvise()
532 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_fadvise()
545 static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, in ovl_copyfile()
546 struct file *file_out, loff_t pos_out, in ovl_copyfile()
550 struct file *realfile_in, *realfile_out; in ovl_copyfile()
602 static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, in ovl_copy_file_range()
603 struct file *file_out, loff_t pos_out, in ovl_copy_file_range()
610 static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, in ovl_remap_file_range()
611 struct file *file_out, loff_t pos_out, in ovl_remap_file_range()
637 static int ovl_flush(struct file *file, fl_owner_t id) in ovl_flush() argument
639 struct file *realfile; in ovl_flush()
643 realfile = ovl_real_file(file); in ovl_flush()
648 old_cred = ovl_override_creds(file_inode(file)->i_sb); in ovl_flush()