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