Lines Matching refs:fdt

33 static void __free_fdtable(struct fdtable *fdt)  in __free_fdtable()  argument
35 kvfree(fdt->fd); in __free_fdtable()
36 kvfree(fdt->open_fds); in __free_fdtable()
37 kfree(fdt); in __free_fdtable()
91 struct fdtable *fdt; in alloc_fdtable() local
115 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT); in alloc_fdtable()
116 if (!fdt) in alloc_fdtable()
118 fdt->max_fds = nr; in alloc_fdtable()
122 fdt->fd = data; in alloc_fdtable()
129 fdt->open_fds = data; in alloc_fdtable()
131 fdt->close_on_exec = data; in alloc_fdtable()
133 fdt->full_fds_bits = data; in alloc_fdtable()
135 return fdt; in alloc_fdtable()
138 kvfree(fdt->fd); in alloc_fdtable()
140 kfree(fdt); in alloc_fdtable()
181 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
201 struct fdtable *fdt; in expand_files() local
205 fdt = files_fdtable(files); in expand_files()
208 if (nr < fdt->max_fds) in expand_files()
232 static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt) in __set_close_on_exec() argument
234 __set_bit(fd, fdt->close_on_exec); in __set_close_on_exec()
237 static inline void __clear_close_on_exec(unsigned int fd, struct fdtable *fdt) in __clear_close_on_exec() argument
239 if (test_bit(fd, fdt->close_on_exec)) in __clear_close_on_exec()
240 __clear_bit(fd, fdt->close_on_exec); in __clear_close_on_exec()
243 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt) in __set_open_fd() argument
245 __set_bit(fd, fdt->open_fds); in __set_open_fd()
247 if (!~fdt->open_fds[fd]) in __set_open_fd()
248 __set_bit(fd, fdt->full_fds_bits); in __set_open_fd()
251 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) in __clear_open_fd() argument
253 __clear_bit(fd, fdt->open_fds); in __clear_open_fd()
254 __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); in __clear_open_fd()
257 static unsigned int count_open_files(struct fdtable *fdt) in count_open_files() argument
259 unsigned int size = fdt->max_fds; in count_open_files()
264 if (fdt->open_fds[--i]) in count_open_files()
271 static unsigned int sane_fdtable_size(struct fdtable *fdt, unsigned int max_fds) in sane_fdtable_size() argument
275 count = count_open_files(fdt); in sane_fdtable_size()
372 rcu_assign_pointer(newf->fdt, new_fdt); in dup_fd()
389 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files() local
395 if (i >= fdt->max_fds) in close_files()
397 set = fdt->open_fds[j++]; in close_files()
400 struct file * file = xchg(&fdt->fd[i], NULL); in close_files()
411 return fdt; in close_files()
430 struct fdtable *fdt = close_files(files); in put_files_struct() local
433 if (fdt != &files->fdtab) in put_files_struct()
434 __free_fdtable(fdt); in put_files_struct()
466 .fdt = &init_files.fdtab,
478 static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start) in find_next_fd() argument
480 unsigned int maxfd = fdt->max_fds; in find_next_fd()
484 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; in find_next_fd()
489 return find_next_zero_bit(fdt->open_fds, maxfd, start); in find_next_fd()
500 struct fdtable *fdt; in __alloc_fd() local
504 fdt = files_fdtable(files); in __alloc_fd()
509 if (fd < fdt->max_fds) in __alloc_fd()
510 fd = find_next_fd(fdt, fd); in __alloc_fd()
534 __set_open_fd(fd, fdt); in __alloc_fd()
536 __set_close_on_exec(fd, fdt); in __alloc_fd()
538 __clear_close_on_exec(fd, fdt); in __alloc_fd()
542 if (rcu_access_pointer(fdt->fd[fd]) != NULL) { in __alloc_fd()
544 rcu_assign_pointer(fdt->fd[fd], NULL); in __alloc_fd()
571 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd() local
572 __clear_open_fd(fd, fdt); in __put_unused_fd()
610 struct fdtable *fdt; in __fd_install() local
617 fdt = files_fdtable(files); in __fd_install()
618 BUG_ON(fdt->fd[fd] != NULL); in __fd_install()
619 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
625 fdt = rcu_dereference_sched(files->fdt); in __fd_install()
626 BUG_ON(fdt->fd[fd] != NULL); in __fd_install()
627 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
645 struct fdtable *fdt; in pick_file() local
648 fdt = files_fdtable(files); in pick_file()
649 if (fd >= fdt->max_fds) in pick_file()
651 file = fdt->fd[fd]; in pick_file()
654 rcu_assign_pointer(fdt->fd[fd], NULL); in pick_file()
764 struct fdtable *fdt; in __close_fd_get_file() local
767 fdt = files_fdtable(files); in __close_fd_get_file()
768 if (fd >= fdt->max_fds) in __close_fd_get_file()
770 file = fdt->fd[fd]; in __close_fd_get_file()
773 rcu_assign_pointer(fdt->fd[fd], NULL); in __close_fd_get_file()
789 struct fdtable *fdt; in do_close_on_exec() local
796 fdt = files_fdtable(files); in do_close_on_exec()
797 if (fd >= fdt->max_fds) in do_close_on_exec()
799 set = fdt->close_on_exec[i]; in do_close_on_exec()
802 fdt->close_on_exec[i] = 0; in do_close_on_exec()
807 file = fdt->fd[fd]; in do_close_on_exec()
810 rcu_assign_pointer(fdt->fd[fd], NULL); in do_close_on_exec()
952 struct fdtable *fdt; in set_close_on_exec() local
954 fdt = files_fdtable(files); in set_close_on_exec()
956 __set_close_on_exec(fd, fdt); in set_close_on_exec()
958 __clear_close_on_exec(fd, fdt); in set_close_on_exec()
965 struct fdtable *fdt; in get_close_on_exec() local
968 fdt = files_fdtable(files); in get_close_on_exec()
969 res = close_on_exec(fd, fdt); in get_close_on_exec()
979 struct fdtable *fdt; in do_dup2() local
995 fdt = files_fdtable(files); in do_dup2()
996 tofree = fdt->fd[fd]; in do_dup2()
997 if (!tofree && fd_is_open(fd, fdt)) in do_dup2()
1000 rcu_assign_pointer(fdt->fd[fd], file); in do_dup2()
1001 __set_open_fd(fd, fdt); in do_dup2()
1003 __set_close_on_exec(fd, fdt); in do_dup2()
1005 __clear_close_on_exec(fd, fdt); in do_dup2()
1182 struct fdtable *fdt; in iterate_fd() local
1187 for (fdt = files_fdtable(files); n < fdt->max_fds; n++) { in iterate_fd()
1189 file = rcu_dereference_check_fdtable(files, fdt->fd[n]); in iterate_fd()