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()
84 struct fdtable *fdt; in alloc_fdtable() local
108 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL); in alloc_fdtable()
109 if (!fdt) in alloc_fdtable()
111 fdt->max_fds = nr; in alloc_fdtable()
115 fdt->fd = data; in alloc_fdtable()
121 fdt->open_fds = data; in alloc_fdtable()
123 fdt->close_on_exec = data; in alloc_fdtable()
125 return fdt; in alloc_fdtable()
128 kvfree(fdt->fd); in alloc_fdtable()
130 kfree(fdt); in alloc_fdtable()
169 rcu_assign_pointer(files->fdt, new_fdt); in expand_fdtable()
189 struct fdtable *fdt; in expand_files() local
191 fdt = files_fdtable(files); in expand_files()
194 if (nr < fdt->max_fds) in expand_files()
205 static inline void __set_close_on_exec(int fd, struct fdtable *fdt) in __set_close_on_exec() argument
207 __set_bit(fd, fdt->close_on_exec); in __set_close_on_exec()
210 static inline void __clear_close_on_exec(int fd, struct fdtable *fdt) in __clear_close_on_exec() argument
212 __clear_bit(fd, fdt->close_on_exec); in __clear_close_on_exec()
215 static inline void __set_open_fd(int fd, struct fdtable *fdt) in __set_open_fd() argument
217 __set_bit(fd, fdt->open_fds); in __set_open_fd()
220 static inline void __clear_open_fd(int fd, struct fdtable *fdt) in __clear_open_fd() argument
222 __clear_bit(fd, fdt->open_fds); in __clear_open_fd()
225 static int count_open_files(struct fdtable *fdt) in count_open_files() argument
227 int size = fdt->max_fds; in count_open_files()
232 if (fdt->open_fds[--i]) in count_open_files()
339 rcu_assign_pointer(newf->fdt, new_fdt); in dup_fd()
356 struct fdtable *fdt = rcu_dereference_raw(files->fdt); in close_files() local
362 if (i >= fdt->max_fds) in close_files()
364 set = fdt->open_fds[j++]; in close_files()
367 struct file * file = xchg(&fdt->fd[i], NULL); in close_files()
378 return fdt; in close_files()
397 struct fdtable *fdt = close_files(files); in put_files_struct() local
400 if (fdt != &files->fdtab) in put_files_struct()
401 __free_fdtable(fdt); in put_files_struct()
432 .fdt = &init_files.fdtab,
450 struct fdtable *fdt; in __alloc_fd() local
454 fdt = files_fdtable(files); in __alloc_fd()
459 if (fd < fdt->max_fds) in __alloc_fd()
460 fd = find_next_zero_bit(fdt->open_fds, fdt->max_fds, fd); in __alloc_fd()
484 __set_open_fd(fd, fdt); in __alloc_fd()
486 __set_close_on_exec(fd, fdt); in __alloc_fd()
488 __clear_close_on_exec(fd, fdt); in __alloc_fd()
492 if (rcu_access_pointer(fdt->fd[fd]) != NULL) { in __alloc_fd()
494 rcu_assign_pointer(fdt->fd[fd], NULL); in __alloc_fd()
516 struct fdtable *fdt = files_fdtable(files); in __put_unused_fd() local
517 __clear_open_fd(fd, fdt); in __put_unused_fd()
555 struct fdtable *fdt; in __fd_install() local
557 fdt = files_fdtable(files); in __fd_install()
558 BUG_ON(fdt->fd[fd] != NULL); in __fd_install()
559 rcu_assign_pointer(fdt->fd[fd], file); in __fd_install()
576 struct fdtable *fdt; in __close_fd() local
579 fdt = files_fdtable(files); in __close_fd()
580 if (fd >= fdt->max_fds) in __close_fd()
582 file = fdt->fd[fd]; in __close_fd()
585 rcu_assign_pointer(fdt->fd[fd], NULL); in __close_fd()
586 __clear_close_on_exec(fd, fdt); in __close_fd()
599 struct fdtable *fdt; in do_close_on_exec() local
606 fdt = files_fdtable(files); in do_close_on_exec()
607 if (fd >= fdt->max_fds) in do_close_on_exec()
609 set = fdt->close_on_exec[i]; in do_close_on_exec()
612 fdt->close_on_exec[i] = 0; in do_close_on_exec()
617 file = fdt->fd[fd]; in do_close_on_exec()
620 rcu_assign_pointer(fdt->fd[fd], NULL); in do_close_on_exec()
728 struct fdtable *fdt; in set_close_on_exec() local
730 fdt = files_fdtable(files); in set_close_on_exec()
732 __set_close_on_exec(fd, fdt); in set_close_on_exec()
734 __clear_close_on_exec(fd, fdt); in set_close_on_exec()
741 struct fdtable *fdt; in get_close_on_exec() local
744 fdt = files_fdtable(files); in get_close_on_exec()
745 res = close_on_exec(fd, fdt); in get_close_on_exec()
755 struct fdtable *fdt; in do_dup2() local
771 fdt = files_fdtable(files); in do_dup2()
772 tofree = fdt->fd[fd]; in do_dup2()
773 if (!tofree && fd_is_open(fd, fdt)) in do_dup2()
776 rcu_assign_pointer(fdt->fd[fd], file); in do_dup2()
777 __set_open_fd(fd, fdt); in do_dup2()
779 __set_close_on_exec(fd, fdt); in do_dup2()
781 __clear_close_on_exec(fd, fdt); in do_dup2()
897 struct fdtable *fdt; in iterate_fd() local
902 for (fdt = files_fdtable(files); n < fdt->max_fds; n++) { in iterate_fd()
904 file = rcu_dereference_check_fdtable(files, fdt->fd[n]); in iterate_fd()