Lines Matching refs:file
42 struct file *f = container_of(head, struct file, f_u.fu_rcuhead); in file_free_rcu()
48 static inline void file_free(struct file *f) in file_free()
76 int proc_nr_files(ctl_table *table, int write, struct file *filp, in proc_nr_files()
83 int proc_nr_files(ctl_table *table, int write, struct file *filp, in proc_nr_files()
100 struct file *get_empty_filp(void) in get_empty_filp()
104 struct file * f; in get_empty_filp()
166 struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry, in alloc_file()
169 struct file *file; in alloc_file() local
172 file = get_empty_filp(); in alloc_file()
173 if (!file) in alloc_file()
176 init_file(file, mnt, dentry, mode, fop); in alloc_file()
177 return file; in alloc_file()
198 int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, in init_file() argument
202 file->f_path.dentry = dentry; in init_file()
203 file->f_path.mnt = mntget(mnt); in init_file()
204 file->f_mapping = dentry->d_inode->i_mapping; in init_file()
205 file->f_mode = mode; in init_file()
206 file->f_op = fop; in init_file()
215 file_take_write(file); in init_file()
223 void fput(struct file *file) in fput() argument
225 if (atomic_long_dec_and_test(&file->f_count)) in fput()
226 __fput(file); in fput()
239 void drop_file_write_access(struct file *file) in drop_file_write_access() argument
241 struct vfsmount *mnt = file->f_path.mnt; in drop_file_write_access()
242 struct dentry *dentry = file->f_path.dentry; in drop_file_write_access()
249 if (file_check_writeable(file) != 0) in drop_file_write_access()
252 file_release_write(file); in drop_file_write_access()
259 void __fput(struct file *file) in __fput() argument
261 struct dentry *dentry = file->f_path.dentry; in __fput()
262 struct vfsmount *mnt = file->f_path.mnt; in __fput()
267 fsnotify_close(file); in __fput()
272 eventpoll_release(file); in __fput()
273 locks_remove_flock(file); in __fput()
275 if (unlikely(file->f_flags & FASYNC)) { in __fput()
276 if (file->f_op && file->f_op->fasync) in __fput()
277 file->f_op->fasync(-1, file, 0); in __fput()
279 if (file->f_op && file->f_op->release) in __fput()
280 file->f_op->release(inode, file); in __fput()
281 security_file_free(file); in __fput()
284 fops_put(file->f_op); in __fput()
285 put_pid(file->f_owner.pid); in __fput()
286 file_kill(file); in __fput()
287 if (file->f_mode & FMODE_WRITE) in __fput()
288 drop_file_write_access(file); in __fput()
289 file->f_path.dentry = NULL; in __fput()
290 file->f_path.mnt = NULL; in __fput()
291 file_free(file); in __fput()
296 struct file *fget(unsigned int fd) in fget()
298 struct file *file; in fget() local
302 file = fcheck_files(files, fd); in fget()
303 if (file) { in fget()
304 if (!atomic_long_inc_not_zero(&file->f_count)) { in fget()
312 return file; in fget()
324 struct file *fget_light(unsigned int fd, int *fput_needed) in fget_light()
326 struct file *file; in fget_light() local
331 file = fcheck_files(files, fd); in fget_light()
334 file = fcheck_files(files, fd); in fget_light()
335 if (file) { in fget_light()
336 if (atomic_long_inc_not_zero(&file->f_count)) in fget_light()
340 file = NULL; in fget_light()
345 return file; in fget_light()
349 void put_filp(struct file *file) in put_filp() argument
351 if (atomic_long_dec_and_test(&file->f_count)) { in put_filp()
352 security_file_free(file); in put_filp()
353 file_kill(file); in put_filp()
354 file_free(file); in put_filp()
358 void file_move(struct file *file, struct list_head *list) in file_move() argument
363 list_move(&file->f_u.fu_list, list); in file_move()
367 void file_kill(struct file *file) in file_kill() argument
369 if (!list_empty(&file->f_u.fu_list)) { in file_kill()
371 list_del_init(&file->f_u.fu_list); in file_kill()
378 struct file *file; in fs_may_remount_ro() local
382 list_for_each_entry(file, &sb->s_files, f_u.fu_list) { in fs_may_remount_ro()
383 struct inode *inode = file->f_path.dentry->d_inode; in fs_may_remount_ro()
390 if (S_ISREG(inode->i_mode) && (file->f_mode & FMODE_WRITE)) in fs_may_remount_ro()
404 filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, in files_init()