Lines Matching full:file

11 #include <linux/file.h>
40 /* SLAB cache for file structures */
47 struct file *f = container_of(head, struct file, f_u.fu_rcuhead); in file_free_rcu()
53 static inline void file_free(struct file *f) in file_free()
96 static struct file *__alloc_file(int flags, const struct cred *cred) in __alloc_file()
98 struct file *f; in __alloc_file()
123 /* Find an unused file structure and return a pointer to it.
124 * Returns an error pointer if some error happend e.g. we over file
133 struct file *alloc_empty_file(int flags, const struct cred *cred) in alloc_empty_file()
136 struct file *f; in alloc_empty_file()
159 pr_info("VFS: file-max limit %lu reached\n", get_max_files()); in alloc_empty_file()
170 struct file *alloc_empty_file_noaccount(int flags, const struct cred *cred) in alloc_empty_file_noaccount()
172 struct file *f = __alloc_file(flags, cred); in alloc_empty_file_noaccount()
181 * alloc_file - allocate and initialize a 'struct file'
183 * @path: the (dentry, vfsmount) pair for the new file
184 * @flags: O_... flags with which the new file will be opened
185 * @fop: the 'struct file_operations' for the new file
187 static struct file *alloc_file(const struct path *path, int flags, in alloc_file()
190 struct file *file; in alloc_file() local
192 file = alloc_empty_file(flags, current_cred()); in alloc_file()
193 if (IS_ERR(file)) in alloc_file()
194 return file; in alloc_file()
196 file->f_path = *path; in alloc_file()
197 file->f_inode = path->dentry->d_inode; in alloc_file()
198 file->f_mapping = path->dentry->d_inode->i_mapping; in alloc_file()
199 file->f_wb_err = filemap_sample_wb_err(file->f_mapping); in alloc_file()
200 file->f_sb_err = file_sample_sb_err(file); in alloc_file()
201 if ((file->f_mode & FMODE_READ) && in alloc_file()
203 file->f_mode |= FMODE_CAN_READ; in alloc_file()
204 if ((file->f_mode & FMODE_WRITE) && in alloc_file()
206 file->f_mode |= FMODE_CAN_WRITE; in alloc_file()
207 file->f_mode |= FMODE_OPENED; in alloc_file()
208 file->f_op = fop; in alloc_file()
209 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) in alloc_file()
211 return file; in alloc_file()
214 struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt, in alloc_file_pseudo()
223 struct file *file; in alloc_file_pseudo() local
232 file = alloc_file(&path, flags, fops); in alloc_file_pseudo()
233 if (IS_ERR(file)) { in alloc_file_pseudo()
237 return file; in alloc_file_pseudo()
241 struct file *alloc_file_clone(struct file *base, int flags, in alloc_file_clone()
244 struct file *f = alloc_file(&base->f_path, flags, fops); in alloc_file_clone()
252 /* the real guts of fput() - releasing the last reference to file
254 static void __fput(struct file *file) in __fput() argument
256 struct dentry *dentry = file->f_path.dentry; in __fput()
257 struct vfsmount *mnt = file->f_path.mnt; in __fput()
258 struct inode *inode = file->f_inode; in __fput()
259 fmode_t mode = file->f_mode; in __fput()
261 if (unlikely(!(file->f_mode & FMODE_OPENED))) in __fput()
266 fsnotify_close(file); in __fput()
269 * in the file cleanup chain. in __fput()
271 eventpoll_release(file); in __fput()
272 locks_remove_file(file); in __fput()
274 ima_file_free(file); in __fput()
275 if (unlikely(file->f_flags & FASYNC)) { in __fput()
276 if (file->f_op->fasync) in __fput()
277 file->f_op->fasync(-1, file, 0); in __fput()
279 if (file->f_op->release) in __fput()
280 file->f_op->release(inode, file); in __fput()
285 fops_put(file->f_op); in __fput()
286 put_pid(file->f_owner.pid); in __fput()
298 file_free(file); in __fput()
305 struct file *f, *t; in delayed_fput()
313 __fput(container_of(work, struct file, f_u.fu_rcuhead)); in ____fput()
320 * not left us with opened struct file waiting for __fput() - execve()
334 void fput_many(struct file *file, unsigned int refs) in fput_many() argument
336 if (atomic_long_sub_and_test(refs, &file->f_count)) { in fput_many()
340 init_task_work(&file->f_u.fu_rcuhead, ____fput); in fput_many()
341 if (!task_work_add(task, &file->f_u.fu_rcuhead, TWA_RESUME)) in fput_many()
346 * fput to avoid leaking *file. in fput_many()
350 if (llist_add(&file->f_u.fu_llist, &delayed_fput_list)) in fput_many()
355 void fput(struct file *file) in fput() argument
357 fput_many(file, 1); in fput()
364 * for this specific struct file it won't involve anything that would
368 void __fput_sync(struct file *file) in __fput_sync() argument
370 if (atomic_long_dec_and_test(&file->f_count)) { in __fput_sync()
373 __fput(file); in __fput_sync()
381 filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, in files_init()
387 * One file with associated inode and dcache is very roughly 1K. Per default