Lines Matching refs:fdt

38 static int  fd_alloc(struct dfs_fdtable *fdt, int startfd);
183 static int fd_slot_expand(struct dfs_fdtable *fdt, int fd) in fd_slot_expand() argument
190 if (fd < fdt->maxfd) in fd_slot_expand()
211 fds = (struct dfs_file **)rt_realloc(fdt->fds, nr * sizeof(struct dfs_file *)); in fd_slot_expand()
218 for (index = fdt->maxfd; index < nr; index++) in fd_slot_expand()
224 fdt->fds = fds; in fd_slot_expand()
225 fdt->maxfd = nr; in fd_slot_expand()
239 static int fd_slot_alloc(struct dfs_fdtable *fdt, int startfd) in fd_slot_alloc() argument
244 for (idx = startfd; idx < (int)fdt->maxfd; idx++) in fd_slot_alloc()
246 if (fdt->fds[idx] == RT_NULL) in fd_slot_alloc()
252 idx = fdt->maxfd; in fd_slot_alloc()
257 if (fd_slot_expand(fdt, idx) < 0) in fd_slot_alloc()
274 static int fd_alloc(struct dfs_fdtable *fdt, int startfd) in fd_alloc() argument
279 idx = fd_slot_alloc(fdt, startfd); in fd_alloc()
294 fdt->fds[idx] = fd; in fd_alloc()
305 int fdt_fd_new(struct dfs_fdtable *fdt) in fdt_fd_new() argument
313 idx = fd_alloc(fdt, DFS_STDIO_OFFSET); in fdt_fd_new()
327 struct dfs_fdtable *fdt = NULL; in fd_new() local
329 fdt = dfs_fdtable_get(); in fd_new()
330 return fdt_fd_new(fdt); in fd_new()
343 struct dfs_file *fdt_fd_get(struct dfs_fdtable* fdt, int fd) in fdt_fd_get() argument
347 if (fd < 0 || fd >= (int)fdt->maxfd) in fdt_fd_get()
353 d = fdt->fds[fd]; in fdt_fd_get()
369 struct dfs_fdtable *fdt; in fd_get() local
371 fdt = dfs_fdtable_get(); in fd_get()
372 return fdt_fd_get(fdt, fd); in fd_get()
384 void fdt_fd_release(struct dfs_fdtable* fdt, int fd) in fdt_fd_release() argument
388 RT_ASSERT(fdt != NULL); in fdt_fd_release()
392 if ((fd < 0) || (fd >= fdt->maxfd)) in fdt_fd_release()
398 fd_slot = fdt->fds[fd]; in fdt_fd_release()
404 fdt->fds[fd] = NULL; in fdt_fd_release()
431 struct dfs_fdtable *fdt; in fd_release() local
433 fdt = dfs_fdtable_get(); in fd_release()
434 fdt_fd_release(fdt, fd); in fd_release()
454 struct dfs_fdtable *fdt = NULL; in sys_dup() local
458 fdt = dfs_fdtable_get(); in sys_dup()
459 if ((oldfd < 0) || (oldfd >= fdt->maxfd)) in sys_dup()
463 if (!fdt->fds[oldfd]) in sys_dup()
468 newfd = fd_slot_alloc(fdt, DFS_STDIO_OFFSET); in sys_dup()
471 fdt->fds[newfd] = fdt->fds[oldfd]; in sys_dup()
473 fdt->fds[newfd]->ref_count++; in sys_dup()
497 struct dfs_fdtable *fdt; in fd_is_open() local
499 fdt = dfs_fdtable_get(); in fd_is_open()
521 for (index = 0; index < fdt->maxfd; index++) in fd_is_open()
523 fd = fdt->fds[index]; in fd_is_open()
562 struct dfs_fdtable *fdt = NULL; in sys_dup2() local
568 fdt = dfs_fdtable_get(); in sys_dup2()
569 if ((oldfd < 0) || (oldfd >= fdt->maxfd)) in sys_dup2()
573 if (!fdt->fds[oldfd]) in sys_dup2()
581 if (newfd >= fdt->maxfd) in sys_dup2()
583 newfd = fd_slot_expand(fdt, newfd); in sys_dup2()
589 if (fdt->fds[newfd] == fdt->fds[oldfd]) in sys_dup2()
596 if (fdt->fds[newfd]) in sys_dup2()
598 ret = dfs_file_close(fdt->fds[newfd]); in sys_dup2()
606 fdt->fds[newfd] = fdt->fds[oldfd]; in sys_dup2()
608 fdt->fds[newfd]->ref_count++; in sys_dup2()
615 static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_file *file) in fd_get_fd_index_form_fdt() argument
626 for(int index = 0; index < (int)fdt->maxfd; index++) in fd_get_fd_index_form_fdt()
628 if(fdt->fds[index] == file) in fd_get_fd_index_form_fdt()
646 struct dfs_fdtable *fdt; in fd_get_fd_index() local
648 fdt = dfs_fdtable_get(); in fd_get_fd_index()
649 return fd_get_fd_index_form_fdt(fdt, file); in fd_get_fd_index()
667 int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_file *file) in fd_associate() argument
675 if (!fdt) in fd_associate()
682 if ((fd < 0) || (fd >= fdt->maxfd)) in fd_associate()
687 if (fdt->fds[fd]) in fd_associate()
693 fdt->fds[fd] = file; in fd_associate()
891 struct dfs_fdtable *fdt; in dfs_fdtable_get() local
897 fdt = &lwp->fdt; in dfs_fdtable_get()
899 fdt = &_fdtab; in dfs_fdtable_get()
901 fdt = &_fdtab; in dfs_fdtable_get()
904 return fdt; in dfs_fdtable_get()
911 struct dfs_fdtable *fdt = RT_NULL; in dfs_fdtable_get_pid() local
917 fdt = &lwp->fdt; in dfs_fdtable_get_pid()
921 return fdt; in dfs_fdtable_get_pid()