| 1044 | } |
| 1045 | |
| 1046 | int lsof(int argc, char *argv[]) |
| 1047 | { |
| 1048 | rt_kprintf("PID fd type fd-ref magic vnode vnode/data addr path \n"); |
| 1049 | |
| 1050 | if (argc == 1) |
| 1051 | { |
| 1052 | struct rt_list_node *node, *list; |
| 1053 | struct lwp_avl_struct *pids = lwp_get_pid_ary(); |
| 1054 | |
| 1055 | lsofp(-1); |
| 1056 | |
| 1057 | for (int index = 0; index < RT_LWP_MAX_NR; index++) |
| 1058 | { |
| 1059 | struct rt_lwp *lwp = (struct rt_lwp *)pids[index].data; |
| 1060 | |
| 1061 | if (lwp) |
| 1062 | { |
| 1063 | list = &lwp->t_grp; |
| 1064 | for (node = list->next; node != list; node = node->next) |
| 1065 | { |
| 1066 | lsofp(lwp_to_pid(lwp)); |
| 1067 | } |
| 1068 | } |
| 1069 | } |
| 1070 | } |
| 1071 | else if (argc == 3) |
| 1072 | { |
| 1073 | if (argv[1][0] == '-' && argv[1][1] == 'p') |
| 1074 | { |
| 1075 | int pid = atoi(argv[2]); |
| 1076 | lsofp(pid); |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | return 0; |
| 1081 | } |
| 1082 | MSH_CMD_EXPORT(lsof, list open files); |
| 1083 | #endif /* RT_USING_SMART */ |
| 1084 |
nothing calls this directly
no test coverage detected