Lines Matching refs:fdt

35 static void __free_fdtable(struct fdtable *fdt)  in __free_fdtable()  argument
37 kvfree(fdt->fd); in __free_fdtable()
38 kvfree(fdt->open_fds); in __free_fdtable()
39 kfree(fdt); in __free_fdtable()
50 #define fdt_words(fdt) ((fdt)->max_fds / BITS_PER_LONG) // words in ->open_fds argument
104 struct fdtable *fdt; in alloc_fdtable() local
129 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT); in alloc_fdtable()
130 if (!fdt) in alloc_fdtable()
132 fdt->max_fds = nr; in alloc_fdtable()
136 fdt->fd = data; in alloc_fdtable()
143 fdt->open_fds = data; in alloc_fdtable()
145 fdt->close_on_exec = data; in alloc_fdtable()
147 fdt->full_fds_bits = data; in alloc_fdtable()
149 return fdt; in alloc_fdtable()
152 kvfree(fdt->fd); in alloc_fdtable()
154 kfree(fdt); in alloc_fdtable()
195 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
215 struct fdtable *fdt; in expand_files() local
219 fdt = files_fdtable(files); in expand_files()
222 if (nr < fdt->max_fds) in expand_files()
246 static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt) in __set_close_on_exec() argument
248 __set_bit(fd, fdt->close_on_exec); in __set_close_on_exec()
251 static inline void __clear_close_on_exec(unsigned int fd, struct fdtable *fdt) in __clear_close_on_exec() argument
253 if (test_bit(fd, fdt->close_on_exec)) in __clear_close_on_exec()
254 __clear_bit(fd, fdt->close_on_exec); in __clear_close_on_exec()
257 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt) in __set_open_fd() argument
259 __set_bit(fd, fdt->open_fds); in __set_open_fd()
261 if (!~fdt->open_fds[fd]) in __set_open_fd()
262 __set_bit(fd, fdt->full_fds_bits); in __set_open_fd()
265 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) in __clear_open_fd() argument
267 __clear_bit(fd, fdt->open_fds); in __clear_open_fd()
268 __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); in __clear_open_fd()
280 static unsigned int sane_fdtable_size(struct fdtable *fdt, struct fd_range *punch_hole) in sane_fdtable_size() argument
282 unsigned int last = find_last_bit(fdt->open_fds, fdt->max_fds); in sane_fdtable_size()
284 if (last == fdt->max_fds) in sane_fdtable_size()
287 last = find_last_bit(fdt->open_fds, punch_hole->from); in sane_fdtable_size()
385 rcu_assign_pointer(newf->fdt, new_fdt); in dup_fd()
401 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files() local
407 if (i >= fdt->max_fds) in close_files()
409 set = fdt->open_fds[j++]; in close_files()
412 struct file * file = xchg(&fdt->fd[i], NULL); in close_files()
423 return fdt; in close_files()
429 struct fdtable *fdt = close_files(files); in put_files_struct() local
432 if (fdt != &files->fdtab) in put_files_struct()
433 __free_fdtable(fdt); in put_files_struct()
452 .fdt = &init_files.fdtab,
464 static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start) in find_next_fd() argument
466 unsigned int maxfd = fdt->max_fds; /* always multiple of BITS_PER_LONG */ in find_next_fd()
470 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; in find_next_fd()
475 return find_next_zero_bit(fdt->open_fds, maxfd, start); in find_next_fd()
486 struct fdtable *fdt; in alloc_fd() local
490 fdt = files_fdtable(files); in alloc_fd()
495 if (fd < fdt->max_fds) in alloc_fd()
496 fd = find_next_fd(fdt, fd); in alloc_fd()
520 __set_open_fd(fd, fdt); in alloc_fd()
522 __set_close_on_exec(fd, fdt); in alloc_fd()
524 __clear_close_on_exec(fd, fdt); in alloc_fd()
528 if (rcu_access_pointer(fdt->fd[fd]) != NULL) { in alloc_fd()
530 rcu_assign_pointer(fdt->fd[fd], NULL); in alloc_fd()
552 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd() local
553 __clear_open_fd(fd, fdt); in __put_unused_fd()
587 struct fdtable *fdt; in fd_install() local
594 fdt = files_fdtable(files); in fd_install()
595 BUG_ON(fdt->fd[fd] != NULL); in fd_install()
596 rcu_assign_pointer(fdt->fd[fd], file); in fd_install()
602 fdt = rcu_dereference_sched(files->fdt); in fd_install()
603 BUG_ON(fdt->fd[fd] != NULL); in fd_install()
604 rcu_assign_pointer(fdt->fd[fd], file); in fd_install()
621 struct fdtable *fdt = files_fdtable(files); in pick_file() local
624 if (fd >= fdt->max_fds) in pick_file()
627 fd = array_index_nospec(fd, fdt->max_fds); in pick_file()
628 file = fdt->fd[fd]; in pick_file()
630 rcu_assign_pointer(fdt->fd[fd], NULL); in pick_file()
659 static inline unsigned last_fd(struct fdtable *fdt) in last_fd() argument
661 return fdt->max_fds - 1; in last_fd()
667 struct fdtable *fdt; in __range_cloexec() local
671 fdt = files_fdtable(cur_fds); in __range_cloexec()
672 max_fd = min(last_fd(fdt), max_fd); in __range_cloexec()
674 bitmap_set(fdt->close_on_exec, fd, max_fd - fd + 1); in __range_cloexec()
793 struct fdtable *fdt; in do_close_on_exec() local
800 fdt = files_fdtable(files); in do_close_on_exec()
801 if (fd >= fdt->max_fds) in do_close_on_exec()
803 set = fdt->close_on_exec[i]; in do_close_on_exec()
806 fdt->close_on_exec[i] = 0; in do_close_on_exec()
811 file = fdt->fd[fd]; in do_close_on_exec()
814 rcu_assign_pointer(fdt->fd[fd], NULL); in do_close_on_exec()
831 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in __fget_files_rcu() local
834 if (unlikely(fd >= fdt->max_fds)) in __fget_files_rcu()
837 fdentry = fdt->fd + array_index_nospec(fd, fdt->max_fds); in __fget_files_rcu()
866 if (unlikely(rcu_dereference_raw(files->fdt) != fdt) || in __fget_files_rcu()
1053 struct fdtable *fdt; in set_close_on_exec() local
1055 fdt = files_fdtable(files); in set_close_on_exec()
1057 __set_close_on_exec(fd, fdt); in set_close_on_exec()
1059 __clear_close_on_exec(fd, fdt); in set_close_on_exec()
1066 struct fdtable *fdt; in get_close_on_exec() local
1069 fdt = files_fdtable(files); in get_close_on_exec()
1070 res = close_on_exec(fd, fdt); in get_close_on_exec()
1080 struct fdtable *fdt; in do_dup2() local
1096 fdt = files_fdtable(files); in do_dup2()
1097 fd = array_index_nospec(fd, fdt->max_fds); in do_dup2()
1098 tofree = fdt->fd[fd]; in do_dup2()
1099 if (!tofree && fd_is_open(fd, fdt)) in do_dup2()
1102 rcu_assign_pointer(fdt->fd[fd], file); in do_dup2()
1103 __set_open_fd(fd, fdt); in do_dup2()
1105 __set_close_on_exec(fd, fdt); in do_dup2()
1107 __clear_close_on_exec(fd, fdt); in do_dup2()
1290 struct fdtable *fdt; in iterate_fd() local
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()