Lines Matching refs:file

110  * flags in file.f_mode.  Note that FMODE_READ and FMODE_WRITE must correspond
114 /* file is open for reading */
116 /* file is open for writing */
118 /* file is seekable */
120 /* file can be accessed using pread */
122 /* file can be accessed using pwrite */
261 struct file *ia_file;
363 struct file *ki_filp;
395 int (*read_folio)(struct file *, struct folio *);
405 int (*write_begin)(struct file *, struct address_space *mapping,
408 int (*write_end)(struct file *, struct address_space *mapping,
431 int (*swap_activate)(struct swap_info_struct *sis, struct file *file,
433 void (*swap_deactivate)(struct file *file);
444 * file offset->disk block mappings in the filesystem during invalidates.
542 * Might pages of this file be mapped into userspace?
550 * Might pages of this file have been modified in userspace?
552 * marks vma as VM_SHARED if it is shared, and the file was opened for
950 * struct file_ra_state - Track a file's readahead state.
987 struct file {
989 /* fput() uses task work when closing and freeing file (default). */
1021 /* Used by fs/eventpoll.c to link all the hooks to this file */
1033 /* file identifier */
1037 static inline struct file *get_file(struct file *f)
1040 WARN_ONCE(!prior, "struct file::f_count incremented from zero; use-after-free condition present!\n");
1044 struct file *get_file_rcu(struct file __rcu **f);
1045 struct file *get_file_active(struct file **f);
1065 /* The following constant reflects the upper bound of the file/locking space */
1073 static inline struct inode *file_inode(const struct file *f)
1086 static inline struct dentry *file_dentry(const struct file *file)
1088 struct dentry *dentry = file->f_path.dentry;
1090 WARN_ON_ONCE(d_inode(dentry) != file_inode(file));
1099 struct file *fa_file;
1106 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
1107 extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *);
1108 extern int fasync_remove_entry(struct file *, struct fasync_struct **);
1115 extern void __f_setown(struct file *filp, struct pid *, enum pid_type, int force);
1116 extern int f_setown(struct file *filp, int who, int force);
1117 extern void f_delown(struct file *filp);
1118 extern pid_t f_getown(struct file *filp);
1209 loff_t s_maxbytes; /* Max file size */
1240 struct file *s_bdev_file;
1706 * @file: the file we write to
1712 static inline bool file_write_started(const struct file *file)
1714 if (!S_ISREG(file_inode(file)->i_mode))
1716 return sb_write_started(file_inode(file)->i_sb);
1721 * @file: the file we write to
1727 static inline bool file_write_not_started(const struct file *file)
1729 if (!S_ISREG(file_inode(file)->i_mode))
1731 return sb_write_not_started(file_inode(file)->i_sb);
1774 * When a process wants to write data or metadata to a file system (i.e. dirty
1776 * sb_end_write() pair to get exclusion against file system freezing. This
1777 * function increments number of writers preventing freezing. If the file
1778 * system is already frozen, the function waits until the file system is
1805 * exclusion against file system freezing. This is needed since the page fault
1807 * faults preventing freezing. If the file system is already frozen, the
1808 * function waits until the file system is thawed.
1833 * of filesystem changes (internal fs threads, discarding preallocation on file
1897 struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
1901 struct file *kernel_file_open(const struct path *path, int flags,
1908 int vfs_fchown(struct file *file, uid_t user, gid_t group);
1909 int vfs_fchmod(struct file *file, umode_t mode);
1912 extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1915 extern long compat_ptr_ioctl(struct file *file, unsigned int cmd,
1922 * VFS file helper functions.
1967 * If it is called with len == 0 that means "remap to end of source file".
2002 loff_t (*llseek) (struct file *, loff_t, int);
2003 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
2004 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
2009 int (*iterate_shared) (struct file *, struct dir_context *);
2010 __poll_t (*poll) (struct file *, struct poll_table_struct *);
2011 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
2012 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
2013 int (*mmap) (struct file *, struct vm_area_struct *);
2014 int (*open) (struct inode *, struct file *);
2015 int (*flush) (struct file *, fl_owner_t id);
2016 int (*release) (struct inode *, struct file *);
2017 int (*fsync) (struct file *, loff_t, loff_t, int datasync);
2018 int (*fasync) (int, struct file *, int);
2019 int (*lock) (struct file *, int, struct file_lock *);
2020 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
2022 int (*flock) (struct file *, int, struct file_lock *);
2023 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
2024 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
2025 void (*splice_eof)(struct file *file);
2026 int (*setlease)(struct file *, int, struct file_lease **, void **);
2027 long (*fallocate)(struct file *file, int mode, loff_t offset,
2029 void (*show_fdinfo)(struct seq_file *m, struct file *f);
2031 unsigned (*mmap_capabilities)(struct file *);
2033 ssize_t (*copy_file_range)(struct file *, loff_t, struct file *,
2035 loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in,
2036 struct file *file_out, loff_t pos_out,
2038 int (*fadvise)(struct file *, loff_t, loff_t, int);
2056 int wrap_directory_iterator(struct file *, struct dir_context *,
2057 int (*) (struct file *, struct dir_context *));
2059 static int shared_##x(struct file *file , struct dir_context *ctx) \
2060 { return wrap_directory_iterator(file, ctx, x); }
2091 struct file *, unsigned open_flag,
2094 struct file *, umode_t);
2105 static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
2107 return file->f_op->mmap(file, vma);
2110 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
2111 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
2112 extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
2114 int remap_verify_area(struct file *file, loff_t pos, loff_t len, bool write);
2115 int __generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,
2116 struct file *file_out, loff_t pos_out,
2119 int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,
2120 struct file *file_out, loff_t pos_out,
2122 extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in,
2123 struct file *file_out, loff_t pos_out,
2125 extern int vfs_dedupe_file_range(struct file *file,
2127 extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
2128 struct file *dst_file, loff_t dst_pos,
2191 #define S_APPEND (1 << 2) /* Append-only file */
2192 #define S_IMMUTABLE (1 << 3) /* Immutable file */
2196 #define S_NOCMTIME (1 << 7) /* Do not update file c/mtime */
2207 #define S_ENCRYPTED (1 << 14) /* Encrypted file (using fs/crypto/) */
2208 #define S_CASEFOLD (1 << 15) /* Casefolded file */
2209 #define S_VERITY (1 << 16) /* Verity file (using fs/verity/) */
2213 * Note that nosuid etc flags are inode-specific: setting some file-system
2218 * Exception: SB_RDONLY is always applied to the entire file system.
2275 static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
2285 struct file *filp)
2455 static inline void file_accessed(struct file *file)
2457 if (!(file->f_flags & O_NOATIME))
2458 touch_atime(&file->f_path);
2461 extern int file_modified(struct file *file);
2540 struct file *__file = (f); \
2617 static inline struct mnt_idmap *file_mnt_idmap(const struct file *file)
2619 return mnt_idmap(file->f_path.mnt);
2637 unsigned int time_attrs, struct file *filp);
2638 extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
2642 extern struct file *file_open_name(struct filename *, int, umode_t);
2643 extern struct file *filp_open(const char *, int, umode_t);
2644 extern struct file *file_open_root(const struct path *,
2646 static inline struct file *file_open_root_mnt(struct vfsmount *mnt,
2652 struct file *dentry_open(const struct path *path, int flags,
2654 struct file *dentry_create(const struct path *path, int flags, umode_t mode,
2656 struct path *backing_file_user_path(struct file *f);
2659 * When mmapping a file on a stackable filesystem (e.g., overlayfs), the file
2660 * stored in ->vm_file is a backing file whose f_inode is on the underlying
2661 * filesystem. When the mapped file path and inode number are displayed to
2668 static inline const struct path *file_user_path(struct file *f)
2675 static inline const struct inode *file_user_inode(struct file *f)
2682 static inline struct file *file_clone_open(struct file *file)
2684 return dentry_open(&file->f_path, file->f_flags, file->f_cred);
2686 extern int filp_close(struct file *, fl_owner_t id);
2694 extern int finish_open(struct file *file, struct dentry *dentry,
2695 int (*open)(struct inode *, struct file *));
2696 extern int finish_no_open(struct file *file, struct dentry *dentry);
2699 static inline int finish_open_simple(struct file *file, int error)
2704 return finish_open(file, file->f_path.dentry, NULL);
2762 extern int __must_check file_fdatawait_range(struct file *file, loff_t lstart,
2764 extern int __must_check file_check_and_advance_wb_err(struct file *file);
2765 extern int __must_check file_write_and_wait_range(struct file *file,
2768 static inline int file_write_and_wait(struct file *file)
2770 return file_write_and_wait_range(file, 0, LLONG_MAX);
2773 extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
2775 extern int vfs_fsync(struct file *file, int datasync);
2777 extern int sync_file_range(struct file *file, loff_t offset, loff_t nbytes,
2789 * of bytes passed in, or an error if syncing the file failed.
2820 static inline int file_permission(struct file *file, int mask)
2822 return inode_permission(file_mnt_idmap(file),
2823 file_inode(file), mask);
2844 * file_start_write - get write access to a superblock for regular file io
2845 * @file: the file we want to write to
2847 * This is a variant of sb_start_write() which is a noop on non-regualr file.
2850 static inline void file_start_write(struct file *file)
2852 if (!S_ISREG(file_inode(file)->i_mode))
2854 sb_start_write(file_inode(file)->i_sb);
2857 static inline bool file_start_write_trylock(struct file *file)
2859 if (!S_ISREG(file_inode(file)->i_mode))
2861 return sb_start_write_trylock(file_inode(file)->i_sb);
2865 * file_end_write - drop write access to a superblock of a regular file
2866 * @file: the file we wrote to
2870 static inline void file_end_write(struct file *file)
2872 if (!S_ISREG(file_inode(file)->i_mode))
2874 sb_end_write(file_inode(file)->i_sb);
2878 * kiocb_start_write - get write access to a superblock for async file io
2897 * kiocb_end_write - drop write access to a superblock after async file io
2919 * get_write_access() gets write permission for a file.
2921 * deny_write_access() denies write access to a file.
2922 * allow_write_access() re-enables write access to a file.
2926 * < 0: (-i_writecount) users that denied write access to the file.
2927 * > 0: (i_writecount) users that have write access to the file.
2938 static inline int deny_write_access(struct file *file)
2940 struct inode *inode = file_inode(file);
2947 static inline void allow_write_access(struct file *file)
2949 if (file)
2950 atomic_inc(&file_inode(file)->i_writecount);
2978 extern ssize_t kernel_read(struct file *, void *, size_t, loff_t *);
2979 ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos);
2980 extern ssize_t kernel_write(struct file *, const void *, size_t, loff_t *);
2981 extern ssize_t __kernel_write(struct file *, const void *, size_t, loff_t *);
2982 extern struct file * open_exec(const char *);
2988 extern char *file_path(struct file *, char *, int);
2992 * @name: file name to check
2993 * @len: length of file name, in bytes
3003 /* needed for stackable file system support */
3004 extern loff_t default_llseek(struct file *file, loff_t offset, int whence);
3006 extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence);
3078 extern int file_remove_privs_flags(struct file *file, unsigned int flags);
3079 extern int file_remove_privs(struct file *);
3108 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
3109 extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
3112 extern int generic_write_check_limits(struct file *file, loff_t pos,
3114 extern int generic_file_rw_checks(struct file *file_in, struct file *file_out);
3125 ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos,
3127 ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos,
3129 ssize_t vfs_iocb_iter_read(struct file *file, struct kiocb *iocb,
3131 ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb,
3135 ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
3138 ssize_t copy_splice_read(struct file *in, loff_t *ppos,
3142 struct file *, loff_t *, size_t, unsigned int);
3147 extern loff_t noop_llseek(struct file *file, loff_t offset, int whence);
3149 extern loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize);
3150 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence);
3151 extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
3153 extern loff_t fixed_size_llseek(struct file *file, loff_t offset,
3155 extern loff_t no_seek_end_llseek_size(struct file *, loff_t, int, loff_t);
3156 extern loff_t no_seek_end_llseek(struct file *, loff_t, int);
3157 int rw_verify_area(int, struct file *, const loff_t *, size_t);
3158 extern int generic_file_open(struct inode * inode, struct file * filp);
3159 extern int nonseekable_open(struct inode * inode, struct file * filp);
3160 extern int stream_open(struct inode * inode, struct file * filp);
3250 extern int iterate_dir(struct file *, struct dir_context *);
3277 extern int dcache_dir_open(struct inode *, struct file *);
3278 extern int dcache_dir_close(struct inode *, struct file *);
3279 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
3280 extern int dcache_readdir(struct file *, struct dir_context *);
3286 extern int simple_open(struct inode *inode, struct file *file);
3299 extern int noop_fsync(struct file *, loff_t, loff_t, int);
3302 extern int simple_write_begin(struct file *file, struct address_space *mapping,
3308 extern int simple_nosetlease(struct file *, int, struct file_lease **, void **);
3312 extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);
3348 extern int __generic_file_fsync(struct file *, loff_t, loff_t, int);
3349 extern int generic_file_fsync(struct file *, loff_t, loff_t, int);
3371 extern int file_update_time(struct file *file);
3392 static inline int iocb_flags(struct file *file)
3395 if (file->f_flags & O_APPEND)
3397 if (file->f_flags & O_DIRECT)
3399 if (file->f_flags & O_DSYNC)
3401 if (file->f_flags & __O_SYNC)
3466 char *simple_transaction_get(struct file *file, const char __user *buf,
3468 ssize_t simple_transaction_read(struct file *file, char __user *buf,
3470 int simple_transaction_release(struct inode *inode, struct file *file);
3472 void simple_transaction_set(struct file *file, size_t n);
3479 * Writing to an attribute immediately sets a value, an open file can be
3484 * completely, no further read calls are possible until the file is opened
3491 static int __fops ## _open(struct inode *inode, struct file *file) \
3494 return simple_attr_open(inode, file, __get, __set, __fmt); \
3517 int simple_attr_open(struct inode *inode, struct file *file,
3520 int simple_attr_release(struct inode *inode, struct file *file);
3521 ssize_t simple_attr_read(struct file *file, char __user *buf,
3523 ssize_t simple_attr_write(struct file *file, const char __user *buf,
3525 ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
3569 static inline bool dir_emit_dot(struct file *file, struct dir_context *ctx)
3572 file->f_path.dentry->d_inode->i_ino, DT_DIR);
3574 static inline bool dir_emit_dotdot(struct file *file, struct dir_context *ctx)
3577 parent_ino(file->f_path.dentry), DT_DIR);
3579 static inline bool dir_emit_dots(struct file *file, struct dir_context *ctx)
3582 if (!dir_emit_dot(file, ctx))
3587 if (!dir_emit_dotdot(file, ctx))
3611 extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
3613 extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,