Lines Matching refs:fdt
47 static void __free_fdtable(struct fdtable *fdt) in __free_fdtable() argument
49 kvfree(fdt->fd); in __free_fdtable()
50 kvfree(fdt->open_fds); in __free_fdtable()
51 kfree(fdt); in __free_fdtable()
105 struct fdtable *fdt; in alloc_fdtable() local
129 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL); in alloc_fdtable()
130 if (!fdt) in alloc_fdtable()
132 fdt->max_fds = nr; in alloc_fdtable()
136 fdt->fd = data; in alloc_fdtable()
142 fdt->open_fds = data; in alloc_fdtable()
144 fdt->close_on_exec = data; in alloc_fdtable()
146 fdt->full_fds_bits = data; in alloc_fdtable()
148 return fdt; in alloc_fdtable()
151 kvfree(fdt->fd); in alloc_fdtable()
153 kfree(fdt); in alloc_fdtable()
194 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
214 struct fdtable *fdt; in expand_files() local
218 fdt = files_fdtable(files); in expand_files()
221 if (nr < fdt->max_fds) in expand_files()
245 static inline void __set_close_on_exec(int fd, struct fdtable *fdt) in __set_close_on_exec() argument
247 __set_bit(fd, fdt->close_on_exec); in __set_close_on_exec()
250 static inline void __clear_close_on_exec(int fd, struct fdtable *fdt) in __clear_close_on_exec() argument
252 if (test_bit(fd, fdt->close_on_exec)) in __clear_close_on_exec()
253 __clear_bit(fd, fdt->close_on_exec); in __clear_close_on_exec()
256 static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt) in __set_open_fd() argument
258 __set_bit(fd, fdt->open_fds); in __set_open_fd()
260 if (!~fdt->open_fds[fd]) in __set_open_fd()
261 __set_bit(fd, fdt->full_fds_bits); in __set_open_fd()
264 static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) in __clear_open_fd() argument
266 __clear_bit(fd, fdt->open_fds); in __clear_open_fd()
267 __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); in __clear_open_fd()
270 static int count_open_files(struct fdtable *fdt) in count_open_files() argument
272 int size = fdt->max_fds; in count_open_files()
277 if (fdt->open_fds[--i]) in count_open_files()
375 rcu_assign_pointer(newf->fdt, new_fdt); in dup_fd()
392 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files() local
398 if (i >= fdt->max_fds) in close_files()
400 set = fdt->open_fds[j++]; in close_files()
403 struct file * file = xchg(&fdt->fd[i], NULL); in close_files()
414 return fdt; in close_files()
433 struct fdtable *fdt = close_files(files); in put_files_struct() local
436 if (fdt != &files->fdtab) in put_files_struct()
437 __free_fdtable(fdt); in put_files_struct()
468 .fdt = &init_files.fdtab,
479 static unsigned long find_next_fd(struct fdtable *fdt, unsigned long start) in find_next_fd() argument
481 unsigned long maxfd = fdt->max_fds; in find_next_fd()
485 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; in find_next_fd()
490 return find_next_zero_bit(fdt->open_fds, maxfd, start); in find_next_fd()
501 struct fdtable *fdt; in __alloc_fd() local
505 fdt = files_fdtable(files); in __alloc_fd()
510 if (fd < fdt->max_fds) in __alloc_fd()
511 fd = find_next_fd(fdt, fd); in __alloc_fd()
535 __set_open_fd(fd, fdt); in __alloc_fd()
537 __set_close_on_exec(fd, fdt); in __alloc_fd()
539 __clear_close_on_exec(fd, fdt); in __alloc_fd()
543 if (rcu_access_pointer(fdt->fd[fd]) != NULL) { in __alloc_fd()
545 rcu_assign_pointer(fdt->fd[fd], NULL); in __alloc_fd()
567 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd() local
568 __clear_open_fd(fd, fdt); in __put_unused_fd()
606 struct fdtable *fdt; in __fd_install() local
618 fdt = rcu_dereference_sched(files->fdt); in __fd_install()
619 BUG_ON(fdt->fd[fd] != NULL); in __fd_install()
620 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
637 struct fdtable *fdt; in __close_fd() local
640 fdt = files_fdtable(files); in __close_fd()
641 if (fd >= fdt->max_fds) in __close_fd()
643 file = fdt->fd[fd]; in __close_fd()
646 rcu_assign_pointer(fdt->fd[fd], NULL); in __close_fd()
647 __clear_close_on_exec(fd, fdt); in __close_fd()
660 struct fdtable *fdt; in do_close_on_exec() local
667 fdt = files_fdtable(files); in do_close_on_exec()
668 if (fd >= fdt->max_fds) in do_close_on_exec()
670 set = fdt->close_on_exec[i]; in do_close_on_exec()
673 fdt->close_on_exec[i] = 0; in do_close_on_exec()
678 file = fdt->fd[fd]; in do_close_on_exec()
681 rcu_assign_pointer(fdt->fd[fd], NULL); in do_close_on_exec()
795 struct fdtable *fdt; in set_close_on_exec() local
797 fdt = files_fdtable(files); in set_close_on_exec()
799 __set_close_on_exec(fd, fdt); in set_close_on_exec()
801 __clear_close_on_exec(fd, fdt); in set_close_on_exec()
808 struct fdtable *fdt; in get_close_on_exec() local
811 fdt = files_fdtable(files); in get_close_on_exec()
812 res = close_on_exec(fd, fdt); in get_close_on_exec()
822 struct fdtable *fdt; in do_dup2() local
838 fdt = files_fdtable(files); in do_dup2()
839 tofree = fdt->fd[fd]; in do_dup2()
840 if (!tofree && fd_is_open(fd, fdt)) in do_dup2()
843 rcu_assign_pointer(fdt->fd[fd], file); in do_dup2()
844 __set_open_fd(fd, fdt); in do_dup2()
846 __set_close_on_exec(fd, fdt); in do_dup2()
848 __clear_close_on_exec(fd, fdt); in do_dup2()
964 struct fdtable *fdt; in iterate_fd() local
969 for (fdt = files_fdtable(files); n < fdt->max_fds; n++) { in iterate_fd()
971 file = rcu_dereference_check_fdtable(files, fdt->fd[n]); in iterate_fd()