Lines Matching refs:file

11 #include <linux/file.h>
42 /* SLAB cache for file structures */
47 /* Container for backing file with optional real path */
49 struct file file;
53 static inline struct backing_file *backing_file(struct file *f)
55 return container_of(f, struct backing_file, file);
58 struct path *backing_file_real_path(struct file *f)
66 struct file *f = container_of(head, struct file, f_rcuhead);
75 static inline void file_free(struct file *f)
116 .procname = "file-nr",
123 .procname = "file-max",
156 static int init_file(struct file *f, int flags, const struct cred *cred)
178 /* Find an unused file structure and return a pointer to it.
179 * Returns an error pointer if some error happend e.g. we over file
188 struct file *alloc_empty_file(int flags, const struct cred *cred)
191 struct file *f;
223 pr_info("VFS: file-max limit %lu reached\n", get_max_files());
232 * This is only for kernel internal use, and the allocate file must not be
233 * installed into file tables or such.
235 struct file *alloc_empty_file_noaccount(int flags, const struct cred *cred)
237 struct file *f;
259 * This is only for kernel internal use, and the allocate file must not be
260 * installed into file tables or such.
262 struct file *alloc_empty_backing_file(int flags, const struct cred *cred)
271 error = init_file(&ff->file, flags, cred);
277 ff->file.f_mode |= FMODE_BACKING | FMODE_NOACCOUNT;
278 return &ff->file;
282 * alloc_file - allocate and initialize a 'struct file'
284 * @path: the (dentry, vfsmount) pair for the new file
285 * @flags: O_... flags with which the new file will be opened
286 * @fop: the 'struct file_operations' for the new file
288 static struct file *alloc_file(const struct path *path, int flags,
291 struct file *file;
293 file = alloc_empty_file(flags, current_cred());
294 if (IS_ERR(file))
295 return file;
297 file->f_path = *path;
298 file->f_inode = path->dentry->d_inode;
299 file->f_mapping = path->dentry->d_inode->i_mapping;
300 file->f_wb_err = filemap_sample_wb_err(file->f_mapping);
301 file->f_sb_err = file_sample_sb_err(file);
303 file->f_mode |= FMODE_LSEEK;
304 if ((file->f_mode & FMODE_READ) &&
306 file->f_mode |= FMODE_CAN_READ;
307 if ((file->f_mode & FMODE_WRITE) &&
309 file->f_mode |= FMODE_CAN_WRITE;
310 file->f_iocb_flags = iocb_flags(file);
311 file->f_mode |= FMODE_OPENED;
312 file->f_op = fop;
313 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
315 return file;
318 struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt,
327 struct file *file;
336 file = alloc_file(&path, flags, fops);
337 if (IS_ERR(file)) {
341 return file;
345 struct file *alloc_file_clone(struct file *base, int flags,
348 struct file *f = alloc_file(&base->f_path, flags, fops);
356 /* the real guts of fput() - releasing the last reference to file
358 static void __fput(struct file *file)
360 struct dentry *dentry = file->f_path.dentry;
361 struct vfsmount *mnt = file->f_path.mnt;
362 struct inode *inode = file->f_inode;
363 fmode_t mode = file->f_mode;
365 if (unlikely(!(file->f_mode & FMODE_OPENED)))
370 fsnotify_close(file);
373 * in the file cleanup chain.
375 eventpoll_release(file);
376 locks_remove_file(file);
378 ima_file_free(file);
379 if (unlikely(file->f_flags & FASYNC)) {
380 if (file->f_op->fasync)
381 file->f_op->fasync(-1, file, 0);
383 if (file->f_op->release)
384 file->f_op->release(inode, file);
389 fops_put(file->f_op);
390 put_pid(file->f_owner.pid);
391 put_file_access(file);
397 file_free(file);
404 struct file *f, *t;
412 __fput(container_of(work, struct file, f_rcuhead));
419 * not left us with opened struct file waiting for __fput() - execve()
433 void fput(struct file *file)
435 if (atomic_long_dec_and_test(&file->f_count)) {
439 init_task_work(&file->f_rcuhead, ____fput);
440 if (!task_work_add(task, &file->f_rcuhead, TWA_RESUME))
445 * fput to avoid leaking *file.
449 if (llist_add(&file->f_llist, &delayed_fput_list))
458 * for this specific struct file it won't involve anything that would
462 void __fput_sync(struct file *file)
464 if (atomic_long_dec_and_test(&file->f_count))
465 __fput(file);
473 filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
479 * One file with associated inode and dcache is very roughly 1K. Per default