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()
124 /* Find an unused file structure and return a pointer to it.
125 * Returns an error pointer if some error happend e.g. we over file
134 struct file *alloc_empty_file(int flags, const struct cred *cred) in alloc_empty_file()
137 struct file *f; in alloc_empty_file()
160 pr_info("VFS: file-max limit %lu reached\n", get_max_files()); in alloc_empty_file()
171 struct file *alloc_empty_file_noaccount(int flags, const struct cred *cred) in alloc_empty_file_noaccount()
173 struct file *f = __alloc_file(flags, cred); in alloc_empty_file_noaccount()
182 * alloc_file - allocate and initialize a 'struct file'
184 * @path: the (dentry, vfsmount) pair for the new file
185 * @flags: O_... flags with which the new file will be opened
186 * @fop: the 'struct file_operations' for the new file
188 static struct file *alloc_file(const struct path *path, int flags, in alloc_file()
191 struct file *file; in alloc_file() local
193 file = alloc_empty_file(flags, current_cred()); in alloc_file()
194 if (IS_ERR(file)) in alloc_file()
195 return file; in alloc_file()
197 file->f_path = *path; in alloc_file()
198 file->f_inode = path->dentry->d_inode; in alloc_file()
199 file->f_mapping = path->dentry->d_inode->i_mapping; in alloc_file()
200 file->f_wb_err = filemap_sample_wb_err(file->f_mapping); in alloc_file()
201 file->f_sb_err = file_sample_sb_err(file); in alloc_file()
202 if ((file->f_mode & FMODE_READ) && in alloc_file()
204 file->f_mode |= FMODE_CAN_READ; in alloc_file()
205 if ((file->f_mode & FMODE_WRITE) && in alloc_file()
207 file->f_mode |= FMODE_CAN_WRITE; in alloc_file()
208 file->f_mode |= FMODE_OPENED; in alloc_file()
209 file->f_op = fop; in alloc_file()
210 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) in alloc_file()
212 return file; in alloc_file()
215 struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt, in alloc_file_pseudo()
224 struct file *file; in alloc_file_pseudo() local
233 file = alloc_file(&path, flags, fops); in alloc_file_pseudo()
234 if (IS_ERR(file)) { in alloc_file_pseudo()
238 return file; in alloc_file_pseudo()
242 struct file *alloc_file_clone(struct file *base, int flags, in alloc_file_clone()
245 struct file *f = alloc_file(&base->f_path, flags, fops); in alloc_file_clone()
253 /* the real guts of fput() - releasing the last reference to file
255 static void __fput(struct file *file) in __fput() argument
257 struct dentry *dentry = file->f_path.dentry; in __fput()
258 struct vfsmount *mnt = file->f_path.mnt; in __fput()
259 struct inode *inode = file->f_inode; in __fput()
260 fmode_t mode = file->f_mode; in __fput()
262 if (unlikely(!(file->f_mode & FMODE_OPENED))) in __fput()
267 fsnotify_close(file); in __fput()
270 * in the file cleanup chain. in __fput()
272 eventpoll_release(file); in __fput()
273 locks_remove_file(file); in __fput()
275 ima_file_free(file); in __fput()
276 if (unlikely(file->f_flags & FASYNC)) { in __fput()
277 if (file->f_op->fasync) in __fput()
278 file->f_op->fasync(-1, file, 0); in __fput()
280 if (file->f_op->release) in __fput()
281 file->f_op->release(inode, file); in __fput()
286 fops_put(file->f_op); in __fput()
287 put_pid(file->f_owner.pid); in __fput()
299 file_free(file); in __fput()
306 struct file *f, *t; in delayed_fput()
314 __fput(container_of(work, struct file, f_u.fu_rcuhead)); in ____fput()
321 * not left us with opened struct file waiting for __fput() - execve()
335 void fput_many(struct file *file, unsigned int refs) in fput_many() argument
337 if (atomic_long_sub_and_test(refs, &file->f_count)) { in fput_many()
341 init_task_work(&file->f_u.fu_rcuhead, ____fput); in fput_many()
342 if (!task_work_add(task, &file->f_u.fu_rcuhead, TWA_RESUME)) in fput_many()
347 * fput to avoid leaking *file. in fput_many()
351 if (llist_add(&file->f_u.fu_llist, &delayed_fput_list)) in fput_many()
356 void fput(struct file *file) in fput() argument
358 fput_many(file, 1); in fput()
365 * for this specific struct file it won't involve anything that would
369 void __fput_sync(struct file *file) in __fput_sync() argument
371 if (atomic_long_dec_and_test(&file->f_count)) { in __fput_sync()
374 __fput(file); in __fput_sync()
383 filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, in files_init()
389 * One file with associated inode and dcache is very roughly 1K. Per default