| 972 | |
| 973 | #ifdef RT_USING_SMART |
| 974 | static int lsofp(int pid) |
| 975 | { |
| 976 | int index; |
| 977 | struct dfs_fdtable *fd_table = RT_NULL; |
| 978 | |
| 979 | if (pid == (-1)) |
| 980 | { |
| 981 | fd_table = dfs_fdtable_get(); |
| 982 | if (!fd_table) return -1; |
| 983 | } |
| 984 | else |
| 985 | { |
| 986 | fd_table = dfs_fdtable_get_pid(pid); |
| 987 | if (!fd_table) |
| 988 | { |
| 989 | rt_kprintf("PID %s is not a applet(lwp)\n", pid); |
| 990 | return -1; |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | rt_kprintf("--- -- ------ ------ ----- ---------- ---------- ---------- ------\n"); |
| 995 | |
| 996 | rt_enter_critical(); |
| 997 | for (index = 0; index < (int)fd_table->maxfd; index++) |
| 998 | { |
| 999 | struct dfs_file *fd = fd_table->fds[index]; |
| 1000 | |
| 1001 | if (fd && fd->vnode->fops) |
| 1002 | { |
| 1003 | if(pid == (-1)) |
| 1004 | { |
| 1005 | rt_kprintf(" K "); |
| 1006 | } |
| 1007 | else |
| 1008 | { |
| 1009 | rt_kprintf("%3d ", pid); |
| 1010 | } |
| 1011 | |
| 1012 | rt_kprintf("%2d ", index); |
| 1013 | if (fd->vnode->type == FT_DIRECTORY) rt_kprintf("%-7.7s ", "dir"); |
| 1014 | else if (fd->vnode->type == FT_REGULAR) rt_kprintf("%-7.7s ", "file"); |
| 1015 | else if (fd->vnode->type == FT_SOCKET) rt_kprintf("%-7.7s ", "socket"); |
| 1016 | else if (fd->vnode->type == FT_USER) rt_kprintf("%-7.7s ", "user"); |
| 1017 | else if (fd->vnode->type == FT_DEVICE) rt_kprintf("%-7.7s ", "device"); |
| 1018 | else rt_kprintf("%-8.8s ", "unknown"); |
| 1019 | rt_kprintf("%6d ", fd->vnode->ref_count); |
| 1020 | rt_kprintf("%04x 0x%.8x ", fd->magic, (int)(size_t)fd->vnode); |
| 1021 | |
| 1022 | if(fd->vnode == RT_NULL) |
| 1023 | { |
| 1024 | rt_kprintf("0x%.8x 0x%.8x ", (int)0x00000000, (int)(size_t)fd); |
| 1025 | } |
| 1026 | else |
| 1027 | { |
| 1028 | rt_kprintf("0x%.8x 0x%.8x ", (int)(size_t)(fd->vnode->data), (int)(size_t)fd); |
| 1029 | } |
| 1030 | |
| 1031 | if (fd->vnode->path) |
no test coverage detected