|
|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright (c) 2006-2018, RT-Thread Development Team
|
|
|
+ * Copyright (c) 2006-2021, RT-Thread Development Team
|
|
|
*
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
*
|
|
|
@@ -14,6 +14,7 @@
|
|
|
#include <dfs_fs.h>
|
|
|
#include <dfs_file.h>
|
|
|
#include "dfs_private.h"
|
|
|
+
|
|
|
#ifdef RT_USING_LWP
|
|
|
#include <lwp.h>
|
|
|
#endif
|
|
|
@@ -447,7 +448,7 @@ static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file
|
|
|
{
|
|
|
int fd = -1;
|
|
|
|
|
|
- if (file == RT_NULL)
|
|
|
+ if (file == RT_NULL)
|
|
|
{
|
|
|
return -1;
|
|
|
}
|
|
|
@@ -458,8 +459,8 @@ static int fd_get_fd_index_form_fdt(struct dfs_fdtable *fdt, struct dfs_fd *file
|
|
|
{
|
|
|
if(fdt->fds[index] == file)
|
|
|
{
|
|
|
- fd = index;
|
|
|
- break;
|
|
|
+ fd = index;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -565,7 +566,9 @@ char *dfs_normalize_path(const char *directory, const char *filename)
|
|
|
|
|
|
#ifdef DFS_USING_WORKDIR
|
|
|
if (directory == NULL) /* shall use working directory */
|
|
|
- directory = &working_directory[0];
|
|
|
+ {
|
|
|
+ directory = lwp_getcwd();
|
|
|
+ }
|
|
|
#else
|
|
|
if ((directory == NULL) && (filename[0] != '/'))
|
|
|
{
|
|
|
@@ -707,7 +710,7 @@ struct dfs_fdtable *dfs_fdtable_get_pid(int pid)
|
|
|
struct rt_lwp *lwp = RT_NULL;
|
|
|
struct dfs_fdtable *fdt = RT_NULL;
|
|
|
|
|
|
- lwp = lwp_from_pid(pid);
|
|
|
+ lwp = lwp_from_pid(pid);
|
|
|
if (lwp)
|
|
|
{
|
|
|
fdt = &lwp->fdt;
|
|
|
@@ -715,7 +718,7 @@ struct dfs_fdtable *dfs_fdtable_get_pid(int pid)
|
|
|
|
|
|
return fdt;
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
struct dfs_fdtable *dfs_fdtable_get_global(void)
|
|
|
{
|
|
|
@@ -781,7 +784,7 @@ static int lsofp(int pid)
|
|
|
else
|
|
|
{
|
|
|
fd_table = dfs_fdtable_get_pid(pid);
|
|
|
- if (!fd_table)
|
|
|
+ if (!fd_table)
|
|
|
{
|
|
|
rt_kprintf("PID %s is not a applet(lwp)\n", pid);
|
|
|
return -1;
|
|
|
@@ -849,7 +852,7 @@ int lsof(int argc, char *argv[])
|
|
|
struct rt_list_node *node, *list;
|
|
|
struct lwp_avl_struct *pids = lwp_get_pid_ary();
|
|
|
|
|
|
- lsofp(-1);
|
|
|
+ lsofp(-1);
|
|
|
|
|
|
for (int index = 0; index < RT_LWP_MAX_NR; index++)
|
|
|
{
|
|
|
@@ -860,7 +863,7 @@ int lsof(int argc, char *argv[])
|
|
|
list = &lwp->t_grp;
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
{
|
|
|
- lsofp(lwp_to_pid(lwp));
|
|
|
+ lsofp(lwp_to_pid(lwp));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -870,14 +873,14 @@ int lsof(int argc, char *argv[])
|
|
|
if (argv[1][0] == '-' && argv[1][1] == 'p')
|
|
|
{
|
|
|
int pid = atoi(argv[2]);
|
|
|
- lsofp(pid);
|
|
|
+ lsofp(pid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
-MSH_CMD_EXPORT(lsof, list open files);
|
|
|
-#endif /* RT_USING_LWP */
|
|
|
+MSH_CMD_EXPORT(lsof, list open files);
|
|
|
+#endif /* RT_USING_LWP */
|
|
|
|
|
|
/*
|
|
|
* If no argument is specified, display the mount history;
|