Lines Matching refs:fdt

34 static void __free_fdtable(struct fdtable *fdt)  in __free_fdtable()  argument
36 kvfree(fdt->fd); in __free_fdtable()
37 kvfree(fdt->open_fds); in __free_fdtable()
38 kfree(fdt); in __free_fdtable()
107 struct fdtable *fdt; in alloc_fdtable() local
132 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT); in alloc_fdtable()
133 if (!fdt) in alloc_fdtable()
135 fdt->max_fds = nr; in alloc_fdtable()
139 fdt->fd = data; in alloc_fdtable()
146 fdt->open_fds = data; in alloc_fdtable()
148 fdt->close_on_exec = data; in alloc_fdtable()
150 fdt->full_fds_bits = data; in alloc_fdtable()
152 return fdt; in alloc_fdtable()
155 kvfree(fdt->fd); in alloc_fdtable()
157 kfree(fdt); in alloc_fdtable()
198 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
218 struct fdtable *fdt; in expand_files() local
222 fdt = files_fdtable(files); in expand_files()
225 if (nr < fdt->max_fds) in expand_files()
249 static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt) in __set_close_on_exec() argument
251 __set_bit(fd, fdt->close_on_exec); in __set_close_on_exec()
254 static inline void __clear_close_on_exec(unsigned int fd, struct fdtable *fdt) in __clear_close_on_exec() argument
256 if (test_bit(fd, fdt->close_on_exec)) in __clear_close_on_exec()
257 __clear_bit(fd, fdt->close_on_exec); in __clear_close_on_exec()
260 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt) in __set_open_fd() argument
262 __set_bit(fd, fdt->open_fds); in __set_open_fd()
264 if (!~fdt->open_fds[fd]) in __set_open_fd()
265 __set_bit(fd, fdt->full_fds_bits); in __set_open_fd()
268 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) in __clear_open_fd() argument
270 __clear_bit(fd, fdt->open_fds); in __clear_open_fd()
271 __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); in __clear_open_fd()
274 static unsigned int count_open_files(struct fdtable *fdt) in count_open_files() argument
276 unsigned int size = fdt->max_fds; in count_open_files()
281 if (fdt->open_fds[--i]) in count_open_files()
301 static unsigned int sane_fdtable_size(struct fdtable *fdt, unsigned int max_fds) in sane_fdtable_size() argument
305 count = count_open_files(fdt); in sane_fdtable_size()
402 rcu_assign_pointer(newf->fdt, new_fdt); in dup_fd()
419 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files() local
425 if (i >= fdt->max_fds) in close_files()
427 set = fdt->open_fds[j++]; in close_files()
430 struct file * file = xchg(&fdt->fd[i], NULL); in close_files()
441 return fdt; in close_files()
460 struct fdtable *fdt = close_files(files); in put_files_struct() local
463 if (fdt != &files->fdtab) in put_files_struct()
464 __free_fdtable(fdt); in put_files_struct()
495 .fdt = &init_files.fdtab,
507 static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start) in find_next_fd() argument
509 unsigned int maxfd = fdt->max_fds; in find_next_fd()
513 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; in find_next_fd()
518 return find_next_zero_bit(fdt->open_fds, maxfd, start); in find_next_fd()
529 struct fdtable *fdt; in __alloc_fd() local
533 fdt = files_fdtable(files); in __alloc_fd()
538 if (fd < fdt->max_fds) in __alloc_fd()
539 fd = find_next_fd(fdt, fd); in __alloc_fd()
563 __set_open_fd(fd, fdt); in __alloc_fd()
565 __set_close_on_exec(fd, fdt); in __alloc_fd()
567 __clear_close_on_exec(fd, fdt); in __alloc_fd()
571 if (rcu_access_pointer(fdt->fd[fd]) != NULL) { in __alloc_fd()
573 rcu_assign_pointer(fdt->fd[fd], NULL); in __alloc_fd()
600 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd() local
601 __clear_open_fd(fd, fdt); in __put_unused_fd()
639 struct fdtable *fdt; in __fd_install() local
646 fdt = files_fdtable(files); in __fd_install()
647 BUG_ON(fdt->fd[fd] != NULL); in __fd_install()
648 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
654 fdt = rcu_dereference_sched(files->fdt); in __fd_install()
655 BUG_ON(fdt->fd[fd] != NULL); in __fd_install()
656 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
674 struct fdtable *fdt; in pick_file() local
677 fdt = files_fdtable(files); in pick_file()
678 if (fd >= fdt->max_fds) in pick_file()
680 file = fdt->fd[fd]; in pick_file()
683 rcu_assign_pointer(fdt->fd[fd], NULL); in pick_file()
792 struct fdtable *fdt; in __close_fd_get_file() local
794 fdt = files_fdtable(files); in __close_fd_get_file()
795 if (fd >= fdt->max_fds) in __close_fd_get_file()
797 file = fdt->fd[fd]; in __close_fd_get_file()
800 rcu_assign_pointer(fdt->fd[fd], NULL); in __close_fd_get_file()
830 struct fdtable *fdt; in do_close_on_exec() local
837 fdt = files_fdtable(files); in do_close_on_exec()
838 if (fd >= fdt->max_fds) in do_close_on_exec()
840 set = fdt->close_on_exec[i]; in do_close_on_exec()
843 fdt->close_on_exec[i] = 0; in do_close_on_exec()
848 file = fdt->fd[fd]; in do_close_on_exec()
851 rcu_assign_pointer(fdt->fd[fd], NULL); in do_close_on_exec()
868 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in __fget_files_rcu() local
871 if (unlikely(fd >= fdt->max_fds)) in __fget_files_rcu()
874 fdentry = fdt->fd + array_index_nospec(fd, fdt->max_fds); in __fget_files_rcu()
904 if (unlikely(rcu_dereference_raw(files->fdt) != fdt) || in __fget_files_rcu()
1037 struct fdtable *fdt; in set_close_on_exec() local
1039 fdt = files_fdtable(files); in set_close_on_exec()
1041 __set_close_on_exec(fd, fdt); in set_close_on_exec()
1043 __clear_close_on_exec(fd, fdt); in set_close_on_exec()
1050 struct fdtable *fdt; in get_close_on_exec() local
1053 fdt = files_fdtable(files); in get_close_on_exec()
1054 res = close_on_exec(fd, fdt); in get_close_on_exec()
1064 struct fdtable *fdt; in do_dup2() local
1080 fdt = files_fdtable(files); in do_dup2()
1081 tofree = fdt->fd[fd]; in do_dup2()
1082 if (!tofree && fd_is_open(fd, fdt)) in do_dup2()
1085 rcu_assign_pointer(fdt->fd[fd], file); in do_dup2()
1086 __set_open_fd(fd, fdt); in do_dup2()
1088 __set_close_on_exec(fd, fdt); in do_dup2()
1090 __clear_close_on_exec(fd, fdt); in do_dup2()
1267 struct fdtable *fdt; in iterate_fd() local
1272 for (fdt = files_fdtable(files); n < fdt->max_fds; n++) { in iterate_fd()
1274 file = rcu_dereference_check_fdtable(files, fdt->fd[n]); in iterate_fd()