diff --git a/mbtk/libgsw_lib/gsw_sys_interface.c b/mbtk/libgsw_lib/gsw_sys_interface.c
index 27050c6..21656e3 100755
--- a/mbtk/libgsw_lib/gsw_sys_interface.c
+++ b/mbtk/libgsw_lib/gsw_sys_interface.c
@@ -1,129 +1,265 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
 #include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <dlfcn.h>
 #include "gsw_sys_interface.h"
-
 #define  LOG_LEVLE_CONFIG_FILE "/etc/telinit"
-
+#define  SSH_STATE_FILE "/tmp/ssh_mode"
+#define  FTP_STATE_FILE "/tmp/ftp_mode"
+#define  LIB_PATH		"/lib/libmbtk_lib.so"
+typedef void (*mbtk_log)(int level, const char *format,...);
+#ifndef LOG_ERR_LEVEL
+#define LOG_ERR_LEVEL  3      /* error conditions */
+#endif
+#define LOGE(fun_ptr_log, fmt, args...) \
+    do{ \
+        char *file_ptr_1001 = __FILE__; \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \
+        char line_1001[10] = {0}; \
+        sprintf(line_1001, "%d", __LINE__); \
+        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
+            if(*ptr_1001 == '/') \
+                 break; \
+            ptr_1001--; \
+        } \
+        fun_ptr_log(LOG_ERR_LEVEL,  "%s#%s: [gsw_sys]" fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while(0)
+void write_mode_to_file(const char *file ,const char *mode)
+{
+	FILE *fp = fopen(file, "w");
+	if (!fp)
+	{
+		perror("Failed to open state file for writing");
+		return;
+	}
+	fprintf(fp, "%s\n", mode);
+	fclose(fp);
+}
+int read_mode_from_file(const char *file, char *mode, size_t size)
+{
+	FILE *fp = fopen(file, "r");
+	if (!fp)
+	{
+		return GSW_HAL_NORMAL_FAIL;  // No mode recorded
+	}
+	if (!fgets(mode, size, fp))
+	{
+		fclose(fp);		
+		return GSW_HAL_NORMAL_FAIL;
+	}
+	mode[strcspn(mode, "\n")] = '\0';
+	fclose(fp);
+	return GSW_HAL_SUCCESS;
+}
 int gsw_sys_svr_ftp_start(const char *cfg)
 {
 	int ret = GSW_HAL_SUCCESS;
-	char command[128] = "vsftpd &";
+	char command[128];
+	mbtk_log fun_ptr_log;
+	void *handle = dlopen(LIB_PATH, RTLD_NOW);
+	if(NULL == handle)
+		return GSW_HAL_NORMAL_FAIL;
+	
+	fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
+	if(fun_ptr_log ==  NULL)
+	{
+		ret = GSW_HAL_NORMAL_FAIL;
+		goto exit;
+	}
+	
 	if(NULL == cfg)
 	{
-		ret = system(command);
+		write_mode_to_file(FTP_STATE_FILE, "init.d");
+		strcpy(command, "/etc/init.d/vsftpd start");
 	}
 	else
 	{
-		sprintf(command, "vsftpd %s &", cfg);
-		ret = system(command);
+		write_mode_to_file(FTP_STATE_FILE, "vsftpd");
+		snprintf(command, sizeof(command), "vsftpd %s &", cfg);
 	}
-	
+	ret = system(command);
 	if(ret != 0) {
-		printf("command execution failed command:%s.\n", command);
-		return GSW_HAL_NORMAL_FAIL;
+		LOGE(fun_ptr_log, "command execution failed command:%s.\n", command);
+		goto exit;
 	}
-	
-	return GSW_HAL_SUCCESS;
+exit:
+	dlclose(handle);
+	handle = NULL;
+	return ret;
 }
-
 int gsw_sys_svr_ftp_stop()
 {
 	int ret = GSW_HAL_SUCCESS;
-	char command[] = "killall -TERM vsftpd";
+	char command[64];
+	char mode[64];
+	mbtk_log fun_ptr_log;
+	void *handle = dlopen(LIB_PATH, RTLD_NOW);
+	if(NULL == handle)
+		return GSW_HAL_NORMAL_FAIL;
+	
+	fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
+	if(fun_ptr_log ==  NULL)
+	{
+		ret = GSW_HAL_NORMAL_FAIL;
+		goto exit;
+	}
+	
+	ret = read_mode_from_file(FTP_STATE_FILE, mode, sizeof(mode));
+	if(0 != ret)
+	{
+		LOGE(fun_ptr_log, "read file:%s error\n", FTP_STATE_FILE);
+		goto exit;
+	}
+	if(strlen(mode) == 0 || strcmp("init.d", mode) == 0)    //strlen(mode)==0为第一次执行
+		strcpy(command, "/etc/init.d/vsftpd stop");
+	else
+		strcpy(command, "killall -TERM vsftpd");
 	
 	ret = system(command);
 	if(ret != 0) 
 	{
-		printf("command execution failed command:%s.\n", command);
-		return GSW_HAL_NORMAL_FAIL;
+		LOGE(fun_ptr_log, "command execution failed command:%s.\n", command);
+		goto exit;
 	}
 	
-	return GSW_HAL_SUCCESS;
-
+exit:
+	dlclose(handle);
+	handle = NULL;
+	return ret;
 }
-
 int gsw_sys_svr_ssh_start(const char *cfg)
 {
 	int ret= GSW_HAL_SUCCESS;
-	char command[128] = "/usr/sbin/sshd &";
+	char command[128];
+	mbtk_log fun_ptr_log;
+	void *handle = dlopen(LIB_PATH, RTLD_NOW);
+	if(NULL == handle)
+		return GSW_HAL_NORMAL_FAIL;
 	
+	fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
+	if(fun_ptr_log ==  NULL)
+	{
+		ret = GSW_HAL_NORMAL_FAIL;
+		goto exit;
+	}
+		
 	if(NULL == cfg)
-	{	
-		ret = system(command);
+	{			
+		write_mode_to_file(SSH_STATE_FILE, "init.d");
+		strcpy(command, "/etc/init.d/sshd start");
 	}
 	else
 	{
-		sprintf(command, "/usr/sbin/sshd %s &", cfg);
-		ret = system(command);
+		write_mode_to_file(SSH_STATE_FILE, "sshd");
+		snprintf(command, sizeof(command), "/usr/sbin/sshd -f %s &", cfg);
 	}
 	
+	ret = system(command);
 	if(ret != 0)
 	{
-		printf("command execution failed command:%s.\n", command);
-		return GSW_HAL_NORMAL_FAIL;
-	
+		LOGE(fun_ptr_log, "command execution failed command:%s.\n", command);
+		goto exit;
 	}
-	return GSW_HAL_SUCCESS;
+	
+exit:	
+	dlclose(handle);
+	handle = NULL;
+	return ret;
 }
-
 int gsw_sys_svr_ssh_stop()
 {
 	int ret = GSW_HAL_SUCCESS;
-	char command[] = "killall sshd";
+	char command[64];
+	char mode[64];
+	mbtk_log fun_ptr_log;
+	void *handle = dlopen(LIB_PATH, RTLD_NOW);
+	if(NULL == handle)
+		return GSW_HAL_NORMAL_FAIL;
 	
+	fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
+	if(fun_ptr_log ==  NULL)
+	{
+		ret = GSW_HAL_NORMAL_FAIL;
+		goto exit;
+	}
+	
+	ret = read_mode_from_file(SSH_STATE_FILE, mode, sizeof(mode));
+	if(0 != ret)
+	{
+		LOGE(fun_ptr_log, "read file:%s error\n", SSH_STATE_FILE);
+		goto exit;
+	}
+	if(strlen(mode) == 0 || strcmp("init.d", mode) == 0)    //strlen(mode)==0为第一次执行
+		strcpy(command, "/etc/init.d/sshd stop");
+	else
+		strcpy(command, "killall sshd");
 	ret = system(command);
 	if(ret != 0) 
 	{
-		printf("command execution failed command:%s.\n", command);
-		return GSW_HAL_NORMAL_FAIL;
+		LOGE(fun_ptr_log, "command execution failed command:%s.\n", command);
+		goto exit;
 	}
 	
-	return GSW_HAL_SUCCESS;
+exit:	
+	dlclose(handle);
+	handle = NULL;
+	return ret;
 }
-
 int gsw_sys_svr_syslog_restart(const char *log_lvl)
 {
 	(void)log_lvl;
+	int 	ret = GSW_HAL_SUCCESS;
 	char command[256] = {0};
 	int level = 0;
 	char *log_level_params[8] = {"emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"};
 	char *log_level_values[8] = {"1", "2", "3", "4", "5", "6", "7", "8"};
+	mbtk_log fun_ptr_log;
+	void *handle = dlopen(LIB_PATH, RTLD_NOW);
+	if(NULL == handle)
+		return GSW_HAL_NORMAL_FAIL;
 	
+	fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
+	if(fun_ptr_log ==  NULL)
+	{
+		ret = GSW_HAL_NORMAL_FAIL;
+		goto exit;
+	}
 	snprintf(command, sizeof(command), 
 			 "grep -q 'setprop sys.default.loglevel' %s", LOG_LEVLE_CONFIG_FILE);
-
 	for(level = 0; level < 8; level++)
 	{
 		if(0 == strcmp(log_lvl, log_level_params[level]))
 			break;
 	}
-
 	if(8 == level)
 	{
-		printf("Parameter error\n");
-		return -1;
+		LOGE(fun_ptr_log, "Parameter error\n");
+		ret = GSW_HAL_NORMAL_FAIL;
+	    goto exit;
 	}
 	
-	int exists = system(command);
-	if (exists != 0) {
-		printf("config option not exist.\n");
-		return GSW_HAL_NORMAL_FAIL;
+	ret = system(command);
+	if (ret != 0)
+	{
+		LOGE(fun_ptr_log, "config option not exist.\n");
+	    goto exit;
 	}
-
 	snprintf(command, sizeof(command), 
 	         "sed -i 's/\\(setprop sys.default.loglevel \\)\\S*/\\1%s/' %s",
 	         log_level_values[level], LOG_LEVLE_CONFIG_FILE);
 	
-	int result = system(command);
-	if (result != 0) {
-	    printf("command execution failed.\n");
-	    return GSW_HAL_SUCCESS;
+	ret = system(command);
+	if (ret != 0)
+	{
+	    LOGE(fun_ptr_log, "command execution failed.\n");
+	    goto exit;
 	}
-
-
-	return GSW_HAL_NORMAL_FAIL;
+exit:	
+	dlclose(handle);
+	handle = NULL;
+	return ret;
 }
+
