Browse Source

Merge remote-tracking branch 'origin/master' into stable-v1.2.x

bernard 11 years ago
parent
commit
b2f35dcf3f

+ 1 - 1
components/dfs/filesystems/nfs/rpc/pmap.c

@@ -24,7 +24,7 @@ unsigned short pmap_getport(struct sockaddr_in *address, unsigned long program,
 {
 {
 	unsigned short port = 0;
 	unsigned short port = 0;
 	int socket = -1;
 	int socket = -1;
-	register CLIENT *client;
+	register CLIENT *client = RT_NULL;
 	struct pmap parms;
 	struct pmap parms;
 
 
 	address->sin_port = htons((unsigned short)PMAPPORT);
 	address->sin_port = htons((unsigned short)PMAPPORT);

+ 8 - 3
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)
 #if defined(RT_USING_MODULE) && defined(RT_USING_DFS)
 /* Return 0 on module executed. Other value indicate error.
 /* 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 ret;
     int fd = -1;
     int fd = -1;
@@ -248,6 +248,11 @@ int msh_exec_module(char* cmd_line, int size)
     rt_free(pg_name);
     rt_free(pg_name);
     return ret;
     return ret;
 }
 }
+
+int system(const char *command)
+{
+    return msh_exec_module(command, rt_strlen(command));
+}
 #endif
 #endif
 
 
 static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp)
 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
 #ifdef RT_USING_DFS
 void msh_auto_complete_path(char *path)
 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;
     char *full_path, *ptr, *index;
 
 
     full_path = (char*)rt_malloc(256);
     full_path = (char*)rt_malloc(256);

+ 5 - 1
components/finsh/shell.c

@@ -54,8 +54,10 @@ ALIGN(RT_ALIGN_SIZE)
 static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE];
 static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE];
 struct finsh_shell* shell;
 struct finsh_shell* shell;
 
 
-#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
+#if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
+#if defined(RT_USING_DFS)
 #include <dfs_posix.h>
 #include <dfs_posix.h>
+#endif
 const char* finsh_get_prompt()
 const char* finsh_get_prompt()
 {
 {
     #define _MSH_PROMPT "msh "
     #define _MSH_PROMPT "msh "
@@ -68,8 +70,10 @@ const char* finsh_get_prompt()
 #endif
 #endif
     strcpy(finsh_prompt, _PROMPT);
     strcpy(finsh_prompt, _PROMPT);
 
 
+#ifdef DFS_USING_WORKDIR
     /* get current working directory */
     /* get current working directory */
     getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
     getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
+#endif
     strcat(finsh_prompt, ">");
     strcat(finsh_prompt, ">");
 
 
     return finsh_prompt;
     return finsh_prompt;

+ 1 - 1
components/finsh/shell.h

@@ -43,7 +43,7 @@
 #define FINSH_CMD_SIZE		80
 #define FINSH_CMD_SIZE		80
 
 
 #define FINSH_OPTION_ECHO	0x01
 #define FINSH_OPTION_ECHO	0x01
-#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
+#if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
 #define FINSH_PROMPT		finsh_get_prompt()
 #define FINSH_PROMPT		finsh_get_prompt()
 const char* finsh_get_prompt(void);
 const char* finsh_get_prompt(void);
 #else
 #else

+ 1 - 1
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);
 rt_err_t rt_module_unload(rt_module_t module);
 #ifdef RT_USING_DFS
 #ifdef RT_USING_DFS
 rt_module_t rt_module_open(const char *filename);
 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
 #endif
 void *rt_module_malloc(rt_size_t size);
 void *rt_module_malloc(rt_size_t size);
 void *rt_module_realloc(void *ptr, rt_size_t size);
 void *rt_module_realloc(void *ptr, rt_size_t size);

+ 2 - 2
src/module.c

@@ -920,7 +920,7 @@ static void module_main_entry(void* parameter)
  *
  *
  * @return the module object
  * @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;
 	rt_module_t module;
 
 
@@ -1125,7 +1125,7 @@ rt_module_t rt_module_open(const char *path)
  *
  *
  * @return the module object
  * @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;
     struct stat s;
     int fd, length;
     int fd, length;