From 409e7fca0ace203793a52b936b64553e2026303b Mon Sep 17 00:00:00 2001 From: heyuanjie Date: Mon, 2 Jul 2018 13:47:47 +0800 Subject: [PATCH] =?UTF-8?q?[msh]=E6=89=A7=E8=A1=8C=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/finsh/msh.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/components/finsh/msh.c b/components/finsh/msh.c index e13f8598fd..9b07883a41 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -313,6 +313,44 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp) 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 cmd_ret; @@ -356,6 +394,13 @@ int msh_exec(char *cmd, rt_size_t length) } #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. */ { char *tcmd;