• Home
  • Raw
  • Download

Lines Matching full:files

49  * space if any.  This does not copy the file pointers.  Called with the files
72 * clear the extra space. Called with the files spinlock held for write.
149 * The files->file_lock should be held on entry, and will be held on exit.
151 static int expand_fdtable(struct files_struct *files, unsigned int nr) in expand_fdtable() argument
152 __releases(files->file_lock) in expand_fdtable()
153 __acquires(files->file_lock) in expand_fdtable()
157 spin_unlock(&files->file_lock); in expand_fdtable()
163 if (atomic_read(&files->count) > 1) in expand_fdtable()
166 spin_lock(&files->file_lock); in expand_fdtable()
177 cur_fdt = files_fdtable(files); in expand_fdtable()
180 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
181 if (cur_fdt != &files->fdtab) in expand_fdtable()
189 * Expand files.
192 * Return <0 error code on error; 0 when nothing done; 1 when files were
194 * The files->file_lock should be held on entry, and will be held on exit.
196 static int expand_files(struct files_struct *files, unsigned int nr) in expand_files() argument
197 __releases(files->file_lock) in expand_files()
198 __acquires(files->file_lock) in expand_files()
204 fdt = files_fdtable(files); in expand_files()
214 if (unlikely(files->resize_in_progress)) { in expand_files()
215 spin_unlock(&files->file_lock); in expand_files()
217 wait_event(files->resize_wait, !files->resize_in_progress); in expand_files()
218 spin_lock(&files->file_lock); in expand_files()
223 files->resize_in_progress = true; in expand_files()
224 expanded = expand_fdtable(files, nr); in expand_files()
225 files->resize_in_progress = false; in expand_files()
227 wake_up_all(&files->resize_wait); in expand_files()
281 * Allocate a new files structure and copy contents from the
282 * passed in files structure.
358 * instantiated in the files array if a sibling thread in dup_fd()
381 static struct fdtable *close_files(struct files_struct * files) in close_files() argument
386 * files structure. in close_files()
388 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files()
401 filp_close(file, files); in close_files()
415 struct files_struct *files; in get_files_struct() local
418 files = task->files; in get_files_struct()
419 if (files) in get_files_struct()
420 atomic_inc(&files->count); in get_files_struct()
423 return files; in get_files_struct()
426 void put_files_struct(struct files_struct *files) in put_files_struct() argument
428 if (atomic_dec_and_test(&files->count)) { in put_files_struct()
429 struct fdtable *fdt = close_files(files); in put_files_struct()
432 if (fdt != &files->fdtab) in put_files_struct()
434 kmem_cache_free(files_cachep, files); in put_files_struct()
438 void reset_files_struct(struct files_struct *files) in reset_files_struct() argument
443 old = tsk->files; in reset_files_struct()
445 tsk->files = files; in reset_files_struct()
452 struct files_struct * files = tsk->files; in exit_files() local
454 if (files) { in exit_files()
456 tsk->files = NULL; in exit_files()
458 put_files_struct(files); in exit_files()
493 int __alloc_fd(struct files_struct *files, in __alloc_fd() argument
500 spin_lock(&files->file_lock); in __alloc_fd()
502 fdt = files_fdtable(files); in __alloc_fd()
504 if (fd < files->next_fd) in __alloc_fd()
505 fd = files->next_fd; in __alloc_fd()
511 * N.B. For clone tasks sharing a files structure, this test in __alloc_fd()
512 * will limit the total number of files that can be opened. in __alloc_fd()
518 error = expand_files(files, fd); in __alloc_fd()
529 if (start <= files->next_fd) in __alloc_fd()
530 files->next_fd = fd + 1; in __alloc_fd()
547 spin_unlock(&files->file_lock); in __alloc_fd()
553 return __alloc_fd(current->files, start, rlimit(RLIMIT_NOFILE), flags); in alloc_fd()
558 return __alloc_fd(current->files, 0, nofile, flags); in __get_unused_fd_flags()
567 static void __put_unused_fd(struct files_struct *files, unsigned int fd) in __put_unused_fd() argument
569 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd()
571 if (fd < files->next_fd) in __put_unused_fd()
572 files->next_fd = fd; in __put_unused_fd()
577 struct files_struct *files = current->files; in put_unused_fd() local
578 spin_lock(&files->file_lock); in put_unused_fd()
579 __put_unused_fd(files, fd); in put_unused_fd()
580 spin_unlock(&files->file_lock); in put_unused_fd()
588 * The VFS is full of places where we drop the files lock between
599 * your throat. 'files' *MUST* be either current->files or obtained
605 void __fd_install(struct files_struct *files, unsigned int fd, in __fd_install() argument
612 if (unlikely(files->resize_in_progress)) { in __fd_install()
614 spin_lock(&files->file_lock); in __fd_install()
615 fdt = files_fdtable(files); in __fd_install()
618 spin_unlock(&files->file_lock); in __fd_install()
623 fdt = rcu_dereference_sched(files->fdt); in __fd_install()
635 __fd_install(current->files, fd, file); in fd_install()
640 static struct file *pick_file(struct files_struct *files, unsigned fd) in pick_file() argument
645 spin_lock(&files->file_lock); in pick_file()
646 fdt = files_fdtable(files); in pick_file()
653 __put_unused_fd(files, fd); in pick_file()
656 spin_unlock(&files->file_lock); in pick_file()
663 int __close_fd(struct files_struct *files, unsigned fd) in __close_fd() argument
667 file = pick_file(files, fd); in __close_fd()
671 return filp_close(file, files); in __close_fd()
688 struct files_struct *cur_fds = me->files, *fds = NULL; in __close_range()
741 * We're done closing the files we were supposed to. Time to install in __close_range()
745 me->files = cur_fds; in __close_range()
760 struct files_struct *files = current->files; in __close_fd_get_file() local
764 spin_lock(&files->file_lock); in __close_fd_get_file()
765 fdt = files_fdtable(files); in __close_fd_get_file()
772 __put_unused_fd(files, fd); in __close_fd_get_file()
773 spin_unlock(&files->file_lock); in __close_fd_get_file()
779 spin_unlock(&files->file_lock); in __close_fd_get_file()
784 void do_close_on_exec(struct files_struct *files) in do_close_on_exec() argument
790 spin_lock(&files->file_lock); in do_close_on_exec()
794 fdt = files_fdtable(files); in do_close_on_exec()
809 __put_unused_fd(files, fd); in do_close_on_exec()
810 spin_unlock(&files->file_lock); in do_close_on_exec()
811 filp_close(file, files); in do_close_on_exec()
813 spin_lock(&files->file_lock); in do_close_on_exec()
817 spin_unlock(&files->file_lock); in do_close_on_exec()
820 static struct file *__fget_files(struct files_struct *files, unsigned int fd, in __fget_files() argument
827 file = fcheck_files(files, fd); in __fget_files()
837 else if (__fcheck_files(files, fd) != file) { in __fget_files()
850 return __fget_files(current->files, fd, mask, refs); in __fget()
875 if (task->files) in fget_task()
876 file = __fget_files(task->files, fd, 0, 1); in fget_task()
900 struct files_struct *files = current->files; in __fget_light() local
903 if (atomic_read(&files->count) == 1) { in __fget_light()
904 file = __fcheck_files(files, fd); in __fget_light()
953 struct files_struct *files = current->files; in set_close_on_exec() local
955 spin_lock(&files->file_lock); in set_close_on_exec()
956 fdt = files_fdtable(files); in set_close_on_exec()
961 spin_unlock(&files->file_lock); in set_close_on_exec()
966 struct files_struct *files = current->files; in get_close_on_exec() local
970 fdt = files_fdtable(files); in get_close_on_exec()
976 static int do_dup2(struct files_struct *files, in do_dup2() argument
978 __releases(&files->file_lock) in do_dup2()
989 * fget() treats larval files as absent. Potentially interesting, in do_dup2()
997 fdt = files_fdtable(files); in do_dup2()
1008 spin_unlock(&files->file_lock); in do_dup2()
1011 filp_close(tofree, files); in do_dup2()
1016 spin_unlock(&files->file_lock); in do_dup2()
1023 struct files_struct *files = current->files; in replace_fd() local
1026 return __close_fd(files, fd); in replace_fd()
1031 spin_lock(&files->file_lock); in replace_fd()
1032 err = expand_files(files, fd); in replace_fd()
1035 return do_dup2(files, file, fd, flags); in replace_fd()
1038 spin_unlock(&files->file_lock); in replace_fd()
1102 struct files_struct *files = current->files; in ksys_dup3() local
1113 spin_lock(&files->file_lock); in ksys_dup3()
1114 err = expand_files(files, newfd); in ksys_dup3()
1123 return do_dup2(files, file, newfd, flags); in ksys_dup3()
1128 spin_unlock(&files->file_lock); in ksys_dup3()
1140 struct files_struct *files = current->files; in SYSCALL_DEFINE2() local
1144 if (!fcheck_files(files, oldfd)) in SYSCALL_DEFINE2()
1180 int iterate_fd(struct files_struct *files, unsigned n, in iterate_fd() argument
1186 if (!files) in iterate_fd()
1188 spin_lock(&files->file_lock); in iterate_fd()
1189 for (fdt = files_fdtable(files); n < fdt->max_fds; n++) { in iterate_fd()
1191 file = rcu_dereference_check_fdtable(files, fdt->fd[n]); in iterate_fd()
1198 spin_unlock(&files->file_lock); in iterate_fd()