Lines Matching refs:files

153 static int expand_fdtable(struct files_struct *files, unsigned int nr)  in expand_fdtable()  argument
154 __releases(files->file_lock) in expand_fdtable()
155 __acquires(files->file_lock) in expand_fdtable()
159 spin_unlock(&files->file_lock); in expand_fdtable()
165 if (atomic_read(&files->count) > 1) in expand_fdtable()
168 spin_lock(&files->file_lock); in expand_fdtable()
179 cur_fdt = files_fdtable(files); in expand_fdtable()
182 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
183 if (cur_fdt != &files->fdtab) in expand_fdtable()
198 static int expand_files(struct files_struct *files, unsigned int nr) in expand_files() argument
199 __releases(files->file_lock) in expand_files()
200 __acquires(files->file_lock) in expand_files()
206 fdt = files_fdtable(files); in expand_files()
216 if (unlikely(files->resize_in_progress)) { in expand_files()
217 spin_unlock(&files->file_lock); in expand_files()
219 wait_event(files->resize_wait, !files->resize_in_progress); in expand_files()
220 spin_lock(&files->file_lock); in expand_files()
225 files->resize_in_progress = true; in expand_files()
226 expanded = expand_fdtable(files, nr); in expand_files()
227 files->resize_in_progress = false; in expand_files()
229 wake_up_all(&files->resize_wait); in expand_files()
383 static struct fdtable *close_files(struct files_struct * files) in close_files() argument
390 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files()
403 filp_close(file, files); in close_files()
415 void put_files_struct(struct files_struct *files) in put_files_struct() argument
417 if (atomic_dec_and_test(&files->count)) { in put_files_struct()
418 struct fdtable *fdt = close_files(files); in put_files_struct()
421 if (fdt != &files->fdtab) in put_files_struct()
423 kmem_cache_free(files_cachep, files); in put_files_struct()
429 struct files_struct * files = tsk->files; in exit_files() local
431 if (files) { in exit_files()
433 tsk->files = NULL; in exit_files()
435 put_files_struct(files); in exit_files()
472 struct files_struct *files = current->files; in alloc_fd() local
477 spin_lock(&files->file_lock); in alloc_fd()
479 fdt = files_fdtable(files); in alloc_fd()
481 if (fd < files->next_fd) in alloc_fd()
482 fd = files->next_fd; in alloc_fd()
495 error = expand_files(files, fd); in alloc_fd()
506 if (start <= files->next_fd) in alloc_fd()
507 files->next_fd = fd + 1; in alloc_fd()
524 spin_unlock(&files->file_lock); in alloc_fd()
539 static void __put_unused_fd(struct files_struct *files, unsigned int fd) in __put_unused_fd() argument
541 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd()
543 if (fd < files->next_fd) in __put_unused_fd()
544 files->next_fd = fd; in __put_unused_fd()
549 struct files_struct *files = current->files; in put_unused_fd() local
550 spin_lock(&files->file_lock); in put_unused_fd()
551 __put_unused_fd(files, fd); in put_unused_fd()
552 spin_unlock(&files->file_lock); in put_unused_fd()
575 struct files_struct *files = current->files; in fd_install() local
580 if (unlikely(files->resize_in_progress)) { in fd_install()
582 spin_lock(&files->file_lock); in fd_install()
583 fdt = files_fdtable(files); in fd_install()
586 spin_unlock(&files->file_lock); in fd_install()
591 fdt = rcu_dereference_sched(files->fdt); in fd_install()
609 static struct file *pick_file(struct files_struct *files, unsigned fd) in pick_file() argument
614 spin_lock(&files->file_lock); in pick_file()
615 fdt = files_fdtable(files); in pick_file()
626 __put_unused_fd(files, fd); in pick_file()
629 spin_unlock(&files->file_lock); in pick_file()
635 struct files_struct *files = current->files; in close_fd() local
638 file = pick_file(files, fd); in close_fd()
642 return filp_close(file, files); in close_fd()
705 struct files_struct *cur_fds = me->files, *fds = NULL; in __close_range()
757 me->files = cur_fds; in __close_range()
771 struct files_struct *files = current->files; in __close_fd_get_file() local
775 fdt = files_fdtable(files); in __close_fd_get_file()
782 __put_unused_fd(files, fd); in __close_fd_get_file()
798 struct files_struct *files = current->files; in close_fd_get_file() local
801 spin_lock(&files->file_lock); in close_fd_get_file()
803 spin_unlock(&files->file_lock); in close_fd_get_file()
808 void do_close_on_exec(struct files_struct *files) in do_close_on_exec() argument
814 spin_lock(&files->file_lock); in do_close_on_exec()
818 fdt = files_fdtable(files); in do_close_on_exec()
833 __put_unused_fd(files, fd); in do_close_on_exec()
834 spin_unlock(&files->file_lock); in do_close_on_exec()
835 filp_close(file, files); in do_close_on_exec()
837 spin_lock(&files->file_lock); in do_close_on_exec()
841 spin_unlock(&files->file_lock); in do_close_on_exec()
844 static inline struct file *__fget_files_rcu(struct files_struct *files, in __fget_files_rcu() argument
849 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in __fget_files_rcu()
885 if (unlikely(rcu_dereference_raw(files->fdt) != fdt) || in __fget_files_rcu()
899 static struct file *__fget_files(struct files_struct *files, unsigned int fd, in __fget_files() argument
905 file = __fget_files_rcu(files, fd, mask, refs); in __fget_files()
914 return __fget_files(current->files, fd, mask, refs); in __fget()
939 if (task->files) in fget_task()
940 file = __fget_files(task->files, fd, 0, 1); in fget_task()
949 struct files_struct *files; in task_lookup_fd_rcu() local
953 files = task->files; in task_lookup_fd_rcu()
954 if (files) in task_lookup_fd_rcu()
955 file = files_lookup_fd_rcu(files, fd); in task_lookup_fd_rcu()
964 struct files_struct *files; in task_lookup_next_fd_rcu() local
969 files = task->files; in task_lookup_next_fd_rcu()
970 if (files) { in task_lookup_next_fd_rcu()
971 for (; fd < files_fdtable(files)->max_fds; fd++) { in task_lookup_next_fd_rcu()
972 file = files_lookup_fd_rcu(files, fd); in task_lookup_next_fd_rcu()
1000 struct files_struct *files = current->files; in __fget_light() local
1003 if (atomic_read(&files->count) == 1) { in __fget_light()
1004 file = files_lookup_fd_raw(files, fd); in __fget_light()
1053 struct files_struct *files = current->files; in set_close_on_exec() local
1055 spin_lock(&files->file_lock); in set_close_on_exec()
1056 fdt = files_fdtable(files); in set_close_on_exec()
1061 spin_unlock(&files->file_lock); in set_close_on_exec()
1066 struct files_struct *files = current->files; in get_close_on_exec() local
1070 fdt = files_fdtable(files); in get_close_on_exec()
1076 static int do_dup2(struct files_struct *files, in do_dup2() argument
1078 __releases(&files->file_lock) in do_dup2()
1097 fdt = files_fdtable(files); in do_dup2()
1108 spin_unlock(&files->file_lock); in do_dup2()
1111 filp_close(tofree, files); in do_dup2()
1116 spin_unlock(&files->file_lock); in do_dup2()
1123 struct files_struct *files = current->files; in replace_fd() local
1131 spin_lock(&files->file_lock); in replace_fd()
1132 err = expand_files(files, fd); in replace_fd()
1135 return do_dup2(files, file, fd, flags); in replace_fd()
1138 spin_unlock(&files->file_lock); in replace_fd()
1207 struct files_struct *files = current->files; in ksys_dup3() local
1218 spin_lock(&files->file_lock); in ksys_dup3()
1219 err = expand_files(files, newfd); in ksys_dup3()
1220 file = files_lookup_fd_locked(files, oldfd); in ksys_dup3()
1228 return do_dup2(files, file, newfd, flags); in ksys_dup3()
1233 spin_unlock(&files->file_lock); in ksys_dup3()
1245 struct files_struct *files = current->files; in SYSCALL_DEFINE2() local
1249 if (!files_lookup_fd_rcu(files, oldfd)) in SYSCALL_DEFINE2()
1286 int iterate_fd(struct files_struct *files, unsigned n, in iterate_fd() argument
1292 if (!files) in iterate_fd()
1294 spin_lock(&files->file_lock); in iterate_fd()
1295 for (fdt = files_fdtable(files); n < fdt->max_fds; n++) { in iterate_fd()
1297 file = rcu_dereference_check_fdtable(files, fdt->fd[n]); in iterate_fd()
1304 spin_unlock(&files->file_lock); in iterate_fd()