Lines Matching refs:file
81 cpy = ofdt->max_fds * sizeof(struct file *); in copy_fdtable()
82 set = (nfdt->max_fds - ofdt->max_fds) * sizeof(struct file *); in copy_fdtable()
101 nr /= (1024 / sizeof(struct file *)); in alloc_fdtable()
103 nr *= (1024 / sizeof(struct file *)); in alloc_fdtable()
119 data = kvmalloc_array(nr, sizeof(struct file *), GFP_KERNEL_ACCOUNT); in alloc_fdtable()
289 struct file **old_fds, **new_fds; in dup_fd()
353 struct file *f = *old_fds++; in dup_fd()
370 memset(new_fds, 0, (new_fdt->max_fds - open_files) * sizeof(struct file *)); in dup_fd()
400 struct file * file = xchg(&fdt->fd[i], NULL); in close_files() local
401 if (file) { in close_files()
402 filp_close(file, files); in close_files()
608 struct file *file) in __fd_install() argument
619 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
627 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
635 void fd_install(unsigned int fd, struct file *file) in fd_install() argument
637 __fd_install(current->files, fd, file); in fd_install()
642 static struct file *pick_file(struct files_struct *files, unsigned fd) in pick_file()
644 struct file *file = NULL; in pick_file() local
651 file = fdt->fd[fd]; in pick_file()
652 if (!file) in pick_file()
659 return file; in pick_file()
667 struct file *file; in __close_fd() local
669 file = pick_file(files, fd); in __close_fd()
670 if (!file) in __close_fd()
673 return filp_close(file, files); in __close_fd()
731 struct file *file; in __close_range() local
733 file = pick_file(cur_fds, fd++); in __close_range()
734 if (!file) in __close_range()
737 filp_close(file, cur_fds); in __close_range()
760 int __close_fd_get_file(unsigned int fd, struct file **res) in __close_fd_get_file()
763 struct file *file; in __close_fd_get_file() local
770 file = fdt->fd[fd]; in __close_fd_get_file()
771 if (!file) in __close_fd_get_file()
776 get_file(file); in __close_fd_get_file()
777 *res = file; in __close_fd_get_file()
804 struct file *file; in do_close_on_exec() local
807 file = fdt->fd[fd]; in do_close_on_exec()
808 if (!file) in do_close_on_exec()
813 filp_close(file, files); in do_close_on_exec()
822 static struct file *__fget_files(struct files_struct *files, unsigned int fd, in __fget_files()
825 struct file *file; in __fget_files() local
829 file = fcheck_files(files, fd); in __fget_files()
830 if (file) { in __fget_files()
835 if (file->f_mode & mask) in __fget_files()
836 file = NULL; in __fget_files()
837 else if (!get_file_rcu_many(file, refs)) in __fget_files()
842 return file; in __fget_files()
845 static inline struct file *__fget(unsigned int fd, fmode_t mask, in __fget()
851 struct file *fget_many(unsigned int fd, unsigned int refs) in fget_many()
856 struct file *fget(unsigned int fd) in fget()
862 struct file *fget_raw(unsigned int fd) in fget_raw()
868 struct file *fget_task(struct task_struct *task, unsigned int fd) in fget_task()
870 struct file *file = NULL; in fget_task() local
874 file = __fget_files(task->files, fd, 0, 1); in fget_task()
877 return file; in fget_task()
899 struct file *file; in __fget_light() local
902 file = __fcheck_files(files, fd); in __fget_light()
903 if (!file || unlikely(file->f_mode & mask)) in __fget_light()
905 return (unsigned long)file; in __fget_light()
907 file = __fget(fd, mask, 1); in __fget_light()
908 if (!file) in __fget_light()
910 return FDPUT_FPUT | (unsigned long)file; in __fget_light()
927 struct file *file = (struct file *)(v & ~3); in __fdget_pos() local
929 if (file && (file->f_mode & FMODE_ATOMIC_POS)) { in __fdget_pos()
930 if (file_count(file) > 1) { in __fdget_pos()
932 mutex_lock(&file->f_pos_lock); in __fdget_pos()
938 void __f_unlock_pos(struct file *f) in __f_unlock_pos()
975 struct file *file, unsigned fd, unsigned flags) in do_dup2() argument
978 struct file *tofree; in do_dup2()
999 get_file(file); in do_dup2()
1000 rcu_assign_pointer(fdt->fd[fd], file); in do_dup2()
1018 int replace_fd(unsigned fd, struct file *file, unsigned flags) in replace_fd() argument
1023 if (!file) in replace_fd()
1033 return do_dup2(files, file, fd, flags); in replace_fd()
1057 int __receive_fd(int fd, struct file *file, int __user *ufd, unsigned int o_flags) in __receive_fd() argument
1062 error = security_file_receive(file); in __receive_fd()
1084 fd_install(new_fd, get_file(file)); in __receive_fd()
1086 error = replace_fd(new_fd, file, o_flags); in __receive_fd()
1092 __receive_sock(file); in __receive_fd()
1099 struct file *file; in ksys_dup3() local
1113 file = fcheck(oldfd); in ksys_dup3()
1114 if (unlikely(!file)) in ksys_dup3()
1121 return do_dup2(files, file, newfd, flags); in ksys_dup3()
1153 struct file *file = fget_raw(fildes); in SYSCALL_DEFINE1() local
1155 if (file) { in SYSCALL_DEFINE1()
1158 fd_install(ret, file); in SYSCALL_DEFINE1()
1160 fput(file); in SYSCALL_DEFINE1()
1165 int f_dupfd(unsigned int from, struct file *file, unsigned flags) in f_dupfd() argument
1172 get_file(file); in f_dupfd()
1173 fd_install(err, file); in f_dupfd()
1179 int (*f)(const void *, struct file *, unsigned), in iterate_fd() argument
1188 struct file *file; in iterate_fd() local
1189 file = rcu_dereference_check_fdtable(files, fdt->fd[n]); in iterate_fd()
1190 if (!file) in iterate_fd()
1192 res = f(p, file, n); in iterate_fd()