summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/finsh/msh.c11
-rw-r--r--include/rtthread.h2
-rw-r--r--src/module.c4
3 files changed, 11 insertions, 6 deletions
diff --git a/components/finsh/msh.c b/components/finsh/msh.c
index 1492e017e1..49a5d23591 100644
--- a/components/finsh/msh.c
+++ b/components/finsh/msh.c
@@ -180,7 +180,7 @@ static cmd_function_t msh_get_cmd(char *cmd, int size)
#if defined(RT_USING_MODULE) && defined(RT_USING_DFS)
/* Return 0 on module executed. Other value indicate error.
*/
-int msh_exec_module(char* cmd_line, int size)
+int msh_exec_module(const char* cmd_line, int size)
{
int ret;
int fd = -1;
@@ -248,6 +248,11 @@ int msh_exec_module(char* cmd_line, int size)
rt_free(pg_name);
return ret;
}
+
+int system(const char *command)
+{
+ return msh_exec_module(command, rt_strlen(command));
+}
#endif
static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp)
@@ -346,8 +351,8 @@ static int str_common(const char *str1, const char *str2)
#ifdef RT_USING_DFS
void msh_auto_complete_path(char *path)
{
- DIR* dir;
- struct dirent *dirent;
+ DIR* dir = RT_NULL;
+ struct dirent *dirent = RT_NULL;
char *full_path, *ptr, *index;
full_path = (char*)rt_malloc(256);
diff --git a/include/rtthread.h b/include/rtthread.h
index abe3a614ed..edd207bcb7 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -421,7 +421,7 @@ rt_module_t rt_module_load(const char *name, void *module_ptr);
rt_err_t rt_module_unload(rt_module_t module);
#ifdef RT_USING_DFS
rt_module_t rt_module_open(const char *filename);
-rt_module_t rt_module_exec_cmd(const char *path, char* cmd_line, int size);
+rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int size);
#endif
void *rt_module_malloc(rt_size_t size);
void *rt_module_realloc(void *ptr, rt_size_t size);
diff --git a/src/module.c b/src/module.c
index 428d42e961..0603159b91 100644
--- a/src/module.c
+++ b/src/module.c
@@ -920,7 +920,7 @@ static void module_main_entry(void* parameter)
*
* @return the module object
*/
-rt_module_t rt_module_do_main(const char *name, void *module_ptr, char* cmd_line, int line_size)
+rt_module_t rt_module_do_main(const char *name, void *module_ptr, const char* cmd_line, int line_size)
{
rt_module_t module;
@@ -1125,7 +1125,7 @@ rt_module_t rt_module_open(const char *path)
*
* @return the module object
*/
-rt_module_t rt_module_exec_cmd(const char *path, char* cmd_line, int size)
+rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int size)
{
struct stat s;
int fd, length;