Revert "Changed logging to dlog" 81/186381/1 accepted/tizen/unified/20180810.062854 submit/tizen/20180809.080636
authormanish.r <manish.r@samsung.com>
Thu, 9 Aug 2018 08:00:35 +0000 (13:30 +0530)
committermanish.r <manish.r@samsung.com>
Thu, 9 Aug 2018 08:01:54 +0000 (13:31 +0530)
This reverts commit 565b3ef468abbfb58da4a0230eda02c02664b29a.

Change-Id: Iec6ee35b0f3d181cd875406e509b2d506903b011
Signed-off-by: manish.r <manish.r@samsung.com>
18 files changed:
src/default_plugin_appcmd.c
src/default_plugin_auth.c
src/default_plugin_basic.c
src/descs_strings.h
src/file_sync_service.c
src/log.h
src/plugin.c
src/plugin_encrypt.c
src/sdb.c
src/sdktools.c
src/services.c
src/sockets.c
src/transport.c
src/transport_local.c
src/transport_usb.c
src/usb_funcfs_client.c
src/usb_linux.c
src/usb_linux_client.c

index 1c7204d..5e8629a 100755 (executable)
@@ -20,8 +20,7 @@
 #include <string.h>
 #include <errno.h>
 
-//#define TRACE_TAG  TRACE_APPCMD
-#define LOG_TAG "SDBD_TRACE_APPCMD"
+#define TRACE_TAG  TRACE_APPCMD
 
 #include "sysdeps.h"
 #include "sdb.h"
@@ -69,7 +68,7 @@ static int appcmd_install_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 5) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -122,7 +121,7 @@ static int appcmd_uninstall_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -146,7 +145,7 @@ static int appcmd_runapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -181,7 +180,7 @@ static int appcmd_rununittestapp_gen_shellcmd(appcmd_info* p_info) {
     p_service = strtok_r(p_info->raw_command, ":", &ptr);
     p_appid = strtok_r(NULL, ":", &ptr);
     if (p_service == NULL || p_appid == NULL) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -218,7 +217,7 @@ static int appcmd_killapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -242,7 +241,7 @@ static int appcmd_packagelist_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -266,7 +265,7 @@ static int appcmd_debugwebapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -294,7 +293,7 @@ static int appcmd_debugnativeapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 5) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -342,7 +341,7 @@ static int appcmd_appinfo_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -573,7 +572,7 @@ static int exec_appcmd_shell_process(appcmd_info* p_info) {
 
     ptm_fd = create_subprocess(SHELL_COMMAND, &pid, (char * const*)args, (char * const*)envp);
     if (ptm_fd < 0) {
-        E("cannot create service thread\n");
+        D("cannot create service thread\n");
         return -1;
     }
     D("create_subprocess() ptm_fd=%d pid=%d\n", ptm_fd, pid);
@@ -614,37 +613,37 @@ static int get_pkg_info(char* pkgid, char* pkginfo_buf, int buf_size) {
 
     ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
     if (ret < 0) {
-        E("failed to get pkginfo handle.\n");
+        D("failed to get pkginfo handle.\n");
         return -1;
     }
 
     ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &pkgname);
     if (ret < 0) {
-        E("failed to get pkg name\n");
+        D("failed to get pkg name\n");
         return -1;
     }
 
     ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
     if (ret < 0) {
-        E("failed to get pkg type.\n");
+        D("failed to get pkg type.\n");
         return -1;
     }
 
     ret = pkgmgrinfo_pkginfo_is_removable(handle, &is_removable);
     if (ret < 0) {
-        E("failed to get removable info.\n");
+        D("failed to get removable info.\n");
         return -1;
     }
 
     pc = pkgmgr_client_new(PC_REQUEST);
     if (pc == NULL) {
-        E("failed to create pkgmgr client.\n");
+        D("failed to create pkgmgr client.\n");
         return -1;
     }
 
     ret = pkgmgr_client_request_service(PM_REQUEST_CHECK_APP, 0, pc, NULL, pkgid, NULL, NULL, &pid);
     if (ret < 0) {
-        E("failed to get running state.\n");
+        D("failed to get running state.\n");
         return -1;
     }
     is_running = ((pid > 0) ? 1:0);
@@ -663,7 +662,7 @@ static void run_appcmd_packageinfo(appcmd_info* p_info) {
     p_info->exitcode = -1;
 
     if (p_info->args_cnt != 3) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return;
     }
 
@@ -679,7 +678,7 @@ static void run_appcmd_packageinfo(appcmd_info* p_info) {
                        snprintf(result_buf, sizeof(result_buf), "\n%s:%s\n", MESSAGE_PREFIX_APPCMD_RETURN, pkginfo_buf);
                        writex(p_info->fd, result_buf, strlen(result_buf));
                } else {
-                       E("failed to get pkginfo.\n");
+                       D("failed to get pkginfo.\n");
                }
 
                free(type);
@@ -699,7 +698,7 @@ static int appcmd_packageinfo_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -770,7 +769,7 @@ static void run_appcmd_appinstallpath(appcmd_info* p_info) {
         snprintf(result_buf, sizeof(result_buf), "\n%s:%s\n", MESSAGE_PREFIX_APPCMD_RETURN, path);
         writex(p_info->fd, result_buf, strlen(result_buf));
     } else {
-        E("failed to get application install path from tzplatform_getenv.");
+        D("failed to get application install path from tzplatform_getenv.");
     }
 }
 
@@ -778,25 +777,25 @@ static void run_appcmd_with_shell_process(appcmd_info* p_info) {
     int ret = -1;
 
     if (p_info == NULL) {
-        E("Invalid arguments. p_info is null\n");
+        D("Invalid arguments. p_info is null\n");
         return;
     }
 
     if (p_info->gen_cmd_func == NULL) {
-        E("Invalid arguments.\n");
+        D("Invalid arguments.\n");
         p_info->exitcode = -1;
         return;
     }
 
     ret = p_info->gen_cmd_func(p_info);
     if (ret < 0) {
-        E("failed to generate install shell command.\n");
+        D("failed to generate install shell command.\n");
         p_info->exitcode = -1;
     } else {
         ret = exec_appcmd_shell_process(p_info);
         D("exec_appcmd_shell_process: ret=%d, exitcode=%d\n", ret, p_info->exitcode);
         if (ret < 0) {
-            E("failed to run shell process\n");
+            D("failed to run shell process\n");
             p_info->exitcode = -1;
         }
     }
@@ -824,7 +823,7 @@ int appcmd_service( parameters* in, int out_fd ) {
     info.args_cnt = tokenize(command, ":", info.args, MAX_TOKENS);
     D("args_cnt=%zu\n", info.args_cnt);
     if (info.args_cnt < 1) {
-        E("failed to parse appcmd for install. (%s)\n", command);
+        D("failed to parse appcmd for install. (%s)\n", command);
         info.exitcode = -1;
         goto appcmd_done;
     }
@@ -886,7 +885,7 @@ int appcmd_service( parameters* in, int out_fd ) {
         info.gen_cmd_func = appcmd_debugnativeapp_gen_shellcmd;
         run_appcmd_with_shell_process(&info);
     } else {
-        E("not supported appcmd service. (%s)\n", service_name);
+        D("not supported appcmd service. (%s)\n", service_name);
         info.exitcode = -1;
         goto appcmd_done;
     }
index 0a9ecd0..5021827 100644 (file)
@@ -16,8 +16,7 @@
 
 #include <stdlib.h>
 
-//#define TRACE_TAG TRACE_SDB
-#define LOG_TAG "SDBD_TRACE_SDB"
+#define TRACE_TAG TRACE_SDB
 #include "log.h"
 
 #include "parameter.h"
 int auth_support ( parameters* in, parameters* out )
 {
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
index 80f82c2..8a180a1 100644 (file)
@@ -22,8 +22,7 @@
 
 #include <tzplatform_config.h>
 
-//#define TRACE_TAG TRACE_SDB
-#define LOG_TAG "SDBD_TRACE_SDB"
+#define TRACE_TAG TRACE_SDB
 #include "log.h"
 
 #include "sdb.h"
@@ -39,19 +38,19 @@ int get_plugin_capability ( parameters* in, parameters* out )
 
     if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
             || in->array_of_parameter[0].type != type_int32 ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
 
@@ -106,12 +105,12 @@ int verify_shell_cmd ( parameters* in, parameters* out )
 {
     if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
             || in->array_of_parameter[0].type != type_string ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -120,7 +119,7 @@ int verify_shell_cmd ( parameters* in, parameters* out )
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -133,12 +132,12 @@ int convert_shell_cmd ( parameters* in, parameters* out )
 {
     if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
             || in->array_of_parameter[0].type != type_string ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -147,7 +146,7 @@ int convert_shell_cmd ( parameters* in, parameters* out )
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
 
@@ -159,12 +158,12 @@ int verify_peer_ip ( parameters* in, parameters* out )
 {
     if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
             || in->array_of_parameter[0].type != type_string ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -173,7 +172,7 @@ int verify_peer_ip ( parameters* in, parameters* out )
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -212,14 +211,14 @@ int verify_peer_ipv6 ( parameters* in, parameters* out )
 int verify_sdbd_launch ( parameters* in, parameters* out )
 {
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -232,12 +231,12 @@ int verify_root_cmd ( parameters* in, parameters* out )
 {
     if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
             || in->array_of_parameter[0].type != type_string ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -246,7 +245,7 @@ int verify_root_cmd ( parameters* in, parameters* out )
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -263,14 +262,14 @@ int verify_root_cmd ( parameters* in, parameters* out )
 int get_shell_env ( parameters* in, parameters* out )
 {
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
 
@@ -282,19 +281,19 @@ int verify_push ( parameters* in, parameters* out )
 {
     if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
             || in->array_of_parameter[0].type != type_string ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        E ( "Invalid argument\n" );
+        D ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     out->number_of_parameter = 1;
     out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (out->array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
index d36b33a..26c5ac4 100644 (file)
@@ -1,8 +1,7 @@
 #include <linux/usb/ch9.h>
 #include <linux/usb/functionfs.h>
 
-//#define   TRACE_TAG  TRACE_USB
-#define LOG_TAG "SDBD_TRACE_USB"
+#define   TRACE_TAG  TRACE_USB
 
 #define MAX_PACKET_SIZE_FS     64
 #define MAX_PACKET_SIZE_HS     512
index fc9056e..ec03f03 100644 (file)
@@ -30,8 +30,7 @@
 #include <sys/smack.h>
 #include <tzplatform_config.h>
 
-//#define TRACE_TAG  TRACE_SYNC
-#define LOG_TAG "SDBD_TRACE_SYNC"
+#define TRACE_TAG  TRACE_SYNC
 #include "log.h"
 
 #include "sdb.h"
@@ -155,7 +154,7 @@ static int mkdirs(int noti_fd, char *name)
             sync_send_label_notify(noti_fd, name, 1);
         }
         if((ret < 0) && (errno != EEXIST)) {
-            E("mkdir(\"%s\") -> errno:%d\n", name, errno);
+            D("mkdir(\"%s\") -> errno:%d\n", name, errno);
             *x = '/';
             return ret;
         }
@@ -209,7 +208,7 @@ static int do_list(int s, const char *path)
 
     d = opendir(path);
     if(d == NULL) {
-        E("failed to open dir due to: errno:%d\n", errno);
+        D("failed to open dir due to: errno:%d\n", errno);
         goto done;
     }
 
@@ -253,7 +252,7 @@ static int fail_message(int s, const char *reason)
     syncmsg msg;
     size_t len = strlen(reason);
 
-    E("sync: failure: %s\n", reason);
+    D("sync: failure: %s\n", reason);
 
     msg.data.id = ID_FAIL;
     msg.data.size = htoll(len);
@@ -285,7 +284,7 @@ static int fail_errno(int fd, int err_no)
 
 static void sync_mediadb(char *path) {
     if (access(CMD_MEDIADB_UPDATE, F_OK) != 0) {
-        E("%s: command not found\n", CMD_MEDIADB_UPDATE);
+        D("%s: command not found\n", CMD_MEDIADB_UPDATE);
         return;
     }
 
@@ -348,7 +347,7 @@ static int handle_send_file(int s, int noti_fd, char *path, mode_t mode, char *b
             goto fail;
         }
         if(readx(s, buffer, len)) {
-            E("read failed due to unknown reason\n");
+            D("read failed due to unknown reason\n");
             goto fail;
         }
 
@@ -378,7 +377,7 @@ static int handle_send_file(int s, int noti_fd, char *path, mode_t mode, char *b
         // flush file system buffers due to N_SE-22305
         sync();
     } else {
-        E("sync error: %d!!!\n", fd);
+        D("sync error: %d!!!\n", fd);
         return -1;
     }
     sync_send_label_notify(noti_fd, path, 1);
@@ -580,7 +579,7 @@ void file_sync_service(int fd, void *cookie)
     int s[2];
 
     if(sdb_socketpair(s)) {
-        E("cannot create service socket pair\n");
+        D("cannot create service socket pair\n");
         exit(-1);
     }
 
@@ -617,7 +616,7 @@ void file_sync_service(int fd, void *cookie)
 
             rv = select(fd + 1, &set, NULL, NULL, &timeout);
             if (rv == -1) {
-                E("sync file descriptor select failed\n");
+                D("sync file descriptor select failed\n");
             } else if (rv == 0) {
                 D("sync file descriptor timeout: (took %d sec over)\n", SYNC_TIMEOUT);
                 fail_message(fd, "sync timeout");
@@ -672,7 +671,7 @@ fail:
         sdb_close(s[1]);
     }
 
-    I("sync: done\n");
+    D("sync: done\n");
     sync_send_label_notify(s[0], name, 0);
     sdb_close(s[0]);
     sdb_close(fd);
index 3b95ada..e7aff88 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -18,7 +18,6 @@
 #define __LOG_H
 
 #include <errno.h>
-#include <dlog.h>
 
 #include "sysdeps.h"
 
@@ -63,14 +62,10 @@ void sdb_qemu_trace(const char* fmt, ...);
   extern unsigned char    sdb_trace_output_count;
   void    sdb_trace_init(void);
 
-//#  define SDB_TRACING  ((sdb_trace_mask & (1 << TRACE_TAG)) != 0)
+#  define SDB_TRACING  ((sdb_trace_mask & (1 << TRACE_TAG)) != 0)
 
   /* you must define TRACE_TAG before using this macro */
-
-#define D(fmt, arg...) SECURE_SLOGD(fmt, ##arg)
-#define I(fmt, arg...) SECURE_SLOGI(fmt, ##arg)
-#define E(fmt, arg...) SECURE_SLOGE(fmt, ##arg)
-/*#  define  D(...)                                      \
+#  define  D(...)                                      \
         do {                                           \
             if (SDB_TRACING) {                         \
                 sdb_mutex_lock(&D_lock);               \
@@ -94,7 +89,7 @@ void sdb_qemu_trace(const char* fmt, ...);
                 errno = save_errno;                    \
                 sdb_mutex_unlock(&D_lock);             \
            }                                           \
-        } while (0)*/
+        } while (0)
 #else
 #  define  D(...)          ((void)0)
 #  define  DR(...)         ((void)0)
index 96956b7..2e257fe 100644 (file)
@@ -17,8 +17,7 @@
 #include <string.h>
 #include <dlfcn.h>
 
-//#define TRACE_TAG TRACE_SDB
-#define LOG_TAG "SDBD_TRACE_SDB"
+#define TRACE_TAG TRACE_SDB
 #include "log.h"
 
 #include "sdb.h"
@@ -77,7 +76,7 @@ static int plugin_register_command ( int command, priority cmd_priority )
         int ret = hashtable_put ( plugin_cmd_hashtable, command, cmd_priority );
         D ("register plugin command : cmd(%d), result(%d)\n", command, ret);
     } else {
-        I ("hashtable is not created\n");
+        D ("hashtable is not created\n");
     }
     return 0;
 }
@@ -92,13 +91,13 @@ static int load_plugin_not_default()
 
     g_plugin_handle = dlopen ( PLUGIN_PATH, RTLD_NOW );
     if ( g_plugin_handle == NULL ) {
-        E ( "failed to dlopen(%s). error: %s\n", PLUGIN_PATH, dlerror() );
+        D ( "failed to dlopen(%s). error: %s\n", PLUGIN_PATH, dlerror() );
         return 0;
     }
 
     plugin_init_proc = dlsym ( g_plugin_handle, PLUGIN_PROC_NAME_INIT );
     if ( plugin_init_proc == NULL ) {
-        E ( "failed to get the sdbd plugin init function. error: %s\n", dlerror() );
+        D ( "failed to get the sdbd plugin init function. error: %s\n", dlerror() );
         dlclose ( g_plugin_handle );
         g_plugin_handle = NULL;
         return 0;
@@ -132,7 +131,7 @@ void load_sdbd_plugin()
         plugin_sync_proc = default_plugin_sync_proc;
         plugin_async_proc = default_plugin_async_proc;
 
-        I ( "using default plugin interface.\n" );
+        D ( "using default plugin interface.\n" );
     } else {
         D ( "using sdbd plugin interface.(%s)\n", PLUGIN_PATH );
 
@@ -235,7 +234,7 @@ static int create_async_proc_thread( int cmd, parameters* in )
     if (sdb_socketpair(s)) {
         release_parameters(in);
         free(in);
-        E("cannot create async proc socket pair\n");
+        D("cannot create async proc socket pair\n");
         return -1;
     }
 
@@ -257,7 +256,7 @@ static int create_async_proc_thread( int cmd, parameters* in )
         sdb_close(s[1]);
         release_parameters(in);
         free(in);
-        E("cannot create async proc thread\n");
+        D("cannot create async proc thread\n");
         return -1;
     }
 
@@ -276,7 +275,7 @@ int request_capability_to_plugin ( int cap, char* out_buf, unsigned int out_len
     in.number_of_parameter = 1;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -347,7 +346,7 @@ int request_conversion_to_plugin ( int cmd, const char* in_buf, char* out_buf, u
         in.number_of_parameter = 1;
         in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
         if (in.array_of_parameter == NULL) {
-            E("failed to allocate memory for the parameter\n");
+            D("failed to allocate memory for the parameter\n");
             return success;
         }
         in.array_of_parameter[0].type = type_string;
@@ -382,7 +381,7 @@ int request_lock_state_to_plugin ( int lock_type )
     in.number_of_parameter = 1;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return result;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -414,7 +413,7 @@ int request_appcmd_to_plugin ( const char* in_buf )
 
     in = (parameters*)malloc(sizeof(parameters));
     if (in == NULL) {
-        E("failed to allocate memory for the parameters\n");
+        D("failed to allocate memory for the parameters\n");
         return -1;
     }
 
@@ -423,7 +422,7 @@ int request_appcmd_to_plugin ( const char* in_buf )
         in->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
         if (in->array_of_parameter == NULL) {
             free(in);
-            E("failed to allocate memory for the parameter\n");
+            D("failed to allocate memory for the parameter\n");
             return -1;
         }
         in->array_of_parameter[0].type = type_string;
index 7ed53f1..8bd9b9d 100644 (file)
@@ -3,8 +3,7 @@
 
 //#define LOG_TAG "SDBD"
 //#include <dlog.h>
-//#define TRACE_TAG TRACE_SDB
-#define LOG_TAG "SDBD_TRACE_SDB"
+#define TRACE_TAG TRACE_SDB
 #include "log.h"
 
 #include "plugin.h"
@@ -67,7 +66,7 @@ int security_deinit(const int nSessionID)
     in.number_of_parameter = 1;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -94,7 +93,7 @@ int security_parse_server_hello(const int nSessionID, apacket* pApacket)
     in.number_of_parameter = 2;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -126,7 +125,7 @@ int security_gen_client_hello(const int nSessionID, apacket* pApacket)
     in.number_of_parameter = 1;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -155,7 +154,7 @@ int security_parse_server_ack(const int nSessionID, apacket* pApacket)
     in.number_of_parameter = 2;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -187,7 +186,7 @@ int security_gen_client_ack(const int nSessionID, apacket* pApacket)
     in.number_of_parameter = 1;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -216,7 +215,7 @@ int security_encrypt(const int nSessionID, apacket* pApacket)
     in.number_of_parameter = 2;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -250,7 +249,7 @@ int security_decrypt(const int nSessionID, apacket* pApacket)
     in.number_of_parameter = 2;
     in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
     if (in.array_of_parameter == NULL) {
-        E("failed to allocate memory for the parameter\n");
+        D("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
index 38a6b21..b4c3e61 100644 (file)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-//#define  TRACE_TAG   TRACE_SDB
-#define LOG_TAG "SDBD_TRACE_SDB"
+#define  TRACE_TAG   TRACE_SDB
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -181,7 +180,7 @@ int is_container_enabled(void) {
     int ret;
     ret = system_info_get_platform_bool("tizen.org/feature/container", &value);
     if (ret != SYSTEM_INFO_ERROR_NONE) {
-        E("failed to get container information: %d\n", errno);
+        D("failed to get container information: %d\n", errno);
         return 0;
     } else {
         D("tizen container: %d\n", value);
@@ -235,7 +234,7 @@ static char* get_sdb_log_conf(const char* key)
 
     fd = unix_open(SDB_LOGCONF_PATH, O_RDONLY);
     if (fd < 0) {
-        E("failed to open '%s' file: %d\n", SDB_LOGCONF_PATH, errno);
+        D("failed to open '%s' file: %d\n", SDB_LOGCONF_PATH, errno);
         return NULL;
     }
 
@@ -384,12 +383,12 @@ void put_apacket(apacket *p)
 
 void handle_online(void)
 {
-    I("sdb: online\n");
+    D("sdb: online\n");
 }
 
 void handle_offline(atransport *t)
 {
-    I("sdb: offline\n");
+    D("sdb: offline\n");
     //Close the associated usb
     run_transport_disconnects(t);
 }
@@ -467,10 +466,10 @@ int handle_encr_packet(apacket* p, atransport *t){
         t->sessionID = sessionID;
         if((retVal = security_init(t->sessionID, NULL)) == 1){ // 암호화 handshaking을 위한 init
             if(security_parse_server_hello(t->sessionID, p) == 1){ // hello 메시지 파싱
-                I("security_parse_server_hello success\n");
+                D("security_parse_server_hello success\n");
                 enc_p = get_apacket();
                 if(security_gen_client_hello(t->sessionID, enc_p) == 1){ // hello 메시지 생성
-                    I("security_gen_client_hello success\n");
+                    D("security_gen_client_hello success\n");
                     enc_p->msg.command = A_ENCR;
                     enc_p->msg.arg0 = ENCR_SET_ON_REQ;
                     enc_p->msg.arg1 = p->msg.arg1;
@@ -478,7 +477,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                     send_packet(enc_p, t);
                 }
                 else { // hello 메시지 생성 실패
-                    E("security_gen_client_hello error\n");
+                    D("security_gen_client_hello error\n");
                     send_encr_fail(p, t, ENCR_ON_FAIL); // 암호화 on 실패 메시지 전송
                     t->encryption = ENCR_OFF; // 암호화 모드는 off
                     security_deinit(t->sessionID);
@@ -486,7 +485,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                 }
             }
             else{ // hello 메시지 파싱 실패
-                E("security_parse_server_hello error\n");
+                D("security_parse_server_hello error\n");
                 send_encr_fail(p, t, ENCR_ON_FAIL);
                 t->encryption = ENCR_OFF;
                 security_deinit(t->sessionID);
@@ -494,7 +493,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                 return -1;
             }
         } else { // init 실패
-            E("security_init error\n");
+            D("security_init error\n");
             send_encr_fail(p, t, ENCR_ON_FAIL);
             t->encryption = ENCR_OFF;
             if (retVal == 0)
@@ -509,7 +508,7 @@ int handle_encr_packet(apacket* p, atransport *t){
         if(security_parse_server_ack(t->sessionID, p) == 1){    // ack 메시지 파싱
             enc_p = get_apacket();
             if(security_gen_client_ack(t->sessionID, enc_p) == 1){ // ack 메시지 생성
-                I("security_gen_client_ack success\n");
+                D("security_gen_client_ack success\n");
                 enc_p->msg.command = A_ENCR;
                 enc_p->msg.arg0 = ENCR_SET_ON_OK;
                 enc_p->msg.arg1 = p->msg.arg1;
@@ -517,7 +516,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                 send_packet(enc_p, t);
             }
             else { // ack 메시지 생성에 실패한 경우
-                E("security_gen_client_ack error\n");
+                D("security_gen_client_ack error\n");
                 send_encr_fail(p, t, ENCR_ON_FAIL);
                 t->encryption = ENCR_OFF;
                 security_deinit(t->sessionID);
@@ -525,7 +524,7 @@ int handle_encr_packet(apacket* p, atransport *t){
             }
         }
         else { // ack 메시지 파싱에 실패한 경우
-            E("security_parse_server_ack error\n");
+            D("security_parse_server_ack error\n");
             send_encr_fail(p, t, ENCR_ON_FAIL);
             t->encryption = ENCR_OFF;
             security_deinit(t->sessionID);
@@ -542,7 +541,7 @@ int handle_encr_packet(apacket* p, atransport *t){
             send_packet(enc_p, t);
         }
         else { // 암호화 모드 off에 실패한 경우
-            E("security_deinit error\n");
+            D("security_deinit error\n");
             send_encr_fail(p, t, ENCR_OFF_FAIL); // 암호화 모드 off 실패 메시지 전송
             return -1;
         }
@@ -564,12 +563,12 @@ int handle_encr_packet(apacket* p, atransport *t){
     else if (p->msg.arg0 == ENCR_ON_FAIL) // 암호화 모드를 on 하는 도중 실패한 경우 받는 메시지
     {
         t->encryption = ENCR_OFF; // 암호화 모드를 다시 off
-        E("encryption on failed\n");
+        D("encryption on failed\n");
     }
     else if (p->msg.arg0 == ENCR_OFF_FAIL) // 암호화 모드를 off하는 도중 실패한 경우 받는 메시지
     {
         //t->encryption = ENCR_ON;
-        E("encryption off failed\n");
+        D("encryption off failed\n");
     }
     //put_apacket(enc_p);
     return 0;
@@ -580,7 +579,7 @@ int handle_encr_packet(apacket* p, atransport *t){
 
 static void send_ready(unsigned local, unsigned remote, atransport *t)
 {
-    I("Calling send_ready \n");
+    D("Calling send_ready \n");
     apacket *p = get_apacket();
     p->msg.command = A_OKAY;
     p->msg.arg0 = local;
@@ -590,7 +589,7 @@ static void send_ready(unsigned local, unsigned remote, atransport *t)
 
 static void send_close(unsigned local, unsigned remote, atransport *t)
 {
-    I("Calling send_close \n");
+    D("Calling send_close \n");
     apacket *p = get_apacket();
     p->msg.command = A_CLSE;
     p->msg.arg0 = local;
@@ -600,7 +599,7 @@ static void send_close(unsigned local, unsigned remote, atransport *t)
 
 static void send_connect(atransport *t)
 {
-    I("Calling send_connect \n");
+    D("Calling send_connect \n");
     apacket *cp = get_apacket();
     cp->msg.command = A_CNXN;
     cp->msg.arg0 = A_VERSION;
@@ -636,7 +635,7 @@ static void send_connect(atransport *t)
 
 void send_device_status()
 {
-    I("broadcast device status\n");
+    D("broadcast device status\n");
     apacket* cp = get_apacket();
     cp->msg.command = A_STAT;
     cp->msg.arg0 = is_pwlocked;
@@ -680,7 +679,7 @@ static int get_str_cmdline(char *src, char *dest, char str[], int str_size) {
     int len = e-s-strlen(dest);
 
     if (len >= str_size) {
-        E("buffer size(%d) should be bigger than %d\n", str_size, len+1);
+        D("buffer size(%d) should be bigger than %d\n", str_size, len+1);
         return -1;
     }
 
@@ -714,7 +713,7 @@ int get_device_name(char str[], int str_size) {
     char *value = NULL;
     int r = system_info_get_platform_string("http://tizen.org/system/model_name", &value);
     if (r != SYSTEM_INFO_ERROR_NONE) {
-        E("fail to get system model:%d\n", errno);
+        D("fail to get system model:%d\n", errno);
         return -1;
     } else {
         s_strncpy(str, value, str_size);
@@ -746,13 +745,13 @@ static int get_cmdline_value(char *split, char str[], int str_size) {
     int fd = unix_open(PROC_CMDLINE_PATH, O_RDONLY);
 
     if (fd < 0) {
-        E("fail to read /proc/cmdline\n");
+        D("fail to read /proc/cmdline\n");
         return -1;
     }
     if(read_line(fd, cmdline, sizeof(cmdline))) {
         D("qemu cmd: %s\n", cmdline);
         if (get_str_cmdline(cmdline, split, str, str_size) < 1) {
-            E("could not get the (%s) value from cmdline\n", split);
+            D("could not get the (%s) value from cmdline\n", split);
             sdb_close(fd);
             return -1;
         }
@@ -772,19 +771,19 @@ int get_emulator_guestip(char str[], int str_size) {
 
     s = socket(AF_INET, SOCK_DGRAM, 0);
     if(s < 0) {
-        E("socket error\n");
+        D("socket error\n");
         return -1;
     }
 
     snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", GUEST_IP_INTERFACE);
     if(ioctl(s, SIOCGIFHWADDR, &ifr) < 0) {
-        E("ioctl hwaddr error\n");
+        D("ioctl hwaddr error\n");
         sdb_close(s);
         return -1;
     }
 
     if(ioctl(s, SIOCGIFADDR, &ifr) < 0) {
-        E("ioctl addr error\n");
+        D("ioctl addr error\n");
         sdb_close(s);
         return -1;
     }
@@ -821,28 +820,28 @@ void parse_banner(char *banner, atransport *t)
     }
 
     if(!strcmp(type, "bootloader")){
-        I("setting connection_state to CS_BOOTLOADER\n");
+        D("setting connection_state to CS_BOOTLOADER\n");
         t->connection_state = CS_BOOTLOADER;
         update_transports();
         return;
     }
 
     if(!strcmp(type, "device")) {
-        I("setting connection_state to CS_DEVICE\n");
+        D("setting connection_state to CS_DEVICE\n");
         t->connection_state = CS_DEVICE;
         update_transports();
         return;
     }
 
     if(!strcmp(type, "recovery")) {
-        I("setting connection_state to CS_RECOVERY\n");
+        D("setting connection_state to CS_RECOVERY\n");
         t->connection_state = CS_RECOVERY;
         update_transports();
         return;
     }
 
     if(!strcmp(type, "sideload")) {
-        I("setting connection_state to CS_SIDELOAD\n");
+        D("setting connection_state to CS_SIDELOAD\n");
         t->connection_state = CS_SIDELOAD;
         update_transports();
         return;
@@ -873,10 +872,10 @@ void handle_packet(apacket *p, atransport *t)
 
     asocket *s;
 
-//    D("handle_packet() %c%c%c%c\n", ((char*) (&(p->msg.command)))[0],
-//                ((char*) (&(p->msg.command)))[1],
-//                ((char*) (&(p->msg.command)))[2],
-//                ((char*) (&(p->msg.command)))[3]);
+    D("handle_packet() %c%c%c%c\n", ((char*) (&(p->msg.command)))[0],
+                ((char*) (&(p->msg.command)))[1],
+                ((char*) (&(p->msg.command)))[2],
+                ((char*) (&(p->msg.command)))[3]);
 
     print_packet("recv", p);
 
@@ -907,7 +906,7 @@ void handle_packet(apacket *p, atransport *t)
     case A_OPEN: /* OPEN(local-id, 0, "destination") */
         if (request_lock_state_to_plugin(LOCKTYPE_PASSWORD) == 1 && t->connection_state == CS_PWLOCK) {
             // in case of already locked before get A_CNXN
-            E("open failed due to password locked before get A_CNXN:%d\n", t->connection_state);
+            D("open failed due to password locked before get A_CNXN:%d\n", t->connection_state);
             send_close(0, p->msg.arg0, t);
         } else {
             if(t->connection_state != CS_OFFLINE) {
@@ -953,7 +952,7 @@ void handle_packet(apacket *p, atransport *t)
                 p->len = p->msg.data_length;
 
                 if(s->enqueue(s, p) == 0) {
-                    I("Enqueue the socket\n");
+                    D("Enqueue the socket\n");
                     send_ready(s->id, rid, t);
                 }
                 return;
@@ -1156,7 +1155,7 @@ static int install_listener(const char *local_name, const char *connect_to, atra
     }
 
     if (close_on_exec(l->fd) < 0) {
-        E("fail to close fd exec:%d\n",l->fd);
+        D("fail to close fd exec:%d\n",l->fd);
     }
     if(!strcmp(l->connect_to, "*smartsocket*")) {
         fdevent_install(&l->fde, l->fd, ss_listener_event_func, l);
@@ -1303,17 +1302,17 @@ static void booting_done_signal_subscriber(GDBusConnection *connection,
 
     booting_done = 1;
     if (access(SDBD_BOOT_INFO_FILE, F_OK) == 0) {
-        I("booting is already done\n");
+        D("booting is already done\n");
     } else {
         FILE *info_file = fopen(SDBD_BOOT_INFO_FILE, "w");
         if (info_file != NULL) {
             fprintf(info_file, "%d", 1);
             fclose(info_file);
         }
-        I("booting is done\n");
+        D("booting is done\n");
     }
 
-    I("handled the booting done signal\n");
+    D("handled the booting done signal\n");
     g_main_loop_quit(g_mainloop);
 }
 
@@ -1326,17 +1325,17 @@ static void *bootdone_cb(void *args)
     connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
     if (connection == NULL) {
         if (error != NULL) {
-            E("failed to connect to the system bus: %s\n", error->message);
+            D("failed to connect to the system bus: %s\n", error->message);
             g_error_free(error);
         } else {
-            E("failed to connect to the system bus\n");
+            D("failed to connect to the system bus\n");
         }
         return NULL;
     }
 
     g_mainloop = g_main_loop_new(NULL, false);
     if (g_mainloop == NULL) {
-        E("failed to create a g_main_loop\n");
+        D("failed to create a g_main_loop\n");
         goto bootdone_out;
     }
 
@@ -1345,11 +1344,11 @@ static void *bootdone_cb(void *args)
         DEVICED_CORE_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
         booting_done_signal_subscriber, NULL, NULL);
     if (id == 0) {
-        E("failed to subscribe to the booting done signal\n");
+        D("failed to subscribe to the booting done signal\n");
         goto bootdone_out;
     }
 
-    I("wait for the booting done signal\n");
+    D("wait for the booting done signal\n");
     g_main_loop_run(g_mainloop);
 
     g_dbus_connection_signal_unsubscribe(connection, id);
@@ -1361,7 +1360,7 @@ bootdone_out:
     if (connection != NULL) {
         g_object_unref(connection);
     }
-    I("exit the bootdone_cb thread\n");
+    D("exit the bootdone_cb thread\n");
 
     return NULL;
 }
@@ -1370,10 +1369,10 @@ void register_bootdone_cb()
 {
     sdb_thread_t t;
     if (sdb_thread_create(&t, bootdone_cb, NULL)) {
-        E("can not create a service thread to check the booting done\n");
+        D("can not create a service thread to check the booting done\n");
         return;
     }
-    I("created the bootdone_cb thread\n");
+    D("created the bootdone_cb thread\n");
 }
 
 static int sdbd_set_groups(const char *name, int gid, struct group_info default_groups[], int default_groups_size) {
@@ -1388,11 +1387,11 @@ static int sdbd_set_groups(const char *name, int gid, struct group_info default_
     }
     group_ids = malloc((ngroups + default_groups_size) * sizeof(gid_t));
     if (group_ids == NULL) {
-        E("failed to allocate group_ids(%zu)\n", (ngroups + default_groups_size) * sizeof(gid_t));
+        D("failed to allocate group_ids(%zu)\n", (ngroups + default_groups_size) * sizeof(gid_t));
         return -1;
     }
     if (getgrouplist(name, gid, group_ids, &ngroups) == -1) {
-        E("failed to getgrouplist(), ngroups = %d\n", ngroups);
+        D("failed to getgrouplist(), ngroups = %d\n", ngroups);
         free(group_ids);
         return -1;
     }
@@ -1412,7 +1411,7 @@ static int sdbd_set_groups(const char *name, int gid, struct group_info default_
         }
     }
     if (setgroups(ngroups+added_group_cnt, group_ids) != 0) {
-        E("failed to setgroups().\n");
+        D("failed to setgroups().\n");
         free(group_ids);
         return -1;
     }
@@ -1428,10 +1427,10 @@ static int sdbd_get_user_pwd(const char* user_name, struct passwd* pwd, char* bu
     ret = getpwnam_r(user_name, pwd, buf, bufsize, &result);
     if (result == NULL) {
         if (ret == 0) {
-            E("Not found passwd : username(%s)\n", user_name);
+            D("Not found passwd : username(%s)\n", user_name);
         } else {
             errno = ret;
-            E("failed to getpwnam_r\n");
+            D("failed to getpwnam_r\n");
         }
         return -1;
     }
@@ -1446,10 +1445,10 @@ static int sdbd_get_group(const char* group_name, struct group* grp, char* buf,
     ret = getgrnam_r(group_name, grp, buf, bufsize, &result);
     if (result == NULL) {
         if (ret == 0) {
-            E("Not found group : groupname(%s)\n", group_name);
+            D("Not found group : groupname(%s)\n", group_name);
         } else {
             errno = ret;
-            E("failed to getgrnam_r\n");
+            D("failed to getgrnam_r\n");
         }
         return -1;
     }
@@ -1459,7 +1458,7 @@ static int sdbd_get_group(const char* group_name, struct group* grp, char* buf,
 
 int set_sdk_user_privileges(int is_drop_capability_after_fork) {
     if (!is_init_sdk_userinfo) {
-        E("failed to init sdk user information.\n");
+        D("failed to init sdk user information.\n");
         return -1;
     }
 
@@ -1470,23 +1469,23 @@ int set_sdk_user_privileges(int is_drop_capability_after_fork) {
     if(is_drop_capability_after_fork) {
 
         if (setuid(g_root_user_id) != 0) {
-            E("set root user id failed (errno: %d)\n", errno);
+            D("set root user id failed (errno: %d)\n", errno);
             return -1;
         }
     }
 
     if (sdbd_set_groups(SDK_USER_NAME, g_sdk_group_id, g_default_groups, SDB_DEFAULT_GROUPS_CNT) < 0) {
-        E("set groups failed (errno: %d)\n", errno);
+        D("set groups failed (errno: %d)\n", errno);
         return -1;
     }
 
     if (setgid(g_sdk_group_id) != 0) {
-        E("set group id failed (errno: %d)\n", errno);
+        D("set group id failed (errno: %d)\n", errno);
         return -1;
     }
 
     if (setuid(g_sdk_user_id) != 0) {
-        E("set user id failed (errno: %d)\n", errno);
+        D("set user id failed (errno: %d)\n", errno);
         return -1;
 //        if(is_drop_capability_after_fork) {
 //            return -1;
@@ -1494,7 +1493,7 @@ int set_sdk_user_privileges(int is_drop_capability_after_fork) {
     }
 
     if (chdir(g_sdk_home_dir) < 0) {
-        E("unable to change working directory to %s\n", g_sdk_home_dir);
+        D("unable to change working directory to %s\n", g_sdk_home_dir);
     }
 
     // TODO: use pam later
@@ -1508,19 +1507,19 @@ int set_sdk_user_privileges(int is_drop_capability_after_fork) {
 int set_root_privileges() {
 
     if (sdbd_set_groups(ROOT_USER_NAME, g_root_group_id, NULL, 0) < 0) {
-        E("set root groups failed (errno: %d)\n", errno);
+        D("set root groups failed (errno: %d)\n", errno);
     }
 
     if (setgid(g_root_group_id) != 0) {
-        E("set root group id failed (errno: %d)\n", errno);
+        D("set root group id failed (errno: %d)\n", errno);
     }
 
     if (setuid(g_root_user_id) != 0) {
-        E("set root user id failed (errno: %d)\n", errno);
+        D("set root user id failed (errno: %d)\n", errno);
     }
 
     if (chdir(g_root_home_dir) < 0) {
-        E("unable to change root working directory to %s\n", g_sdk_home_dir);
+        D("unable to change root working directory to %s\n", g_sdk_home_dir);
     }
 
     // TODO: use pam later
@@ -1563,7 +1562,7 @@ static int init_sdb_default_groups() {
     bufsize = get_group_bufsize();
     buf = malloc(bufsize);
     if (buf == NULL) {
-        E("failed to allocate gruop buf(%ld)\n", bufsize);
+        D("failed to allocate gruop buf(%ld)\n", bufsize);
         return -1;
     }
 
@@ -1572,7 +1571,7 @@ static int init_sdb_default_groups() {
         if (sdbd_get_group(g_default_groups[i].name, &grp, buf, bufsize) == 0) {
             g_default_groups[i].gid = grp.gr_gid;
         } else {
-            E("failed get group info.(errno: %d)\n", errno);
+            D("failed get group info.(errno: %d)\n", errno);
         }
     }
 
@@ -1600,11 +1599,11 @@ static int init_root_userinfo() {
     bufsize = get_passwd_bufsize();
     buf = malloc(bufsize);
     if (buf == NULL) {
-        E("failed to allocate passwd buf(%ld)\n", bufsize);
+        D("failed to allocate passwd buf(%ld)\n", bufsize);
         set_static_root_userinfo();
     } else {
         if (sdbd_get_user_pwd(ROOT_USER_NAME, &pwd, buf, bufsize) < 0) {
-            E("failed to get root user passwd info.(errno: %d)\n", errno);
+            D("failed to get root user passwd info.(errno: %d)\n", errno);
             set_static_root_userinfo();
         } else {
             D("username=%s, uid=%d, gid=%d, dir=%s\n", pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_dir);
@@ -1619,7 +1618,7 @@ static int init_root_userinfo() {
     int env_size = strlen("HOME=") + strlen(g_root_home_dir) + 1;
     g_root_home_dir_env = malloc(env_size);
     if(g_root_home_dir_env == NULL) {
-        E("failed to allocate for home dir env string\n");
+        D("failed to allocate for home dir env string\n");
     } else {
         snprintf(g_root_home_dir_env, env_size, "HOME=%s", g_root_home_dir);
     }
@@ -1637,17 +1636,17 @@ static int init_sdk_userinfo() {
     }
 
     if (init_sdb_default_groups() < 0) {
-        E("failed to initialize default groups.\n");
+        D("failed to initialize default groups.\n");
     }
 
     bufsize = get_passwd_bufsize();
     buf = malloc(bufsize);
     if (buf == NULL) {
-        E("failed to allocate passwd buf(%ld)\n", bufsize);
+        D("failed to allocate passwd buf(%ld)\n", bufsize);
         set_static_sdk_userinfo();
     } else {
         if (sdbd_get_user_pwd(SDK_USER_NAME, &pwd, buf, bufsize) < 0) {
-            E("get user passwd info.(errno: %d)\n", errno);
+            D("get user passwd info.(errno: %d)\n", errno);
             set_static_sdk_userinfo();
         } else {
             D("username=%s, uid=%d, gid=%d, dir=%s\n", pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_dir);
@@ -1662,7 +1661,7 @@ static int init_sdk_userinfo() {
     int env_size = strlen("HOME=") + strlen(g_sdk_home_dir) + 1;
     g_sdk_home_dir_env = malloc(env_size);
     if(g_sdk_home_dir_env == NULL) {
-        E("failed to allocate for home dir env string\n");
+        D("failed to allocate for home dir env string\n");
     } else {
         snprintf(g_sdk_home_dir_env, env_size, "HOME=%s", g_sdk_home_dir);
     }
@@ -1681,7 +1680,7 @@ static int safe_system(char *cmd, char *argv[], char *envp[]) {
             return -1;
         case 0:
             execve(cmd, argv, envp);
-            E("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
+            D("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
             exit(-1);
         default:
             for (;;) {
@@ -1725,7 +1724,7 @@ static void init_sdk_requirements() {
                 NULL,
             };
             if (safe_system(cmd, args, envp) < 0) {
-                E("failed to change ownership to sdk user to %s\n", g_sdk_home_dir);
+                D("failed to change ownership to sdk user to %s\n", g_sdk_home_dir);
             }
 
             /* free environment variables */
@@ -1755,7 +1754,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch),
                     "%s", UNKNOWN);
-        E("fail to get the CPU architecture of model:%d\n", errno);
+        D("fail to get the CPU architecture of model:%d\n", errno);
     } else {
         snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch),
                     "%s", value);
@@ -1768,7 +1767,7 @@ static void init_capabilities(void) {
     // Secure protocol support
     if(!request_capability_to_plugin(CAPABILITY_SECURE, g_capabilities.secure_protocol,
                             sizeof(g_capabilities.secure_protocol))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_SECURE);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_SECURE);
         snprintf(g_capabilities.secure_protocol, sizeof(g_capabilities.secure_protocol),
                     "%s", DISABLED);
     }
@@ -1777,7 +1776,7 @@ static void init_capabilities(void) {
     // Interactive shell support
     if(!request_capability_to_plugin(CAPABILITY_INTER_SHELL, g_capabilities.intershell_support,
                             sizeof(g_capabilities.intershell_support))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_INTER_SHELL);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_INTER_SHELL);
         snprintf(g_capabilities.intershell_support, sizeof(g_capabilities.intershell_support),
                     "%s", DISABLED);
     }
@@ -1786,7 +1785,7 @@ static void init_capabilities(void) {
     // File push/pull support
     if(!request_capability_to_plugin(CAPABILITY_FILESYNC, g_capabilities.filesync_support,
                             sizeof(g_capabilities.filesync_support))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_FILESYNC);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_FILESYNC);
         snprintf(g_capabilities.filesync_support, sizeof(g_capabilities.filesync_support),
                     "%s", DISABLED);
     }
@@ -1795,7 +1794,7 @@ static void init_capabilities(void) {
     // USB protocol support
     if(!request_capability_to_plugin(CAPABILITY_USB_PROTOCOL, g_capabilities.usbproto_support,
                             sizeof(g_capabilities.usbproto_support))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_USB_PROTOCOL);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_USB_PROTOCOL);
         snprintf(g_capabilities.usbproto_support, sizeof(g_capabilities.usbproto_support),
                     "%s", DISABLED);
     }
@@ -1804,7 +1803,7 @@ static void init_capabilities(void) {
     // Socket protocol support
     if(!request_capability_to_plugin(CAPABILITY_SOCK_PROTOCOL, g_capabilities.sockproto_support,
                             sizeof(g_capabilities.sockproto_support))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_SOCK_PROTOCOL);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_SOCK_PROTOCOL);
         snprintf(g_capabilities.sockproto_support, sizeof(g_capabilities.sockproto_support),
                     "%s", DISABLED);
     }
@@ -1816,7 +1815,7 @@ static void init_capabilities(void) {
     // Root command support
     if(!request_capability_to_plugin(CAPABILITY_ROOT_ONOFF, g_capabilities.rootonoff_support,
                             sizeof(g_capabilities.rootonoff_support))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_ROOT_ONOFF);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_ROOT_ONOFF);
         snprintf(g_capabilities.rootonoff_support, sizeof(g_capabilities.rootonoff_support),
                     "%s", DISABLED);
     }
@@ -1825,7 +1824,7 @@ static void init_capabilities(void) {
     // Encryption support
     if(!request_capability_to_plugin(CAPABILITY_ENCRYPTION, g_capabilities.encryption_support,
                             sizeof(g_capabilities.encryption_support))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_ENCRYPTION);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_ENCRYPTION);
         snprintf(g_capabilities.encryption_support, sizeof(g_capabilities.encryption_support),
                     "%s", DISABLED);
     }
@@ -1855,7 +1854,7 @@ static void init_capabilities(void) {
 
     // SDK Tool path
     if (SDK_TOOL_PATH == NULL) {
-        E("fail to get SDK tool path.\n");
+        D("fail to get SDK tool path.\n");
         snprintf(g_capabilities.sdk_toolpath, sizeof(g_capabilities.sdk_toolpath),
                     "%s", UNKNOWN);
     } else {
@@ -1868,7 +1867,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.profile_name, sizeof(g_capabilities.profile_name),
                     "%s", UNKNOWN);
-        E("fail to get profile name:%d\n", errno);
+        D("fail to get profile name:%d\n", errno);
     } else {
         snprintf(g_capabilities.profile_name, sizeof(g_capabilities.profile_name),
                     "%s", value);
@@ -1883,7 +1882,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.vendor_name, sizeof(g_capabilities.vendor_name),
                     "%s", UNKNOWN);
-        E("fail to get the Vendor name:%d\n", errno);
+        D("fail to get the Vendor name:%d\n", errno);
     } else {
         snprintf(g_capabilities.vendor_name, sizeof(g_capabilities.vendor_name),
                     "%s", value);
@@ -1896,7 +1895,7 @@ static void init_capabilities(void) {
     // Target name of the launch possible
     if(!request_capability_to_plugin(CAPABILITY_CAN_LAUNCH, g_capabilities.can_launch,
                             sizeof(g_capabilities.can_launch))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_CAN_LAUNCH);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_CAN_LAUNCH);
         snprintf(g_capabilities.can_launch, sizeof(g_capabilities.can_launch),
                     "%s", UNKNOWN);
     }
@@ -1913,7 +1912,7 @@ static void init_capabilities(void) {
     } else {
         snprintf(g_capabilities.device_name, sizeof(g_capabilities.device_name),
                 "%s", UNKNOWN);
-        E("fail to get the Device name:%d\n", errno);
+        D("fail to get the Device name:%d\n", errno);
     }
 
 
@@ -1922,7 +1921,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.platform_version, sizeof(g_capabilities.platform_version),
                     "%s", UNKNOWN);
-        E("fail to get platform version:%d\n", errno);
+        D("fail to get platform version:%d\n", errno);
     } else {
         snprintf(g_capabilities.platform_version, sizeof(g_capabilities.platform_version),
                     "%s", value);
@@ -1935,7 +1934,7 @@ static void init_capabilities(void) {
     // Product version
     if(!request_capability_to_plugin(CAPABILITY_PRODUCT_VER, g_capabilities.product_version,
                             sizeof(g_capabilities.product_version))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_PRODUCT_VER);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_PRODUCT_VER);
         snprintf(g_capabilities.product_version, sizeof(g_capabilities.product_version),
                     "%s", UNKNOWN);
     }
@@ -1949,7 +1948,7 @@ static void init_capabilities(void) {
     // Sdbd plugin version
     if(!request_capability_to_plugin(CAPABILITY_PLUGIN_VER, g_capabilities.sdbd_plugin_version,
                             sizeof(g_capabilities.sdbd_plugin_version))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_PLUGIN_VER);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_PLUGIN_VER);
         snprintf(g_capabilities.sdbd_plugin_version, sizeof(g_capabilities.sdbd_plugin_version),
                     "%s", UNKNOWN);
     }
@@ -1958,7 +1957,7 @@ static void init_capabilities(void) {
     // sdbd log enable
     if(!request_capability_to_plugin(CAPABILITY_LOG_ENABLE, g_capabilities.log_enable,
                                sizeof(g_capabilities.log_enable))) {
-           E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_LOG_ENABLE);
+           D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_LOG_ENABLE);
            snprintf(g_capabilities.log_enable, sizeof(g_capabilities.log_enable),
                        "%s", DISABLED);
     }
@@ -1966,7 +1965,7 @@ static void init_capabilities(void) {
     // sdbd log path
     if(!request_capability_to_plugin(CAPABILITY_LOG_PATH, g_capabilities.log_path,
                                sizeof(g_capabilities.log_path))) {
-           E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_LOG_PATH);
+           D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_LOG_PATH);
            snprintf(g_capabilities.log_path, sizeof(g_capabilities.log_path),
                        "%s", UNKNOWN);
     }
@@ -1974,7 +1973,7 @@ static void init_capabilities(void) {
     // Application command support
     if(!request_capability_to_plugin(CAPABILITY_APPCMD, g_capabilities.appcmd_support,
                                sizeof(g_capabilities.appcmd_support))) {
-           E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_APPCMD);
+           D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_APPCMD);
            snprintf(g_capabilities.appcmd_support, sizeof(g_capabilities.appcmd_support),
                        "%s", UNKNOWN);
     }
@@ -1987,7 +1986,7 @@ static void init_capabilities(void) {
     // pkgcmd debug mode support
     if(!request_capability_to_plugin(CAPABILITY_DEBUGMODE, g_capabilities.pkgcmd_debugmode,
                 sizeof(g_capabilities.pkgcmd_debugmode))) {
-        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_DEBUGMODE);
+        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_DEBUGMODE);
         snprintf(g_capabilities.pkgcmd_debugmode, sizeof(g_capabilities.pkgcmd_debugmode),
                 "%s", ENABLED);
     }
@@ -2023,14 +2022,14 @@ static void check_emulator_or_device()
     if (ret == 0) {
         if(!strncmp(model_name, EMULATOR_MODEL_NAME, sizeof(EMULATOR_MODEL_NAME))){
             g_is_emulator = 1;
-            I("This target type is Emulator\n");
+            D("This target type is Emulator\n");
         } else {
             g_is_emulator = 0;
-            I("This target type is Device\n");
+            D("This target type is Device\n");
         }
     } else {
         g_is_emulator = -1;
-        E("failed to get the model name.\n");
+        D("failed to get the model name.\n");
     }
 }
 
@@ -2057,13 +2056,13 @@ int sdb_main(int server_port)
 
     init_capabilities();
 
-    //sdb_trace_init();
-    //start_device_log();
+    sdb_trace_init();
+    start_device_log();
 
     init_drop_privileges();
     init_sdk_requirements();
     if (!request_validity_to_plugin(PLUGIN_SYNC_CMD_VERIFY_LAUNCH, NULL)) {
-        E("sdbd should be launched in develop mode.\n");
+        D("sdbd should be launched in develop mode.\n");
         return -1;
     }
 
@@ -2114,7 +2113,7 @@ int sdb_main(int server_port)
         cap.inheritable = 0;
         capset(&header, &cap);
 #endif
-        I("Local port disabled\n");
+        D("Local port disabled\n");
     } else {
         char local_name[30];
         build_local_name(local_name, sizeof(local_name), server_port);
@@ -2164,7 +2163,7 @@ int sdb_main(int server_port)
 
     sdb_notify_startup(0, "READY=1");
 
-    I("Event loop starting\n");
+    D("Event loop starting\n");
 
     fdevent_loop();
 
@@ -2178,12 +2177,12 @@ int sdb_main(int server_port)
 int copy_packet(apacket* dest, apacket* src) {
 
     if(dest == NULL) {
-        E("dest packet is NULL\n");
+        D("dest packet is NULL\n");
         return -1;
     }
 
     if(src == NULL) {
-        E("src packet is NULL\n");
+        D("src packet is NULL\n");
         return -1;
     }
 
@@ -2302,7 +2301,7 @@ int main(int argc, char **argv)
         return EXIT_FAILURE;
     }
 
-    I("Handling main()\n");
+    D("Handling main()\n");
 
     //sdbd will never die on emulator!
     signal(SIGTERM, handle_sig_term); /* tizen specific */
index c734c10..ddf4b18 100644 (file)
@@ -11,8 +11,7 @@
 #include "sysdeps.h"
 #include "sdktools.h"
 
-//#define  TRACE_TAG  TRACE_SERVICES
-#define LOG_TAG "SDBD_TRACE_SEVICES"
+#define  TRACE_TAG  TRACE_SERVICES
 #include "log.h"
 
 #include "sdb.h"
@@ -76,11 +75,11 @@ static int get_application_install_path(char* pkg_path) {
 
     fp = popen("/usr/bin/pkgcmd -a", "r");
     if (fp == NULL) {
-        E("failed : popen pkgcmd -a\n");
+        D("failed : popen pkgcmd -a\n");
         return 0;
     }
     if (!fgets(ret_str, PATH_MAX+64, fp)) {
-        E("failed : fgets pkgcmd -a\n");
+        D("failed : fgets pkgcmd -a\n");
         pclose(fp);
         return 0;
     }
@@ -91,7 +90,7 @@ static int get_application_install_path(char* pkg_path) {
     ret_str[len + 1] = '\0';
 
     if (sscanf(ret_str, "Tizen Application Installation Path: %4095s", pkg_path) != 1) {
-        E("failed : parsing fail (str:%s)\n", ret_str);
+        D("failed : parsing fail (str:%s)\n", ret_str);
         return 0;
     }
 
@@ -106,7 +105,7 @@ int is_pkg_file_path(const char* path) {
     char pkg_path_regx[PATH_MAX+64] = {0,};
 
     if (!get_application_install_path(pkg_path)) {
-        E("failed to get application install path\n");
+        D("failed to get application install path\n");
         return 0;
     }
 
@@ -115,7 +114,7 @@ int is_pkg_file_path(const char* path) {
 
     ret = regcomp(&regex, pkg_path_regx, REG_EXTENDED);
     if (ret){
-        E("failed : recomp (error:%d)\n", ret);
+        D("failed : recomp (error:%d)\n", ret);
         return 0;
     }
 
@@ -123,7 +122,7 @@ int is_pkg_file_path(const char* path) {
     regfree(&regex);
 
     if (ret){
-        E("This path is NOT package file: %s\n", path);
+        D("This path is NOT package file: %s\n", path);
         return 0;
     }
 
index 9f2d7bf..6d98e18 100644 (file)
@@ -23,8 +23,7 @@
 
 #include "sysdeps.h"
 
-//#define  TRACE_TAG  TRACE_SERVICES
-#define LOG_TAG "SDBD_TRACE_SERVICES"
+#define  TRACE_TAG  TRACE_SERVICES
 #include "log.h"
 
 #include "sdb.h"
@@ -165,11 +164,11 @@ void get_tzplatform_env(int fd, void *cookie) {
             D("environment value : %s\n", env_value);
             snprintf(buf, sizeof(buf), "%d%s", NO_ERROR_TZPLATFORM_ENV, env_value);
         } else {
-            E("failed to get environment value using tzplatform_getenv");
+            D("failed to get environment value using tzplatform_getenv");
             snprintf(buf, sizeof(buf), "%d", ERROR_TZPLATFORM_ENV_GENERAL);
         }
     } else {
-        E("environment name (%s) is invalid\n", env_name);
+        D("environment name (%s) is invalid\n", env_name);
         snprintf(buf, sizeof(buf), "%d", ERROR_TZPLATFORM_ENV_INVALID_VARIABLES);
     }
     writex(fd, buf, strlen(buf));
@@ -219,18 +218,18 @@ void inoti_service(int fd, void *arg)
     int ifd;
     char buffer[BUF_LEN];
 
-    I( "inoti_service start\n");
+    D( "inoti_service start\n");
     ifd = inotify_init();
 
     if ( ifd < 0 ) {
-        E( "inotify_init failed\n");
+        D( "inotify_init failed\n");
         sdb_close(fd);
         return;
     }
 
     wd = inotify_add_watch(ifd, CS_PATH, IN_CREATE | IN_MOVE);
     if ( wd < 0 ) {
-        E("inotify_add_watch failed (errno :%d)\n", errno);
+        D("inotify_add_watch failed (errno :%d)\n", errno);
         sdb_close(ifd);
         sdb_close(fd);
         return;
@@ -241,7 +240,7 @@ void inoti_service(int fd, void *arg)
         length = sdb_read( ifd, buffer, BUF_LEN );
 
         if ( length < 0 ) {
-            E( "inoti read failed\n");
+            D( "inoti read failed\n");
             goto done;
         }
         int payload = length >= EVENT_SIZE ? length - EVENT_SIZE : 0;
@@ -257,7 +256,7 @@ void inoti_service(int fd, void *arg)
                             writex(fd, cspath, len);
                             free(cspath);
                         } else {
-                            E( "asprintf was failed\n" );
+                            D( "asprintf was failed\n" );
                         }
                     }
                 } else if (event->mask & IN_MOVE) {
@@ -269,7 +268,7 @@ void inoti_service(int fd, void *arg)
                             writex(fd, cspath, len);
                             free(cspath);
                         } else {
-                            E("asprintf was failed\n");
+                            D("asprintf was failed\n");
                         }
                     }
                 }
@@ -285,7 +284,7 @@ done:
     inotify_rm_watch( ifd, wd );
     sdb_close(ifd);
     sdb_close(fd);
-    I( "inoti_service end\n");
+    D( "inoti_service end\n");
 }
 
 #if 0
@@ -329,7 +328,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
     int s[2];
 
     if(sdb_socketpair(s)) {
-        E("cannot create service socket pair\n");
+        D("cannot create service socket pair\n");
         return -1;
     }
 
@@ -343,7 +342,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
         free(sti);
         sdb_close(s[0]);
         sdb_close(s[1]);
-        E("cannot create service thread\n");
+        D("cannot create service thread\n");
         return -1;
     }
 
@@ -369,23 +368,23 @@ int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * c
 
     ptm = unix_open("/dev/ptmx", O_RDWR); // | O_NOCTTY);
     if(ptm < 0){
-        E("[ cannot open /dev/ptmx - errno:%d ]\n",errno);
+        D("[ cannot open /dev/ptmx - errno:%d ]\n",errno);
         return -1;
     }
     if (fcntl(ptm, F_SETFD, FD_CLOEXEC) < 0) {
-        E("[ cannot set cloexec to /dev/ptmx - errno:%d ]\n",errno);
+        D("[ cannot set cloexec to /dev/ptmx - errno:%d ]\n",errno);
     }
 
     if(grantpt(ptm) || unlockpt(ptm) ||
         ptsname_r(ptm, devname, sizeof(devname)) != 0 ){
-        E("[ trouble with /dev/ptmx - errno:%d ]\n", errno);
+        D("[ trouble with /dev/ptmx - errno:%d ]\n", errno);
         sdb_close(ptm);
         return -1;
     }
 
     *pid = fork();
     if(*pid < 0) {
-        E("- fork failed: errno:%d -\n", errno);
+        D("- fork failed: errno:%d -\n", errno);
         sdb_close(ptm);
         return -1;
     }
@@ -414,7 +413,7 @@ int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * c
                 sdb_close(fd);
             } else {
                // FIXME: not supposed to be here
-               E("sdb: unable to open %s due to errno:%d\n", text, errno);
+               D("sdb: unable to open %s due to errno:%d\n", text, errno);
             }
         }
 
@@ -475,11 +474,11 @@ static ssize_t recv_fd(int fd, void *ptr, size_t nbytes, int *recvfd)
     if ((pheader = CMSG_FIRSTHDR(&msg)) != NULL &&
             pheader->cmsg_len == CMSG_LEN(sizeof(int))) {
         if (pheader->cmsg_level != SOL_SOCKET) {
-            I("sdb: control level != SOL_SOCKET");
+            D("sdb: control level != SOL_SOCKET");
             exit(-1);
         }
         if (pheader->cmsg_type != SCM_RIGHTS) {
-            I("sdb: control type != SCM_RIGHTS");
+            D("sdb: control type != SCM_RIGHTS");
             exit(-1);
         }
         memcpy(recvfd, CMSG_DATA(pheader), sizeof(int));
@@ -494,7 +493,7 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
 {
     *pid = fork();
     if(*pid < 0) {
-        E("- fork failed: errno:%d -\n", errno);
+        D("- fork failed: errno:%d -\n", errno);
         return -1;
     }
 
@@ -505,7 +504,7 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
                 D("sdb: executes root commands!!:%s\n", argv[2]);
             } else {
                 if (getuid() != g_sdk_user_id && set_sdk_user_privileges(RESERVE_CAPABILITIES_AFTER_FORK) < 0) {
-                    E("failed to set SDK user privileges\n");
+                    D("failed to set SDK user privileges\n");
                     exit(-1);
                 }
             }
@@ -514,7 +513,7 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
         }
         /* exec sdbduser */
         execve(cmd, argv, envp);
-        E("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
+        D("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
         exit(-1);
     } else {
         // Don't set child's OOM adjustment to zero.
@@ -533,14 +532,14 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
         snprintf(tmptext, sizeof tmptext, "/tmp/.sdbduser_%d.sock", (int)(*pid));
         char *sockpath = strdup(tmptext);
         if (sockpath == NULL) {
-            E("failed to get socket path, %d\n", errno);
+            D("failed to get socket path, %d\n", errno);
             return -1;
         }
         D("read fd socket is %s\n", sockpath);
 
         sock = socket(PF_LOCAL, SOCK_STREAM, 0);
         if (sock == -1) {
-            E("socket error, %d\n", errno);
+            D("socket error, %d\n", errno);
             free(sockpath);
             return -1;
         }
@@ -555,9 +554,9 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
             usleep(10000);
         }
         if (trycnt == 100) {
-            E("failed to connect, errno: %d\n", errno);
+            D("failed to connect, errno: %d\n", errno);
             if (sdb_close(sock) == -1) {
-                E("close sock error, %d\n", errno);
+                D("close sock error, %d\n", errno);
             }
             free(sockpath);
             return -1;
@@ -565,9 +564,9 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
 
         char c;
         if (recv_fd(sock, &c, 1, &ptm) == -1) {
-            E("recv_fd error, %d\n", errno);
+            D("recv_fd error, %d\n", errno);
             if (sdb_close(sock) == -1) {
-                E("close sock error, %d\n", errno);
+                D("close sock error, %d\n", errno);
             }
             free(sockpath);
             return -1;
@@ -576,11 +575,11 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
         }
 
         if (sdb_close(sock) == -1) {
-            E("close sock error, %d\n", errno);
+            D("close sock error, %d\n", errno);
         }
         free(sockpath);
 
-        I("getting child's ptm successed.\n");
+        D("getting child's ptm successed.\n");
         return ptm;
     }
 }
@@ -716,13 +715,13 @@ static int create_subproc_thread(const char *name, int lines, int columns)
     char *envp_plugin = NULL;
     envp_plugin = malloc(ENV_BUF_MAX);
     if (envp_plugin == NULL) {
-        E("Cannot allocate the shell commnad buffer.");
+        D("Cannot allocate the shell commnad buffer.");
         return -1;
     }
     memset(envp_plugin, 0, ENV_BUF_MAX);
     if (!request_conversion_to_plugin(PLUGIN_SYNC_CMD_GET_SHELL_ENV, NULL,
                 envp_plugin, ENV_BUF_MAX)) {
-        E("Failed to convert the shell command. (%s)\n", name);
+        D("Failed to convert the shell command. (%s)\n", name);
         free(envp_plugin);
         return -1;
     } else {
@@ -738,7 +737,7 @@ static int create_subproc_thread(const char *name, int lines, int columns)
     if(name) { // in case of shell execution directly
         // Check the shell command validation.
         if (!request_validity_to_plugin(PLUGIN_SYNC_CMD_VERIFY_SHELLCMD, name)) {
-            E("This shell command is invalid. (%s)\n", name);
+            D("This shell command is invalid. (%s)\n", name);
             return -1;
         }
 
@@ -746,13 +745,13 @@ static int create_subproc_thread(const char *name, int lines, int columns)
         char *new_cmd = NULL;
         new_cmd = malloc(SDBD_SHELL_CMD_MAX);
         if(new_cmd == NULL) {
-            E("Cannot allocate the shell commnad buffer.");
+            D("Cannot allocate the shell commnad buffer.");
             return -1;
         }
 
         memset(new_cmd, 0, SDBD_SHELL_CMD_MAX);
         if(!request_conversion_to_plugin(PLUGIN_SYNC_CMD_CONVERT_SHELLCMD, name, new_cmd, SDBD_SHELL_CMD_MAX)) {
-            E("Failed to convert the shell command. (%s)\n", name);
+            D("Failed to convert the shell command. (%s)\n", name);
             free(new_cmd);
             return -1;
         }
@@ -772,7 +771,7 @@ static int create_subproc_thread(const char *name, int lines, int columns)
     } else { // in case of shell interactively
         // Check the capability for interactive shell support.
         if (!is_support_interactive_shell()) {
-            E("This platform dose NOT support the interactive shell\n");
+            D("This platform dose NOT support the interactive shell\n");
             return -1;
         }
 
@@ -816,7 +815,7 @@ static int create_subproc_thread(const char *name, int lines, int columns)
     D("create_subprocess() ret_fd=%d pid=%d\n", ret_fd, pid);
 
     if (ret_fd < 0) {
-        E("cannot create service thread\n");
+        D("cannot create service thread\n");
         return -1;
     }
 
@@ -827,7 +826,7 @@ static int create_subproc_thread(const char *name, int lines, int columns)
         win_sz.ws_col = columns;
 
         if (ioctl(ret_fd, TIOCSWINSZ, &win_sz) < 0) {
-            E("failed to sync window size.\n");
+            D("failed to sync window size.\n");
         }
     }
 
@@ -840,7 +839,7 @@ static int create_subproc_thread(const char *name, int lines, int columns)
     if(sdb_thread_create( &t, service_bootstrap_func, sti)){
         free(sti);
         sdb_close(ret_fd);
-        E("cannot create service thread\n");
+        D("cannot create service thread\n");
         return -1;
     }
 
@@ -854,7 +853,7 @@ static int create_sync_subprocess(void (*func)(int, void *), void* cookie) {
     int s[2];
 
     if(sdb_socketpair(s)) {
-        E("cannot create service socket pair\n");
+        D("cannot create service socket pair\n");
         return -1;
     }
 
@@ -869,10 +868,10 @@ static int create_sync_subprocess(void (*func)(int, void *), void* cookie) {
         // FIXME: do not wait child process hear
         //waitpid(pid, &ret, 0);
     } else {
-        E("- fork failed: errno:%d -\n", errno);
+        D("- fork failed: errno:%d -\n", errno);
         sdb_close(s[0]);
         sdb_close(s[1]);
-        E("cannot create sync service sub process\n");
+        D("cannot create sync service sub process\n");
         return -1;
     }
 
@@ -919,7 +918,7 @@ static void get_platforminfo(int fd, void *cookie) {
     int r = system_info_get_platform_string("http://tizen.org/system/model_name", &value);
     if (r != SYSTEM_INFO_ERROR_NONE) {
         s_strncpy(sysinfo.model_name, UNKNOWN, sizeof(sysinfo.model_name));
-        E("fail to get system model:%d\n", errno);
+        D("fail to get system model:%d\n", errno);
     } else {
         s_strncpy(sysinfo.model_name, value, sizeof(sysinfo.model_name));
         D("returns model_name:%s\n", value);
@@ -931,7 +930,7 @@ static void get_platforminfo(int fd, void *cookie) {
     r = system_info_get_platform_string("http://tizen.org/system/platform.name", &value);
     if (r != SYSTEM_INFO_ERROR_NONE) {
         s_strncpy(sysinfo.platform_name, UNKNOWN, sizeof(sysinfo.platform_name));
-        E("fail to get platform name:%d\n", errno);
+        D("fail to get platform name:%d\n", errno);
     } else {
         s_strncpy(sysinfo.platform_name, value, sizeof(sysinfo.platform_name));
         D("returns platform_name:%s\n", value);
@@ -945,7 +944,7 @@ static void get_platforminfo(int fd, void *cookie) {
     r = system_info_get_platform_string("tizen.org/feature/platform.version", &value);
     if (r != SYSTEM_INFO_ERROR_NONE) {
         s_strncpy(sysinfo.platform_version, UNKNOWN, sizeof(sysinfo.platform_version));
-        E("fail to get platform version:%d\n", errno);
+        D("fail to get platform version:%d\n", errno);
     } else {
         s_strncpy(sysinfo.platform_version, value, sizeof(sysinfo.platform_version));
         D("returns platform_version:%s\n", value);
@@ -957,7 +956,7 @@ static void get_platforminfo(int fd, void *cookie) {
     r = system_info_get_platform_string("tizen.org/feature/profile", &value);
     if (r != SYSTEM_INFO_ERROR_NONE) {
         s_strncpy(sysinfo.profile_name, UNKNOWN, sizeof(sysinfo.profile_name));
-        E("fail to get profile name:%d\n", errno);
+        D("fail to get profile name:%d\n", errno);
     } else {
         s_strncpy(sysinfo.profile_name, value, sizeof(sysinfo.profile_name));
         D("returns profile name:%s\n", value);
@@ -1130,10 +1129,10 @@ static void sync_windowsize(int fd, void *cookie) {
         win_sz.ws_col = columns;
 
         if (ioctl(s->fd, TIOCSWINSZ, &win_sz) < 0) {
-            E("failed to sync window size.\n");
+            D("failed to sync window size.\n");
             return;
         }
-        I("success to sync window size.\n");
+        D("success to sync window size.\n");
     }
 }
 
@@ -1144,11 +1143,11 @@ void get_boot(int fd, void *cookie) {
     int interval = 1000;
     while (time < COMMAND_TIMEOUT) {
         if (booting_done == 1) {
-            I("get_boot:platform booting is done\n");
+            D("get_boot:platform booting is done\n");
             snprintf(buf, sizeof(buf), "%s", "1");
             break;
         }
-        I("get_boot:platform booting is in progress\n");
+        D("get_boot:platform booting is in progress\n");
         sdb_sleep_ms(interval);
         time += interval;
     }
@@ -1323,7 +1322,7 @@ int service_to_fd(const char *name)
 
     if (ret >= 0) {
         if (close_on_exec(ret) < 0) {
-            E("failed to close fd exec\n");
+            D("failed to close fd exec\n");
         }
     }
     return ret;
index ebc7550..12baade 100644 (file)
@@ -23,8 +23,7 @@
 
 #include "sysdeps.h"
 
-//#define  TRACE_TAG  TRACE_SOCKETS
-#define LOG_TAG "SDBD_TRACE_SOCKETS"
+#define  TRACE_TAG  TRACE_SOCKETS
 #include "log.h"
 
 #include "sdb.h"
@@ -157,7 +156,7 @@ static int local_socket_enqueue(asocket *s, apacket *p)
             continue;
         }
         if((r == 0) || (errno != EAGAIN)) {
-            E( "LS(%d): not ready, errno=%d\n", s->id, errno);
+            D( "LS(%d): not ready, errno=%d\n", s->id, errno);
             s->close(s);
             return 1; /* not ready (error) */
         } else {
@@ -263,7 +262,7 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
 {
     asocket *s = _s;
 
-    //D("LS(%d): event_func(fd=%d(==%d), ev=%04x)\n", s->id, s->fd, fd, ev);
+    D("LS(%d): event_func(fd=%d(==%d), ev=%04x)\n", s->id, s->fd, fd, ev);
 
     /* put the FDE_WRITE processing before the FDE_READ
     ** in order to simplify the code.
@@ -334,8 +333,8 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
 
         while (avail > 0) {
             r = sdb_read(fd, x, avail);
-//            D("LS(%d): post sdb_read(fd=%d,...) r=%d (errno=%d) avail=%d\n",
-//              s->id, s->fd, r, r < 0 ? errno : 0, avail);
+            D("LS(%d): post sdb_read(fd=%d,...) r=%d (errno=%d) avail=%d\n",
+              s->id, s->fd, r, r < 0 ? errno : 0, avail);
             if (r > 0 && r <= avail) {
                 avail -= r;
                 x += r;
@@ -350,8 +349,8 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
             is_eof = 1;
             break;
         }
-//        D("LS(%d): fd=%d post avail loop. r=%d is_eof=%d forced_eof=%d\n",
-//          s->id, s->fd, r, is_eof, s->fde.force_eof);
+        D("LS(%d): fd=%d post avail loop. r=%d is_eof=%d forced_eof=%d\n",
+          s->id, s->fd, r, is_eof, s->fde.force_eof);
 
         //변경된 최대 패킷 크기로 코드 수정
         if ((avail == max_payload) || (s->peer == 0)) {
@@ -359,7 +358,7 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
         } else {
             p->len = max_payload >= avail ? max_payload - avail : 0;
             r = s->peer->enqueue(s->peer, p);
-            //D("LS(%d): fd=%d post peer->enqueue(). r=%d\n", s->id, s->fd, r);
+            D("LS(%d): fd=%d post peer->enqueue(). r=%d\n", s->id, s->fd, r);
 
             if(r < 0) {
                     /* error return means they closed us as a side-effect
@@ -394,7 +393,7 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
             ** bytes of readable data.
             */
 //        s->close(s);
-        E("LS(%d): FDE_ERROR (fd=%d)\n", s->id, s->fd);
+        D("LS(%d): FDE_ERROR (fd=%d)\n", s->id, s->fd);
 
         return;
     }
@@ -449,8 +448,8 @@ typedef struct aremotesocket {
 
 static int remote_socket_enqueue(asocket *s, apacket *p)
 {
-//    D("entered remote_socket_enqueue RS(%d) WRITE fd=%d peer.fd=%d\n",
-//      s->id, s->fd, s->peer->fd);
+    D("entered remote_socket_enqueue RS(%d) WRITE fd=%d peer.fd=%d\n",
+      s->id, s->fd, s->peer->fd);
     p->msg.command = A_WRTE;
     p->msg.arg0 = s->peer->id;
     p->msg.arg1 = s->id;
@@ -525,7 +524,7 @@ asocket *create_remote_socket(unsigned id, atransport *t)
 
 void connect_to_remote(asocket *s, const char *destination)
 {
-    //D("Connect_to_remote call RS(%d) fd=%d\n", s->id, s->fd);
+    D("Connect_to_remote call RS(%d) fd=%d\n", s->id, s->fd);
     apacket *p = get_apacket();
     size_t len = strlen(destination) + 1;
 
@@ -533,7 +532,7 @@ void connect_to_remote(asocket *s, const char *destination)
         fatal("destination oversized");
     }
 
-    //D("LS(%d): connect('%s')\n", s->id, destination);
+    D("LS(%d): connect('%s')\n", s->id, destination);
     p->msg.command = A_OPEN;
     p->msg.arg0 = s->id;
     p->msg.data_length = len;
@@ -648,11 +647,11 @@ static int smart_socket_enqueue(asocket *s, apacket *p)
 
     len = unhex(p->data, 4);
     if((len < 1) ||  (len > 1024)) {
-        E("SS(%d): bad size (%d)\n", s->id, len);
+        D("SS(%d): bad size (%d)\n", s->id, len);
         goto fail;
     }
 
-    //D("SS(%d): len is %d\n", s->id, len );
+    D("SS(%d): len is %d\n", s->id, len );
         /* can't do anything until we have the full header */
     if((len + 4) > p->len) {
         D("SS(%d): waiting for %d more bytes\n", s->id, len+4 - p->len);
@@ -661,7 +660,7 @@ static int smart_socket_enqueue(asocket *s, apacket *p)
 
     p->data[len + 4] = 0;
 
-    //D("SS(%d): '%s'\n", s->id, (char*) (p->data + 4));
+    D("SS(%d): '%s'\n", s->id, (char*) (p->data + 4));
 
     if (s->transport == NULL) {
         char* error_string = "unknown failure";
index a5df573..d6ecd66 100644 (file)
@@ -22,8 +22,7 @@
 
 #include "sysdeps.h"
 
-//#define   TRACE_TAG  TRACE_TRANSPORT
-#define LOG_TAG "SDBD_TRACE_TRANSPORT"
+#define   TRACE_TAG  TRACE_TRANSPORT
 #include "log.h"
 
 #include "sdb.h"
@@ -73,7 +72,7 @@ static void  dump_hex( const unsigned char*  ptr, size_t  len )
         *pb++ =  c;
     }
     *pb++ = '\0';
-//    D("%s\n", buffer);
+    DR("%s\n", buffer);
 }
 
 static const char *statename(atransport *t)
@@ -156,7 +155,8 @@ dump_packet(const char* name, const char* func, apacket* p)
     else
         snprintf(arg1, sizeof arg1, "0x%x", p->msg.arg1);
 
-    //D("%s: %s: [%s] arg0=%s arg1=%s (len=%d) ", name, func, cmd, arg0, arg1, len);
+    D("%s: %s: [%s] arg0=%s arg1=%s (len=%d) ",
+        name, func, cmd, arg0, arg1, len);
     dump_hex(p->data, len);
 }
 #endif /* SDB_TRACE */
@@ -178,14 +178,16 @@ read_packet(int  fd, const char* name, apacket** ppacket)
             len -= r;
             p   += r;
         } else {
-            E("%s: read_packet (fd=%d), error ret=%d errno=%d\n", name, fd, r, errno);
+            D("%s: read_packet (fd=%d), error ret=%d errno=%d\n", name, fd, r, errno);
             if((r < 0) && (errno == EINTR)) continue;
             return -1;
         }
     }
 
 #if SDB_TRACE
-    dump_packet(name, "from remote", *ppacket);
+    if (SDB_TRACING) {
+        dump_packet(name, "from remote", *ppacket);
+    }
 #endif
     return 0;
 }
@@ -202,7 +204,9 @@ write_packet(int  fd, const char* name, apacket** ppacket)
     }
 
 #if SDB_TRACE
-    dump_packet(name, "to remote", *ppacket);
+    if (SDB_TRACING) {
+        dump_packet(name, "to remote", *ppacket);
+    }
 #endif
     while(len > 0) {
         r = sdb_write(fd, p, len);
@@ -210,7 +214,7 @@ write_packet(int  fd, const char* name, apacket** ppacket)
             len -= r;
             p += r;
         } else {
-            E("%s: write_packet (fd=%d) error ret=%d errno=%d\n", name, fd, r, errno);
+            D("%s: write_packet (fd=%d) error ret=%d errno=%d\n", name, fd, r, errno);
             if((r < 0) && (errno == EINTR)) continue;
             return -1;
         }
@@ -221,11 +225,11 @@ write_packet(int  fd, const char* name, apacket** ppacket)
 static void transport_socket_events(int fd, unsigned events, void *_t)
 {
     atransport *t = _t;
-    //D("transport_socket_events(fd=%d, events=%04x,...)\n", fd, events);
+    D("transport_socket_events(fd=%d, events=%04x,...)\n", fd, events);
     if(events & FDE_READ){
         apacket *p = 0;
         if(read_packet(fd, t->serial, &p)){
-            E("%s: failed to read packet from transport socket on fd %d\n", t->serial, fd);
+            D("%s: failed to read packet from transport socket on fd %d\n", t->serial, fd);
         } else {
             handle_packet(p, (atransport *) _t);
         }
@@ -251,7 +255,7 @@ void send_packet(apacket *p, atransport *t)
     print_packet("send", p);
 
     if (t == NULL) {
-        E("Transport is null \n");
+        D("Transport is null \n");
         fatal("Transport is null");
     }
 
@@ -287,7 +291,7 @@ static void *output_thread(void *_t)
     p->msg.magic = A_SYNC ^ 0xffffffff;
     if(write_packet(t->fd, t->serial, &p)) {
         put_apacket(p);
-        E("%s: failed to write SYNC packet\n", t->serial);
+        D("%s: failed to write SYNC packet\n", t->serial);
         goto oops;
     }
 
@@ -296,7 +300,8 @@ static void *output_thread(void *_t)
         p = get_apacket();
 
         if(t->read_from_remote(p, t) == 0){
-            //D("%s: received remote packet, sending to transport\n", t->serial);
+            D("%s: received remote packet, sending to transport\n",
+              t->serial);
 
 #ifdef SUPPORT_ENCRYPT
         if (t->encryption == ENCR_ON && p->msg.command != A_ENCR) // 현재 연결이 암호화 모드이고, 암호화 관련 메시지가 아닌 경우, 메시지 복호화
@@ -308,11 +313,11 @@ static void *output_thread(void *_t)
 
             if(write_packet(t->fd, t->serial, &p)){
                 put_apacket(p);
-                E("%s: failed to write apacket to transport\n", t->serial);
+                D("%s: failed to write apacket to transport\n", t->serial);
                 goto oops;
             }
         } else {
-            E("%s: remote read failed for transport\n", t->serial);
+            D("%s: remote read failed for transport\n", t->serial);
             put_apacket(p);
             break;
         }
@@ -326,7 +331,7 @@ static void *output_thread(void *_t)
     p->msg.magic = A_SYNC ^ 0xffffffff;
     if(write_packet(t->fd, t->serial, &p)) {
         put_apacket(p);
-        E("%s: failed to write SYNC apacket to transport", t->serial);
+        D("%s: failed to write SYNC apacket to transport", t->serial);
     }
 
 oops:
@@ -347,7 +352,7 @@ static void *input_thread(void *_t)
 
     for(;;){
         if(read_packet(t->fd, t->serial, &p)) {
-            E("%s: failed to read apacket from transport on fd %d\n",
+            D("%s: failed to read apacket from transport on fd %d\n",
                t->serial, t->fd );
             break;
         }
@@ -374,7 +379,7 @@ static void *input_thread(void *_t)
             }
         } else {
             if(active) {
-                //D("%s: transport got packet, sending to remote, state(%s)\n", t->serial, statename(t));
+                D("%s: transport got packet, sending to remote, state(%s)\n", t->serial, statename(t));
 
 #ifdef SUPPORT_ENCRYPT
         if (t->encryption == ENCR_ON && p->msg.command != A_ENCR) // 현재 연결이 암호화 모드이고, 암호화 관련 메시지가 아닌 경우, 메시지를 암호화
@@ -439,7 +444,7 @@ transport_read_action(int  fd, struct tmsg*  m)
             p   += r;
         } else {
             if((r < 0) && (errno == EINTR)) continue;
-            E("transport_read_action: on fd %d, error %d\n",
+            D("transport_read_action: on fd %d, error %d\n",
               fd, errno);
             return -1;
         }
@@ -461,7 +466,7 @@ transport_write_action(int  fd, struct tmsg*  m)
             p   += r;
         } else {
             if((r < 0) && (errno == EINTR)) continue;
-            E("transport_write_action: on fd %d, error %d\n",
+            D("transport_write_action: on fd %d, error %d\n",
               fd, errno);
             return -1;
         }
@@ -734,7 +739,7 @@ void register_socket_transport(int s, const char *serial, int port, int local, c
 {
     atransport *t = calloc(1, sizeof(atransport));
     if (t == NULL) {
-        E("failed to allocate memory of transport struct\n");
+        D("failed to allocate memory of transport struct\n");
         return;
     }
     char buff[32];
@@ -828,7 +833,7 @@ void register_usb_transport(usb_handle *usb, const char *serial, unsigned writea
     char device_name[256];
     atransport *t = calloc(1, sizeof(atransport));
     if (t == NULL) {
-        E("failed to allocate memory of transport struct\n");
+        D("failed to allocate memory of transport struct\n");
         return;
     }
 
@@ -860,10 +865,8 @@ void unregister_usb_transport(usb_handle *usb)
     sdb_mutex_unlock(&transport_lock);
 }
 
-//#undef TRACE_TAG
-//#define TRACE_TAG  TRACE_RWX
-#undef LOG_TAG
-#define LOG_TAG "SDBD_TRACE_RWX"
+#undef TRACE_TAG
+#define TRACE_TAG  TRACE_RWX
 
 int readx(int fd, void *ptr, size_t len)
 {
@@ -871,7 +874,7 @@ int readx(int fd, void *ptr, size_t len)
     int r;
     int l = len;
 
-    //D("readx: fd=%d wanted=%zu\n", fd, len);
+    D("readx: fd=%d wanted=%zu\n", fd, len);
     while (l > 0) {
         r = sdb_read(fd, p, l);
         if (r > 0 && r <= l) {
@@ -879,18 +882,18 @@ int readx(int fd, void *ptr, size_t len)
             p += r;
         } else {
             if (r < 0) {
-                E("readx: fd=%d error %d\n", fd, errno);
+                D("readx: fd=%d error %d\n", fd, errno);
                 if (errno == EINTR)
                     continue;
             } else {
-                E("readx: fd=%d disconnected\n", fd);
+                D("readx: fd=%d disconnected\n", fd);
             }
             return -1;
         }
     }
 
 #if SDB_TRACE
-    //D("readx: fd=%d wanted=%zu got=%zu\n", fd, len, len - l);
+    D("readx: fd=%d wanted=%zu got=%zu\n", fd, len, len - l);
     dump_hex( ptr, len );
 #endif
     return 0;
@@ -902,7 +905,7 @@ int writex(int fd, const void *ptr, size_t len)
     int r;
 
 #if SDB_TRACE
-    //D("writex: fd=%d len=%zu: ", fd, len);
+    D("writex: fd=%d len=%zu: ", fd, len);
     dump_hex( ptr, len );
 #endif
     while(len > 0) {
@@ -912,11 +915,11 @@ int writex(int fd, const void *ptr, size_t len)
             p += r;
         } else {
             if (r < 0) {
-                E("writex: fd=%d error %d\n", fd, errno);
+                D("writex: fd=%d error %d\n", fd, errno);
                 if (errno == EINTR)
                     continue;
             } else {
-                E("writex: fd=%d disconnected\n", fd);
+                D("writex: fd=%d disconnected\n", fd);
             }
             return -1;
         }
@@ -927,12 +930,12 @@ int writex(int fd, const void *ptr, size_t len)
 int check_header(apacket *p, atransport *t)
 {
     if(p->msg.magic != (p->msg.command ^ 0xffffffff)) {
-        E("check_header(): invalid magic\n");
+        D("check_header(): invalid magic\n");
         return -1;
     }
 
     if(p->msg.data_length > t->max_payload) {
-        E("check_header(): %d > transport->max_payload(%zu)\n", p->msg.data_length, t->max_payload);
+        D("check_header(): %d > transport->max_payload(%zu)\n", p->msg.data_length, t->max_payload);
         return -1;
     }
 
index 16cd7de..20f2747 100644 (file)
@@ -32,8 +32,7 @@
 #include <unistd.h>
 #endif
 
-//#define  TRACE_TAG  TRACE_TRANSPORT
-#define LOG_TAG "SDBD_TRACE_TRANSPORT"
+#define  TRACE_TAG  TRACE_TRANSPORT
 #include "log.h"
 
 #include "sdb.h"
@@ -66,7 +65,7 @@ static pthread_cond_t noti_cond = PTHREAD_COND_INITIALIZER;
 static int remote_read(apacket *p, atransport *t)
 {
     if(readx(t->sfd, &p->msg, sizeof(amessage))){
-        E("remote local: read terminated (message)\n");
+        D("remote local: read terminated (message)\n");
         return -1;
     }
 
@@ -77,17 +76,17 @@ static int remote_read(apacket *p, atransport *t)
       p->msg.command, p->msg.arg0, p->msg.arg1, p->msg.data_length, p->msg.data_check, p->msg.magic);
 #endif
     if(check_header(p, t)) {
-        E("bad header: terminated (data)\n");
+        D("bad header: terminated (data)\n");
         return -1;
     }
 
     if(readx(t->sfd, p->data, p->msg.data_length)){
-        E("remote local: terminated (data)\n");
+        D("remote local: terminated (data)\n");
         return -1;
     }
 
     if(check_data(p)) {
-        E("bad data: terminated (data)\n");
+        D("bad data: terminated (data)\n");
         return -1;
     }
 
@@ -105,7 +104,7 @@ static int remote_write(apacket *p, atransport *t)
       p->msg.command, p->msg.arg0, p->msg.arg1, p->msg.data_length, p->msg.data_check, p->msg.magic);
 #endif
     if(writex(t->sfd, &p->msg, sizeof(amessage) + length)) {
-        E("remote local: write terminated\n");
+        D("remote local: write terminated\n");
         return -1;
     }
 
@@ -129,7 +128,7 @@ int local_connect_arbitrary_ports(int console_port, int sdb_port, const char *de
     if (fd >= 0) {
         D("client: connected on remote on fd %d\n", fd);
         if (close_on_exec(fd) < 0) {
-            E("failed to close fd exec\n");
+            D("failed to close fd exec\n");
         }
         disable_tcp_nagle(fd);
         snprintf(buf, sizeof buf, "%s%d", LOCAL_CLIENT_PREFIX, console_port);
@@ -168,7 +167,7 @@ static void *server_socket_thread(void * arg)
                 continue;
             }
             if (close_on_exec(serverfd) < 0) {
-                E("failed to close serverfd exec\n");
+                D("failed to close serverfd exec\n");
             }
         }
 
@@ -184,7 +183,7 @@ static void *server_socket_thread(void * arg)
         if(fd >= 0) {
             D("server: new connection on fd %d\n", fd);
             if (close_on_exec(fd) < 0) {
-                E("failed to close fd exec\n");
+                D("failed to close fd exec\n");
             }
             disable_tcp_nagle(fd);
 
@@ -220,7 +219,7 @@ static void *server_socket_thread(void * arg)
                 int ret = -1;
                 ret = keep_alive(fd, 1, SDB_KEEPALIVE_CNT, SDB_KEEPALIVE_IDLE, SDB_KEEPALIVE_INTVL);
                 if (ret < 0) {
-                    E("failed to set keep alive option. FD(%d), errno=%d\n", fd, errno);
+                    D("failed to set keep alive option. FD(%d), errno=%d\n", fd, errno);
                 } else {
                     D("Success to set keep alive option. FD(%d), cnt=%d, idle=%d(sec), interval=%d(sec)\n",
                         fd, SDB_KEEPALIVE_CNT, SDB_KEEPALIVE_IDLE, SDB_KEEPALIVE_INTVL);
@@ -229,7 +228,7 @@ static void *server_socket_thread(void * arg)
                 register_socket_transport(fd, "host", port, 1, NULL);
             }
         } else {
-            E("failed to accept() from sdb server\n");
+            D("failed to accept() from sdb server\n");
             //FIXME: implements error handle for EMFILE or ENFILE
         }
     }
@@ -357,7 +356,7 @@ int connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen,
 
     flags = fcntl(sockfd, F_GETFL, 0);
     if(fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) == -1) {
-        E("failed to set file O_NONBLOCK status flag for socket %d: errno:%d\n",
+        D("failed to set file O_NONBLOCK status flag for socket %d: errno:%d\n",
                      sockfd, errno);
     }
 
@@ -388,11 +387,11 @@ int connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen,
         if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
             return (-1); /* Solaris pending error */
     } else
-        E("select error: sockfd not set\n");
+        D("select error: sockfd not set\n");
 
     done:
     if(fcntl(sockfd, F_SETFL, flags) == -1) { /* restore file status flags */
-        E("failed to restore file status flag for socket %d\n",
+        D("failed to restore file status flag for socket %d\n",
                  sockfd);
     }
 
@@ -421,22 +420,22 @@ static int send_msg_to_localhost_from_guest(const char *host_ip, int local_port,
         s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
     }
     if (s < 0) {
-        E("could not create socket\n");
+        D("could not create socket\n");
         return -1;
     }
     ret = connect_nonb(s, (struct sockaddr*) &server, sizeof(server), connect_timeout);
     if (ret < 0) {
-        E("could not connect to server\n");
+        D("could not connect to server\n");
         sdb_close(s);
         return -1;
     }
     if (writex(s, request, strlen(request)) != 0) {
-        E("could not send notification request to host\n");
+        D("could not send notification request to host\n");
         sdb_close(s);
         return -1;
     }
     sdb_close(s);
-    I("sent notification request to host\n");
+    D("sent notification request to host\n");
 
     return 0;
 }
@@ -462,7 +461,7 @@ static void* notify_sdbd_startup_thread(void* ptr) {
         return NULL;
     }
     if (get_emulator_hostip(host_ip, sizeof host_ip) == -1) {
-       E("failed to get emulator host ip\n");
+       D("failed to get emulator host ip\n");
        return NULL;
     }
     // XXX: Known issue - log collision
@@ -482,7 +481,7 @@ static void* notify_sdbd_startup_thread(void* ptr) {
         }
 
         if (get_emulator_guestip(guest_ip, sizeof guest_ip) == -1) {
-            E("failed to get emulator guest ip\n");
+            D("failed to get emulator guest ip\n");
             goto sleep_and_continue;
         }
 
index add5901..471aa87 100644 (file)
@@ -20,8 +20,7 @@
 
 #include <sysdeps.h>
 
-//#define  TRACE_TAG  TRACE_TRANSPORT
-#define LOG_TAG "SDBD_TRACE_TRANSPORT"
+#define  TRACE_TAG  TRACE_TRANSPORT
 #include "log.h"
 
 #include "sdb.h"
@@ -52,26 +51,26 @@ unsigned host_to_le32(unsigned n)
 static int remote_read(apacket *p, atransport *t)
 {
     if(usb_read(t->usb, &p->msg, sizeof(amessage))){
-        E("remote usb: read terminated (message)\n");
+        D("remote usb: read terminated (message)\n");
         return -1;
     }
 
     fix_endians(p);
 
     if(check_header(p, t)) {
-        E("remote usb: check_header failed\n");
+        D("remote usb: check_header failed\n");
         return -1;
     }
 
     if(p->msg.data_length) {
         if(usb_read(t->usb, p->data, p->msg.data_length)){
-            E("remote usb: terminated (data)\n");
+            D("remote usb: terminated (data)\n");
             return -1;
         }
     }
 
     if(check_data(p)) {
-        E("remote usb: check_data failed\n");
+        D("remote usb: check_data failed\n");
         return -1;
     }
 
@@ -85,12 +84,12 @@ static int remote_write(apacket *p, atransport *t)
     fix_endians(p);
 
     if(usb_write(t->usb, &p->msg, sizeof(amessage))) {
-        E("remote usb: 1 - write terminated\n");
+        D("remote usb: 1 - write terminated\n");
         return -1;
     }
     if(p->msg.data_length == 0) return 0;
     if(usb_write(t->usb, &p->data, size)) {
-        E("remote usb: 2 - write terminated\n");
+        D("remote usb: 2 - write terminated\n");
         return -1;
     }
 
index dd9fa65..b33e68f 100644 (file)
@@ -28,8 +28,7 @@
 
 #include "sysdeps.h"
 
-//#define   TRACE_TAG  TRACE_USB
-#define LOG_TAG "SDBD_TRACE_USB"
+#define   TRACE_TAG  TRACE_USB
 #include "log.h"
 
 #include "sdb.h"
@@ -74,7 +73,7 @@ static void init_functionfs(struct usb_handle *h)
     D("OPENING %s\n", h->EP0_NAME);
     h->control = sdb_open(h->EP0_NAME, O_RDWR);
     if (h->control < 0) {
-        E("[ %s: cannot open control endpoint ]\n", h->EP0_NAME);
+        D("[ %s: cannot open control endpoint ]\n", h->EP0_NAME);
         h->control = -errno;
         sdb_mutex_unlock(&h->control_lock);
         goto error;
@@ -84,7 +83,7 @@ static void init_functionfs(struct usb_handle *h)
     D("[ %s: writing descriptors ]\n", h->EP0_NAME);
     ret = sdb_write(h->control, &descriptors, sizeof(descriptors));
     if (ret < 0) {
-        E("[ %s: cannot write descriptors ]\n", h->EP0_NAME);
+        D("[ %s: cannot write descriptors ]\n", h->EP0_NAME);
         sdb_mutex_unlock(&h->control_lock);
         goto error;
     }
@@ -93,7 +92,7 @@ static void init_functionfs(struct usb_handle *h)
     D("[ %s: writing strings ]\n", h->EP0_NAME);
     ret = sdb_write(h->control, &strings, sizeof(strings));
     if(ret < 0) {
-        E("[ %s: cannot write strings ]\n", h->EP0_NAME);
+        D("[ %s: cannot write strings ]\n", h->EP0_NAME);
         sdb_mutex_unlock(&h->control_lock);
         goto error;
     }
@@ -106,7 +105,7 @@ static void init_functionfs(struct usb_handle *h)
     /* open output endpoint */
     D("[ %s: opening ]\n", h->EP_OUT_NAME);
     if ((h->bulk_out = sdb_open(h->EP_OUT_NAME, O_RDWR)) < 0) {
-        E("[ %s: cannot open bulk-out endpoint ]\n", h->EP_OUT_NAME);
+        D("[ %s: cannot open bulk-out endpoint ]\n", h->EP_OUT_NAME);
         h->bulk_out = -errno;
         goto error;
     }
@@ -114,7 +113,7 @@ static void init_functionfs(struct usb_handle *h)
     /* open input endpoint */
     D("[ %s: opening ]\n", h->EP_IN_NAME);
     if ((h->bulk_in = sdb_open(h->EP_IN_NAME, O_RDWR)) < 0) {
-        E("[ %s: cannot open bulk-in endpoint ]\n", h->EP_IN_NAME);
+        D("[ %s: cannot open bulk-in endpoint ]\n", h->EP_IN_NAME);
         h->bulk_in = -errno;
         goto error;
     }
@@ -169,7 +168,7 @@ static void *usb_open_thread(void *x)
     }
 
     if (usb->control < 0 || usb->bulk_in < 0 || usb->bulk_out < 0) {
-        E("[ opening device failed ]\n");
+        D("[ opening device failed ]\n");
         return (void *)-1;
     }
 
@@ -468,7 +467,7 @@ int ffs_usb_write(usb_handle *h, const void *data, int len)
 
     n = bulk_write(h->bulk_in, data, len);
     if(n != len) {
-        E("ERROR: fd = %d, n = %d, errno = %d\n",
+        D("ERROR: fd = %d, n = %d, errno = %d\n",
             h->bulk_in, n, errno);
         return -1;
     }
@@ -489,7 +488,7 @@ int ffs_usb_read(usb_handle *h, void *data, size_t len)
 
     n = bulk_read(h->bulk_out, data, len);
     if(n != len) {
-        E("ERROR: fd = %d, n = %d, errno = %d\n",
+        D("ERROR: fd = %d, n = %d, errno = %d\n",
             h->bulk_out, n, errno);
         return -1;
     }
index 7cfe9ee..0d8f2be 100644 (file)
@@ -38,8 +38,7 @@
 
 #include "sysdeps.h"
 
-//#define   TRACE_TAG  TRACE_USB
-#define LOG_TAG "SDBD_TRACE_USB"
+#define   TRACE_TAG  TRACE_USB
 #include "log.h"
 
 #include "sdb.h"
@@ -181,7 +180,7 @@ static void find_usb_device(const char *base,
 
                 // should have device and configuration descriptors, and atleast two endpoints
             if (desclength < USB_DT_DEVICE_SIZE + USB_DT_CONFIG_SIZE) {
-                E("desclength %d is too small\n", desclength);
+                D("desclength %d is too small\n", desclength);
                 sdb_close(fd);
                 continue;
             }
@@ -210,7 +209,7 @@ static void find_usb_device(const char *base,
 
             bufptr += USB_DT_CONFIG_SIZE;
             if (config->bLength != USB_DT_CONFIG_SIZE || config->bDescriptorType != USB_DT_CONFIG) {
-                E("usb_config_descriptor not found\n");
+                D("usb_config_descriptor not found\n");
                 sdb_close(fd);
                 continue;
             }
@@ -225,7 +224,7 @@ static void find_usb_device(const char *base,
                     bufptr += length;
 
                     if (length != USB_DT_INTERFACE_SIZE) {
-                        E("interface descriptor has wrong size\n");
+                        D("interface descriptor has wrong size\n");
                         break;
                     }
 
@@ -238,7 +237,7 @@ static void find_usb_device(const char *base,
                             is_sdb_interface(vid, pid, interface->bInterfaceClass,
                             interface->bInterfaceSubClass, interface->bInterfaceProtocol))  {
 
-                        I("looking for bulk endpoints\n");
+                        D("looking for bulk endpoints\n");
                             // looks like SDB...
                         ep1 = (struct usb_endpoint_descriptor *)bufptr;
                         bufptr += USB_DT_ENDPOINT_SIZE;
@@ -250,14 +249,14 @@ static void find_usb_device(const char *base,
                             ep1->bDescriptorType != USB_DT_ENDPOINT ||
                             ep2->bLength != USB_DT_ENDPOINT_SIZE ||
                             ep2->bDescriptorType != USB_DT_ENDPOINT) {
-                            I("endpoints not found\n");
+                            D("endpoints not found\n");
                             break;
                         }
 
                             // both endpoints should be bulk
                         if (ep1->bmAttributes != USB_ENDPOINT_XFER_BULK ||
                             ep2->bmAttributes != USB_ENDPOINT_XFER_BULK) {
-                            I("bulk endpoints not found\n");
+                            D("bulk endpoints not found\n");
                             continue;
                         }
                             /* aproto 01 needs 0 termination */
@@ -308,7 +307,7 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len)
     urb->buffer = (void*) data;
     urb->buffer_length = len;
 
-    I("++ write ++\n");
+    D("++ write ++\n");
 
     sdb_mutex_lock(&h->lock);
     if(h->dead) {
@@ -343,7 +342,7 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len)
     }
 fail:
     sdb_mutex_unlock(&h->lock);
-    I("-- write --\n");
+    D("-- write --\n");
     return res;
 }
 
@@ -376,7 +375,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len)
 
     h->urb_in_busy = 1;
     for(;;) {
-        I("[ reap urb - wait ]\n");
+        D("[ reap urb - wait ]\n");
         h->reaper_thread = pthread_self();
         sdb_mutex_unlock(&h->lock);
         res = ioctl(h->desc, USBDEVFS_REAPURB, &out);
@@ -391,7 +390,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len)
             if(saved_errno == EINTR) {
                 continue;
             }
-            E("[ reap urb - error ]\n");
+            D("[ reap urb - error ]\n");
             break;
         }
         D("[ urb @%p status = %d, actual = %d ]\n",
@@ -408,7 +407,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len)
             break;
         }
         if(out == &h->urb_out) {
-            I("[ reap urb - OUT compelete ]\n");
+            D("[ reap urb - OUT compelete ]\n");
             h->urb_out_busy = 0;
             sdb_cond_broadcast(&h->notify);
         }
@@ -440,7 +439,7 @@ int usb_write(usb_handle *h, const void *_data, int len)
 
         n = usb_bulk_write(h, data, xfer);
         if(n != xfer) {
-            E("ERROR: n = %d, errno = %d\n",
+            D("ERROR: n = %d, errno = %d\n",
                 n, errno);
             return -1;
         }
@@ -462,7 +461,7 @@ int usb_read(usb_handle *h, void *_data, size_t len)
     unsigned char *data = (unsigned char*) _data;
     int n;
 
-    I("++ usb_read ++\n");
+    D("++ usb_read ++\n");
     while(len > 0) {
         int xfer = (len > 4096) ? 4096 : len;
 
@@ -471,14 +470,14 @@ int usb_read(usb_handle *h, void *_data, size_t len)
         D("[ usb read %d ] = %d, fname=%s\n", xfer, n, h->fname);
         if(n != xfer) {
             if((errno == ETIMEDOUT) && (h->desc != -1)) {
-                I("[ timeout ]\n");
+                D("[ timeout ]\n");
                 if(n > 0){
                     data += n;
                     len -= n;
                 }
                 continue;
             }
-            E("ERROR: n = %d, errno = %d \n",
+            D("ERROR: n = %d, errno = %d \n",
                 n, errno);
             return -1;
         }
@@ -487,7 +486,7 @@ int usb_read(usb_handle *h, void *_data, size_t len)
         data += xfer;
     }
 
-    I("-- usb_read --\n");
+    D("-- usb_read --\n");
     return 0;
 }
 
@@ -528,7 +527,7 @@ void usb_kick(usb_handle *h)
 
 int usb_close(usb_handle *h)
 {
-    I("[ usb close ... ]\n");
+    D("[ usb close ... ]\n");
     sdb_mutex_lock(&usb_lock);
     h->next->prev = h->prev;
     h->prev->next = h->next;
@@ -596,7 +595,7 @@ static void register_device(const char *dev_name,
         /* tizen specific */
         n = ioctl(usb->desc, USBDEVFS_RESET);
         if(n != 0) {
-            E("[ usb reset failed %s fd = %d]\n", usb->fname, usb->desc);
+            D("[ usb reset failed %s fd = %d]\n", usb->fname, usb->desc);
             goto fail;
         }
         n = ioctl(usb->desc, USBDEVFS_SETCONFIGURATION, &bConfigurationValue);
@@ -607,7 +606,7 @@ static void register_device(const char *dev_name,
 
         n = ioctl(usb->desc, USBDEVFS_CLAIMINTERFACE, &interface);
         if(n != 0) {
-            E("[ usb claim failed %s fd = %d]\n", usb->fname, usb->desc);
+            D("[ usb claim failed %s fd = %d]\n", usb->fname, usb->desc);
             goto fail;
         }
     }
@@ -675,7 +674,7 @@ static void register_device(const char *dev_name,
     return;
 
 fail:
-    E("[ usb open %s error=%d]\n",
+    D("[ usb open %s error=%d]\n",
         usb->fname,  errno);
     if(usb->desc >= 0) {
         sdb_close(usb->desc);
@@ -685,7 +684,7 @@ fail:
 
 void* device_poll_thread(void* unused)
 {
-    I("Created device thread\n");
+    D("Created device thread\n");
     for(;;) {
             /* XXX use inotify */
         find_usb_device("/dev/bus/usb", register_device);
index da86cd2..a4840c9 100644 (file)
@@ -26,8 +26,7 @@
 
 #include "sysdeps.h"
 
-//#define   TRACE_TAG  TRACE_USB
-#define LOG_TAG "SDBD_TRACE_USB"
+#define   TRACE_TAG  TRACE_USB
 #include "log.h"
 
 #include "sdb.h"
@@ -59,20 +58,20 @@ static void *usb_open_thread(void *x)
             if (fd < 0) {
                 // to support older kernels
                 //fd = unix_open("/dev/android", O_RDWR);
-                E("[ opening %s device failed ]\n", USB_NODE_FILE);
+                D("[ opening %s device failed ]\n", USB_NODE_FILE);
             }
             if (fd < 0) {
                 sdb_sleep_ms(1000);
             }
         } while (fd < 0);
-        //D("[ opening device succeeded ]\n");
+        D("[ opening device succeeded ]\n");
 
         if (close_on_exec(fd) < 0) {
-            E("[closing fd exec failed ]\n");
+            D("[closing fd exec failed ]\n");
         }
         usb->fd = fd;
 
-        //D("[ usb_thread - registering device ]\n");
+        D("[ usb_thread - registering device ]\n");
         register_usb_transport(usb, 0, 1);
     }
 
@@ -86,20 +85,20 @@ int linux_usb_write(usb_handle *h, const void *data, int len)
 {
     int n;
 
-    //D("about to write (fd=%d, len=%d)\n", h->fd, len);
+    D("about to write (fd=%d, len=%d)\n", h->fd, len);
     n = sdb_write(h->fd, data, len);
     if(n != len) {
-        E("ERROR: fd = %d, n = %d, errno = %d\n",
+        D("ERROR: fd = %d, n = %d, errno = %d\n",
             h->fd, n, errno);
         return -1;
     }
-    //D("[ done fd=%d ]\n", h->fd);
+    D("[ done fd=%d ]\n", h->fd);
     return 0;
 }
 
 int linux_usb_read(usb_handle *h, void *data, size_t len)
 {
-    //D("about to read (fd=%d, len=%zu)\n", h->fd, len);
+    D("about to read (fd=%d, len=%zu)\n", h->fd, len);
     int l = len;
     while (l > 0) {
         /* The sdb_read does not support read larger than 4096 bytes at once.
@@ -110,14 +109,14 @@ int linux_usb_read(usb_handle *h, void *data, size_t len)
             if (errno == EINTR) {
                 continue;
             } else {
-                E("ERROR: fd = %d, n = %d, errno = %d\n", h->fd, n, errno);
+                D("ERROR: fd = %d, n = %d, errno = %d\n", h->fd, n, errno);
                 return -1;
             }
         }
         l = (l >= n) ? l - n : 0;
         data = ((char*)data) + n;
     }
-    //D("[ done fd=%d ]\n", h->fd);
+    D("[ done fd=%d ]\n", h->fd);
     return 0;
 }
 
@@ -129,7 +128,7 @@ void linux_usb_init()
 
     h = calloc(1, sizeof(usb_handle));
     if (h == NULL) {
-        E("failed to allocate memory of usb_handle\n");
+        D("failed to allocate memory of usb_handle\n");
         return;
     }
 
@@ -145,12 +144,12 @@ void linux_usb_init()
 #if 0 /* tizen specific */
     fd = unix_open("/dev/android_sdb_enable", O_RDWR);
     if (fd < 0) {
-       E("failed to open /dev/android_sdb_enable\n");
+       D("failed to open /dev/android_sdb_enable\n");
     } else {
         close_on_exec(fd);
     }
 #endif
-    I("[ usb_init - starting thread ]\n");
+    D("[ usb_init - starting thread ]\n");
     if(sdb_thread_create(&tid, usb_open_thread, h)){
         fatal_errno("cannot create usb thread");
     }
@@ -158,7 +157,7 @@ void linux_usb_init()
 
 void linux_usb_kick(usb_handle *h)
 {
-    I("usb_kick\n");
+    D("usb_kick\n");
     sdb_mutex_lock(&h->lock);
     sdb_close(h->fd);
     h->fd = -1;