Lines Matching full:file

11 #include <linux/file.h>
41 /* SLAB cache for file structures */
48 struct file *f = container_of(head, struct file, f_rcuhead); in file_free_rcu()
54 static inline void file_free(struct file *f) in file_free()
93 .procname = "file-nr",
100 .procname = "file-max",
133 static struct file *__alloc_file(int flags, const struct cred *cred) in __alloc_file()
135 struct file *f; in __alloc_file()
160 /* Find an unused file structure and return a pointer to it.
161 * Returns an error pointer if some error happend e.g. we over file
170 struct file *alloc_empty_file(int flags, const struct cred *cred) in alloc_empty_file()
173 struct file *f; in alloc_empty_file()
196 pr_info("VFS: file-max limit %lu reached\n", get_max_files()); in alloc_empty_file()
207 struct file *alloc_empty_file_noaccount(int flags, const struct cred *cred) in alloc_empty_file_noaccount()
209 struct file *f = __alloc_file(flags, cred); in alloc_empty_file_noaccount()
218 * alloc_file - allocate and initialize a 'struct file'
220 * @path: the (dentry, vfsmount) pair for the new file
221 * @flags: O_... flags with which the new file will be opened
222 * @fop: the 'struct file_operations' for the new file
224 static struct file *alloc_file(const struct path *path, int flags, in alloc_file()
227 struct file *file; in alloc_file() local
229 file = alloc_empty_file(flags, current_cred()); in alloc_file()
230 if (IS_ERR(file)) in alloc_file()
231 return file; in alloc_file()
233 file->f_path = *path; in alloc_file()
234 file->f_inode = path->dentry->d_inode; in alloc_file()
235 file->f_mapping = path->dentry->d_inode->i_mapping; in alloc_file()
236 file->f_wb_err = filemap_sample_wb_err(file->f_mapping); in alloc_file()
237 file->f_sb_err = file_sample_sb_err(file); in alloc_file()
239 file->f_mode |= FMODE_LSEEK; in alloc_file()
240 if ((file->f_mode & FMODE_READ) && in alloc_file()
242 file->f_mode |= FMODE_CAN_READ; in alloc_file()
243 if ((file->f_mode & FMODE_WRITE) && in alloc_file()
245 file->f_mode |= FMODE_CAN_WRITE; in alloc_file()
246 file->f_iocb_flags = iocb_flags(file); in alloc_file()
247 file->f_mode |= FMODE_OPENED; in alloc_file()
248 file->f_op = fop; in alloc_file()
249 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) in alloc_file()
251 return file; in alloc_file()
254 struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt, in alloc_file_pseudo()
263 struct file *file; in alloc_file_pseudo() local
272 file = alloc_file(&path, flags, fops); in alloc_file_pseudo()
273 if (IS_ERR(file)) { in alloc_file_pseudo()
277 return file; in alloc_file_pseudo()
281 struct file *alloc_file_clone(struct file *base, int flags, in alloc_file_clone()
284 struct file *f = alloc_file(&base->f_path, flags, fops); in alloc_file_clone()
292 /* the real guts of fput() - releasing the last reference to file
294 static void __fput(struct file *file) in __fput() argument
296 struct dentry *dentry = file->f_path.dentry; in __fput()
297 struct vfsmount *mnt = file->f_path.mnt; in __fput()
298 struct inode *inode = file->f_inode; in __fput()
299 fmode_t mode = file->f_mode; in __fput()
301 if (unlikely(!(file->f_mode & FMODE_OPENED))) in __fput()
306 fsnotify_close(file); in __fput()
309 * in the file cleanup chain. in __fput()
311 eventpoll_release(file); in __fput()
312 locks_remove_file(file); in __fput()
314 ima_file_free(file); in __fput()
315 if (unlikely(file->f_flags & FASYNC)) { in __fput()
316 if (file->f_op->fasync) in __fput()
317 file->f_op->fasync(-1, file, 0); in __fput()
319 if (file->f_op->release) in __fput()
320 file->f_op->release(inode, file); in __fput()
325 fops_put(file->f_op); in __fput()
326 put_pid(file->f_owner.pid); in __fput()
327 put_file_access(file); in __fput()
333 file_free(file); in __fput()
340 struct file *f, *t; in delayed_fput()
348 __fput(container_of(work, struct file, f_rcuhead)); in ____fput()
355 * not left us with opened struct file waiting for __fput() - execve()
369 void fput(struct file *file) in fput() argument
371 if (atomic_long_dec_and_test(&file->f_count)) { in fput()
375 init_task_work(&file->f_rcuhead, ____fput); in fput()
376 if (!task_work_add(task, &file->f_rcuhead, TWA_RESUME)) in fput()
381 * fput to avoid leaking *file. in fput()
385 if (llist_add(&file->f_llist, &delayed_fput_list)) in fput()
394 * for this specific struct file it won't involve anything that would
398 void __fput_sync(struct file *file) in __fput_sync() argument
400 if (atomic_long_dec_and_test(&file->f_count)) { in __fput_sync()
403 __fput(file); in __fput_sync()
412 filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, in files_init()
418 * One file with associated inode and dcache is very roughly 1K. Per default