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()
92 struct fdtable *fdt; in alloc_fdtable() local
116 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT); in alloc_fdtable()
117 if (!fdt) in alloc_fdtable()
119 fdt->max_fds = nr; in alloc_fdtable()
123 fdt->fd = data; in alloc_fdtable()
130 fdt->open_fds = data; in alloc_fdtable()
132 fdt->close_on_exec = data; in alloc_fdtable()
134 fdt->full_fds_bits = data; in alloc_fdtable()
136 return fdt; in alloc_fdtable()
139 kvfree(fdt->fd); in alloc_fdtable()
141 kfree(fdt); in alloc_fdtable()
182 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
202 struct fdtable *fdt; in expand_files() local
206 fdt = files_fdtable(files); in expand_files()
209 if (nr < fdt->max_fds) in expand_files()
233 static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt) in __set_close_on_exec() argument
235 __set_bit(fd, fdt->close_on_exec); in __set_close_on_exec()
238 static inline void __clear_close_on_exec(unsigned int fd, struct fdtable *fdt) in __clear_close_on_exec() argument
240 if (test_bit(fd, fdt->close_on_exec)) in __clear_close_on_exec()
241 __clear_bit(fd, fdt->close_on_exec); in __clear_close_on_exec()
244 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt) in __set_open_fd() argument
246 __set_bit(fd, fdt->open_fds); in __set_open_fd()
248 if (!~fdt->open_fds[fd]) in __set_open_fd()
249 __set_bit(fd, fdt->full_fds_bits); in __set_open_fd()
252 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) in __clear_open_fd() argument
254 __clear_bit(fd, fdt->open_fds); in __clear_open_fd()
255 __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); in __clear_open_fd()
258 static unsigned int count_open_files(struct fdtable *fdt) in count_open_files() argument
260 unsigned int size = fdt->max_fds; in count_open_files()
265 if (fdt->open_fds[--i]) in count_open_files()
272 static unsigned int sane_fdtable_size(struct fdtable *fdt, unsigned int max_fds) in sane_fdtable_size() argument
276 count = count_open_files(fdt); in sane_fdtable_size()
373 rcu_assign_pointer(newf->fdt, new_fdt); in dup_fd()
390 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files() local
396 if (i >= fdt->max_fds) in close_files()
398 set = fdt->open_fds[j++]; in close_files()
401 struct file * file = xchg(&fdt->fd[i], NULL); in close_files()
412 return fdt; in close_files()
418 struct fdtable *fdt = close_files(files); in put_files_struct() local
421 if (fdt != &files->fdtab) in put_files_struct()
422 __free_fdtable(fdt); in put_files_struct()
441 .fdt = &init_files.fdtab,
453 static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start) in find_next_fd() argument
455 unsigned int maxfd = fdt->max_fds; in find_next_fd()
459 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; in find_next_fd()
464 return find_next_zero_bit(fdt->open_fds, maxfd, start); in find_next_fd()
475 struct fdtable *fdt; in alloc_fd() local
479 fdt = files_fdtable(files); in alloc_fd()
484 if (fd < fdt->max_fds) in alloc_fd()
485 fd = find_next_fd(fdt, fd); in alloc_fd()
509 __set_open_fd(fd, fdt); in alloc_fd()
511 __set_close_on_exec(fd, fdt); in alloc_fd()
513 __clear_close_on_exec(fd, fdt); in alloc_fd()
517 if (rcu_access_pointer(fdt->fd[fd]) != NULL) { in alloc_fd()
519 rcu_assign_pointer(fdt->fd[fd], NULL); in alloc_fd()
541 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd() local
542 __clear_open_fd(fd, fdt); in __put_unused_fd()
576 struct fdtable *fdt; in fd_install() local
583 fdt = files_fdtable(files); in fd_install()
584 BUG_ON(fdt->fd[fd] != NULL); in fd_install()
585 rcu_assign_pointer(fdt->fd[fd], file); in fd_install()
591 fdt = rcu_dereference_sched(files->fdt); in fd_install()
592 BUG_ON(fdt->fd[fd] != NULL); in fd_install()
593 rcu_assign_pointer(fdt->fd[fd], file); in fd_install()
612 struct fdtable *fdt; in pick_file() local
615 fdt = files_fdtable(files); in pick_file()
616 if (fd >= fdt->max_fds) { in pick_file()
620 file = fdt->fd[fd]; in pick_file()
625 rcu_assign_pointer(fdt->fd[fd], NULL); in pick_file()
654 static inline unsigned last_fd(struct fdtable *fdt) in last_fd() argument
656 return fdt->max_fds - 1; in last_fd()
662 struct fdtable *fdt; in __range_cloexec() local
666 fdt = files_fdtable(cur_fds); in __range_cloexec()
667 max_fd = min(last_fd(fdt), max_fd); in __range_cloexec()
669 bitmap_set(fdt->close_on_exec, fd, max_fd - fd + 1); in __range_cloexec()
773 struct fdtable *fdt; in __close_fd_get_file() local
775 fdt = files_fdtable(files); in __close_fd_get_file()
776 if (fd >= fdt->max_fds) in __close_fd_get_file()
778 file = fdt->fd[fd]; in __close_fd_get_file()
781 rcu_assign_pointer(fdt->fd[fd], NULL); in __close_fd_get_file()
811 struct fdtable *fdt; in do_close_on_exec() local
818 fdt = files_fdtable(files); in do_close_on_exec()
819 if (fd >= fdt->max_fds) in do_close_on_exec()
821 set = fdt->close_on_exec[i]; in do_close_on_exec()
824 fdt->close_on_exec[i] = 0; in do_close_on_exec()
829 file = fdt->fd[fd]; in do_close_on_exec()
832 rcu_assign_pointer(fdt->fd[fd], NULL); in do_close_on_exec()
849 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in __fget_files_rcu() local
852 if (unlikely(fd >= fdt->max_fds)) in __fget_files_rcu()
855 fdentry = fdt->fd + array_index_nospec(fd, fdt->max_fds); in __fget_files_rcu()
885 if (unlikely(rcu_dereference_raw(files->fdt) != fdt) || in __fget_files_rcu()
1054 struct fdtable *fdt; in set_close_on_exec() local
1056 fdt = files_fdtable(files); in set_close_on_exec()
1058 __set_close_on_exec(fd, fdt); in set_close_on_exec()
1060 __clear_close_on_exec(fd, fdt); in set_close_on_exec()
1067 struct fdtable *fdt; in get_close_on_exec() local
1070 fdt = files_fdtable(files); in get_close_on_exec()
1071 res = close_on_exec(fd, fdt); in get_close_on_exec()
1081 struct fdtable *fdt; in do_dup2() local
1097 fdt = files_fdtable(files); 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()