Lines Matching refs:fd
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()
192 return fd; in fd_slot_expand()
196 if (fd >= DFS_FD_MAX) in fd_slot_expand()
202 nr = ((fd + 4) & ~3); in fd_slot_expand()
227 return fd; in fd_slot_expand()
277 struct dfs_file *fd = NULL; in fd_alloc() local
286 fd = (struct dfs_file *)rt_calloc(1, sizeof(struct dfs_file)); in fd_alloc()
287 if (!fd) in fd_alloc()
291 fd->ref_count = 1; in fd_alloc()
292 fd->magic = DFS_FD_MAGIC; in fd_alloc()
293 fd->vnode = NULL; in fd_alloc()
294 fdt->fds[idx] = fd; in fd_alloc()
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()
367 struct dfs_file *fd_get(int fd) in fd_get() argument
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
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()
429 void fd_release(int fd) in fd_release() argument
434 fdt_fd_release(fdt, fd); in fd_release()
496 struct dfs_file *fd; in fd_is_open() local
523 fd = fdt->fds[index]; in fd_is_open()
524 if (fd == NULL || fd->vnode->fops == NULL || fd->vnode->path == NULL) continue; in fd_is_open()
526 if (fd->vnode->fs == fs && strcmp(fd->vnode->path, mountpath) == 0) in fd_is_open()
617 int fd = -1; in fd_get_fd_index_form_fdt() local
630 fd = index; in fd_get_fd_index_form_fdt()
637 return fd; in fd_get_fd_index_form_fdt()
667 int fd_associate(struct dfs_fdtable *fdt, int fd, struct dfs_file *file) in fd_associate() argument
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()
694 retfd = fd; in fd_associate()
704 void fd_init(struct dfs_file *fd) in fd_init() argument
706 if (fd) in fd_init()
708 fd->magic = DFS_FD_MAGIC; in fd_init()
709 fd->ref_count = 1; in fd_init()
710 fd->pos = 0; in fd_init()
711 fd->vnode = NULL; in fd_init()
712 fd->data = NULL; in fd_init()
945 struct dfs_file *fd = fd_table->fds[index]; in list_fd() local
947 if (fd && fd->vnode->fops) in list_fd()
950 if (fd->vnode->type == FT_DIRECTORY) rt_kprintf("%-7.7s ", "dir"); in list_fd()
951 else if (fd->vnode->type == FT_REGULAR) rt_kprintf("%-7.7s ", "file"); in list_fd()
952 else if (fd->vnode->type == FT_SOCKET) rt_kprintf("%-7.7s ", "socket"); in list_fd()
953 else if (fd->vnode->type == FT_USER) rt_kprintf("%-7.7s ", "user"); in list_fd()
954 else if (fd->vnode->type == FT_DEVICE) rt_kprintf("%-7.7s ", "device"); in list_fd()
956 rt_kprintf("%3d ", fd->vnode->ref_count); in list_fd()
957 rt_kprintf("%04x ", fd->magic); in list_fd()
958 if (fd->vnode->path) in list_fd()
960 rt_kprintf("%s\n", fd->vnode->path); in list_fd()
999 struct dfs_file *fd = fd_table->fds[index]; in lsofp() local
1001 if (fd && fd->vnode->fops) in lsofp()
1013 if (fd->vnode->type == FT_DIRECTORY) rt_kprintf("%-7.7s ", "dir"); in lsofp()
1014 else if (fd->vnode->type == FT_REGULAR) rt_kprintf("%-7.7s ", "file"); in lsofp()
1015 else if (fd->vnode->type == FT_SOCKET) rt_kprintf("%-7.7s ", "socket"); in lsofp()
1016 else if (fd->vnode->type == FT_USER) rt_kprintf("%-7.7s ", "user"); in lsofp()
1017 else if (fd->vnode->type == FT_DEVICE) rt_kprintf("%-7.7s ", "device"); in lsofp()
1019 rt_kprintf("%6d ", fd->vnode->ref_count); in lsofp()
1020 rt_kprintf("%04x 0x%.8x ", fd->magic, (int)(size_t)fd->vnode); in lsofp()
1022 if(fd->vnode == RT_NULL) in lsofp()
1024 rt_kprintf("0x%.8x 0x%.8x ", (int)0x00000000, (int)(size_t)fd); in lsofp()
1028 rt_kprintf("0x%.8x 0x%.8x ", (int)(size_t)(fd->vnode->data), (int)(size_t)fd); in lsofp()
1031 if (fd->vnode->path) in lsofp()
1033 rt_kprintf("%s \n", fd->vnode->path); in lsofp()