Lines Matching refs:files

29 static int expand_files(struct files_struct *files, int nr)  in expand_files()  argument
36 if (nr >= files->max_fdset) { in expand_files()
38 if ((err = expand_fdset(files, nr))) in expand_files()
41 if (nr >= files->max_fds) { in expand_files()
43 if ((err = expand_fd_array(files, nr))) in expand_files()
61 static int locate_fd(struct files_struct *files, in locate_fd() argument
68 write_lock(&files->file_lock); in locate_fd()
80 if (start < files->next_fd) in locate_fd()
81 start = files->next_fd; in locate_fd()
84 if (start < files->max_fdset) { in locate_fd()
85 newfd = find_next_zero_bit(files->open_fds->fds_bits, in locate_fd()
86 files->max_fdset, start); in locate_fd()
93 error = expand_files(files, newfd); in locate_fd()
104 if (start <= files->next_fd) in locate_fd()
105 files->next_fd = newfd + 1; in locate_fd()
113 static inline void allocate_fd(struct files_struct *files, in allocate_fd() argument
116 FD_SET(fd, files->open_fds); in allocate_fd()
117 FD_CLR(fd, files->close_on_exec); in allocate_fd()
118 write_unlock(&files->file_lock); in allocate_fd()
124 struct files_struct * files = current->files; in dupfd() local
127 ret = locate_fd(files, file, start); in dupfd()
130 allocate_fd(files, file, ret); in dupfd()
134 write_unlock(&files->file_lock); in dupfd()
143 struct files_struct * files = current->files; in sys_dup2() local
145 write_lock(&files->file_lock); in sys_dup2()
156 err = expand_files(files, newfd); in sys_dup2()
169 tofree = files->fd[newfd]; in sys_dup2()
170 if (!tofree && FD_ISSET(newfd, files->open_fds)) in sys_dup2()
173 files->fd[newfd] = file; in sys_dup2()
174 FD_SET(newfd, files->open_fds); in sys_dup2()
175 FD_CLR(newfd, files->close_on_exec); in sys_dup2()
176 write_unlock(&files->file_lock); in sys_dup2()
179 filp_close(tofree, files); in sys_dup2()
184 write_unlock(&files->file_lock); in sys_dup2()
188 write_unlock(&files->file_lock); in sys_dup2()