Lines Matching refs:file

48 	struct file file;  member
55 #define backing_file(f) container_of(f, struct backing_file, file)
57 const struct path *backing_file_user_path(const struct file *f) in backing_file_user_path()
63 void backing_file_set_user_path(struct file *f, const struct path *path) in backing_file_set_user_path()
69 static inline void file_free(struct file *f) in file_free()
154 static int init_file(struct file *f, int flags, const struct cred *cred) in init_file()
218 struct file *alloc_empty_file(int flags, const struct cred *cred) in alloc_empty_file()
221 struct file *f; in alloc_empty_file()
266 struct file *alloc_empty_file_noaccount(int flags, const struct cred *cred) in alloc_empty_file_noaccount()
268 struct file *f; in alloc_empty_file_noaccount()
293 struct file *alloc_empty_backing_file(int flags, const struct cred *cred) in alloc_empty_backing_file()
302 error = init_file(&ff->file, flags, cred); in alloc_empty_backing_file()
308 ff->file.f_mode |= FMODE_BACKING | FMODE_NOACCOUNT; in alloc_empty_backing_file()
309 return &ff->file; in alloc_empty_backing_file()
319 static void file_init_path(struct file *file, const struct path *path, in file_init_path() argument
322 file->__f_path = *path; in file_init_path()
323 file->f_inode = path->dentry->d_inode; in file_init_path()
324 file->f_mapping = path->dentry->d_inode->i_mapping; in file_init_path()
325 file->f_wb_err = filemap_sample_wb_err(file->f_mapping); in file_init_path()
326 file->f_sb_err = file_sample_sb_err(file); in file_init_path()
328 file->f_mode |= FMODE_LSEEK; in file_init_path()
329 if ((file->f_mode & FMODE_READ) && in file_init_path()
331 file->f_mode |= FMODE_CAN_READ; in file_init_path()
332 if ((file->f_mode & FMODE_WRITE) && in file_init_path()
334 file->f_mode |= FMODE_CAN_WRITE; in file_init_path()
335 file->f_iocb_flags = iocb_flags(file); in file_init_path()
336 file->f_mode |= FMODE_OPENED; in file_init_path()
337 file->f_op = fop; in file_init_path()
338 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) in file_init_path()
349 static struct file *alloc_file(const struct path *path, int flags, in alloc_file()
352 struct file *file; in alloc_file() local
354 file = alloc_empty_file(flags, current_cred()); in alloc_file()
355 if (!IS_ERR(file)) in alloc_file()
356 file_init_path(file, path, fop); in alloc_file()
357 return file; in alloc_file()
371 struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt, in alloc_file_pseudo()
377 struct file *file; in alloc_file_pseudo() local
383 file = alloc_file(&path, flags, fops); in alloc_file_pseudo()
384 if (IS_ERR(file)) { in alloc_file_pseudo()
387 return file; in alloc_file_pseudo()
393 file_set_fsnotify_mode(file, FMODE_NONOTIFY); in alloc_file_pseudo()
394 return file; in alloc_file_pseudo()
398 struct file *alloc_file_pseudo_noaccount(struct inode *inode, in alloc_file_pseudo_noaccount()
405 struct file *file; in alloc_file_pseudo_noaccount() local
411 file = alloc_empty_file_noaccount(flags, current_cred()); in alloc_file_pseudo_noaccount()
412 if (IS_ERR(file)) { in alloc_file_pseudo_noaccount()
415 return file; in alloc_file_pseudo_noaccount()
417 file_init_path(file, &path, fops); in alloc_file_pseudo_noaccount()
422 file_set_fsnotify_mode(file, FMODE_NONOTIFY); in alloc_file_pseudo_noaccount()
423 return file; in alloc_file_pseudo_noaccount()
427 struct file *alloc_file_clone(struct file *base, int flags, in alloc_file_clone()
430 struct file *f; in alloc_file_clone()
442 static void __fput(struct file *file) in __fput() argument
444 struct dentry *dentry = file->f_path.dentry; in __fput()
445 struct vfsmount *mnt = file->f_path.mnt; in __fput()
446 struct inode *inode = file->f_inode; in __fput()
447 fmode_t mode = file->f_mode; in __fput()
449 if (unlikely(!(file->f_mode & FMODE_OPENED))) in __fput()
454 fsnotify_close(file); in __fput()
459 eventpoll_release(file); in __fput()
460 locks_remove_file(file); in __fput()
462 security_file_release(file); in __fput()
463 if (unlikely(file->f_flags & FASYNC)) { in __fput()
464 if (file->f_op->fasync) in __fput()
465 file->f_op->fasync(-1, file, 0); in __fput()
467 if (file->f_op->release) in __fput()
468 file->f_op->release(inode, file); in __fput()
473 fops_put(file->f_op); in __fput()
474 file_f_owner_release(file); in __fput()
475 put_file_access(file); in __fput()
481 file_free(file); in __fput()
488 struct file *f, *t; in delayed_fput()
496 __fput(container_of(work, struct file, f_task_work)); in ____fput()
518 static void __fput_deferred(struct file *file) in __fput_deferred() argument
522 if (unlikely(!(file->f_mode & (FMODE_BACKING | FMODE_OPENED)))) { in __fput_deferred()
523 file_free(file); in __fput_deferred()
528 init_task_work(&file->f_task_work, ____fput); in __fput_deferred()
529 if (!task_work_add(task, &file->f_task_work, TWA_RESUME)) in __fput_deferred()
538 if (llist_add(&file->f_llist, &delayed_fput_list)) in __fput_deferred()
542 void fput(struct file *file) in fput() argument
544 if (unlikely(file_ref_put(&file->f_ref))) in fput()
545 __fput_deferred(file); in fput()
557 void __fput_sync(struct file *file) in __fput_sync() argument
559 if (file_ref_put(&file->f_ref)) in __fput_sync()
560 __fput(file); in __fput_sync()
570 void fput_close_sync(struct file *file) in fput_close_sync() argument
572 if (likely(file_ref_put_close(&file->f_ref))) in fput_close_sync()
573 __fput(file); in fput_close_sync()
582 void fput_close(struct file *file) in fput_close() argument
584 if (file_ref_put_close(&file->f_ref)) in fput_close()
585 __fput_deferred(file); in fput_close()
592 .freeptr_offset = offsetof(struct file, f_freeptr), in files_init()
595 filp_cachep = kmem_cache_create("filp", sizeof(struct file), &args, in files_init()