MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lsof

Function lsof

components/dfs/dfs_v1/src/dfs.c:1046–1081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044}
1045
1046int 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}
1082MSH_CMD_EXPORT(lsof, list open files);
1083#endif /* RT_USING_SMART */
1084

Callers

nothing calls this directly

Calls 4

rt_kprintfFunction · 0.85
lwp_get_pid_aryFunction · 0.85
lsofpFunction · 0.85
lwp_to_pidFunction · 0.85

Tested by

no test coverage detected