mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-30 23:20:22 +08:00
commit
eb821ae031
@ -313,6 +313,44 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(RT_USING_LWP) && defined(RT_USING_DFS)
|
||||||
|
static int _msh_exec_lwp(char *cmd, rt_size_t length)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
int cmd0_size = 0;
|
||||||
|
char *argv[FINSH_ARG_MAX];
|
||||||
|
int fd = -1;
|
||||||
|
char *pg_name;
|
||||||
|
|
||||||
|
extern int exec(char*, int, char**);
|
||||||
|
|
||||||
|
/* find the size of first command */
|
||||||
|
while ((cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t') && cmd0_size < length)
|
||||||
|
cmd0_size ++;
|
||||||
|
if (cmd0_size == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* split arguments */
|
||||||
|
rt_memset(argv, 0x00, sizeof(argv));
|
||||||
|
argc = msh_split(cmd, length, argv);
|
||||||
|
if (argc == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
pg_name = argv[0];
|
||||||
|
/* try to open program */
|
||||||
|
fd = open(pg_name, O_RDONLY, 0);
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* found program */
|
||||||
|
close(fd);
|
||||||
|
exec(pg_name, argc, argv);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int msh_exec(char *cmd, rt_size_t length)
|
int msh_exec(char *cmd, rt_size_t length)
|
||||||
{
|
{
|
||||||
int cmd_ret;
|
int cmd_ret;
|
||||||
@ -356,6 +394,13 @@ int msh_exec(char *cmd, rt_size_t length)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(RT_USING_LWP) && defined(RT_USING_DFS)
|
||||||
|
if (_msh_exec_lwp(cmd, length) == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* truncate the cmd at the first space. */
|
/* truncate the cmd at the first space. */
|
||||||
{
|
{
|
||||||
char *tcmd;
|
char *tcmd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user