Revert "Revert "Changed logging to dlog"" 70/187470/2
authorAdhavan M <adhavan.m@samsung.com>
Thu, 23 Aug 2018 11:34:36 +0000 (11:34 +0000)
committerManish Rathod <manish.r@samsung.com>
Thu, 23 Aug 2018 11:35:41 +0000 (11:35 +0000)
This reverts commit 982b42f4d4a19ffce9f55389ad0c3e90828cb4bd.

Change-Id: I09200a5850632c531a81c8391f3b2ad5ebeedf64

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 5e8629aa938b96de6f16e0a5c1c1f1357cc2563f..1c7204d86be03cf06e5b07b0b0be40cdf945dbf7 100755 (executable)
@@ -20,7 +20,8 @@
 #include <string.h>
 #include <errno.h>
 
-#define TRACE_TAG  TRACE_APPCMD
+//#define TRACE_TAG  TRACE_APPCMD
+#define LOG_TAG "SDBD_TRACE_APPCMD"
 
 #include "sysdeps.h"
 #include "sdb.h"
@@ -68,7 +69,7 @@ static int appcmd_install_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 5) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -121,7 +122,7 @@ static int appcmd_uninstall_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -145,7 +146,7 @@ static int appcmd_runapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -180,7 +181,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) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -217,7 +218,7 @@ static int appcmd_killapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -241,7 +242,7 @@ static int appcmd_packagelist_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -265,7 +266,7 @@ static int appcmd_debugwebapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -293,7 +294,7 @@ static int appcmd_debugnativeapp_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 5) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -341,7 +342,7 @@ static int appcmd_appinfo_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -572,7 +573,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) {
-        D("cannot create service thread\n");
+        E("cannot create service thread\n");
         return -1;
     }
     D("create_subprocess() ptm_fd=%d pid=%d\n", ptm_fd, pid);
@@ -613,37 +614,37 @@ static int get_pkg_info(char* pkgid, char* pkginfo_buf, int buf_size) {
 
     ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
     if (ret < 0) {
-        D("failed to get pkginfo handle.\n");
+        E("failed to get pkginfo handle.\n");
         return -1;
     }
 
     ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &pkgname);
     if (ret < 0) {
-        D("failed to get pkg name\n");
+        E("failed to get pkg name\n");
         return -1;
     }
 
     ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
     if (ret < 0) {
-        D("failed to get pkg type.\n");
+        E("failed to get pkg type.\n");
         return -1;
     }
 
     ret = pkgmgrinfo_pkginfo_is_removable(handle, &is_removable);
     if (ret < 0) {
-        D("failed to get removable info.\n");
+        E("failed to get removable info.\n");
         return -1;
     }
 
     pc = pkgmgr_client_new(PC_REQUEST);
     if (pc == NULL) {
-        D("failed to create pkgmgr client.\n");
+        E("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) {
-        D("failed to get running state.\n");
+        E("failed to get running state.\n");
         return -1;
     }
     is_running = ((pid > 0) ? 1:0);
@@ -662,7 +663,7 @@ static void run_appcmd_packageinfo(appcmd_info* p_info) {
     p_info->exitcode = -1;
 
     if (p_info->args_cnt != 3) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return;
     }
 
@@ -678,7 +679,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 {
-                       D("failed to get pkginfo.\n");
+                       E("failed to get pkginfo.\n");
                }
 
                free(type);
@@ -698,7 +699,7 @@ static int appcmd_packageinfo_gen_shellcmd(appcmd_info* p_info) {
     int len = sizeof(p_info->shell_cmd);
 
     if (p_info->args_cnt != 2) {
-        D("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
+        E("failed to parse appcmd.(cnt=%zu)\n", p_info->args_cnt);
         return -1;
     }
 
@@ -769,7 +770,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 {
-        D("failed to get application install path from tzplatform_getenv.");
+        E("failed to get application install path from tzplatform_getenv.");
     }
 }
 
@@ -777,25 +778,25 @@ static void run_appcmd_with_shell_process(appcmd_info* p_info) {
     int ret = -1;
 
     if (p_info == NULL) {
-        D("Invalid arguments. p_info is null\n");
+        E("Invalid arguments. p_info is null\n");
         return;
     }
 
     if (p_info->gen_cmd_func == NULL) {
-        D("Invalid arguments.\n");
+        E("Invalid arguments.\n");
         p_info->exitcode = -1;
         return;
     }
 
     ret = p_info->gen_cmd_func(p_info);
     if (ret < 0) {
-        D("failed to generate install shell command.\n");
+        E("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) {
-            D("failed to run shell process\n");
+            E("failed to run shell process\n");
             p_info->exitcode = -1;
         }
     }
@@ -823,7 +824,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) {
-        D("failed to parse appcmd for install. (%s)\n", command);
+        E("failed to parse appcmd for install. (%s)\n", command);
         info.exitcode = -1;
         goto appcmd_done;
     }
@@ -885,7 +886,7 @@ int appcmd_service( parameters* in, int out_fd ) {
         info.gen_cmd_func = appcmd_debugnativeapp_gen_shellcmd;
         run_appcmd_with_shell_process(&info);
     } else {
-        D("not supported appcmd service. (%s)\n", service_name);
+        E("not supported appcmd service. (%s)\n", service_name);
         info.exitcode = -1;
         goto appcmd_done;
     }
index 5021827766f030c35d696a92bec5e2271287d1bb..0a9ecd0a19277760a43fc2cb016f08ca6d6e4996 100644 (file)
@@ -16,7 +16,8 @@
 
 #include <stdlib.h>
 
-#define TRACE_TAG TRACE_SDB
+//#define TRACE_TAG TRACE_SDB
+#define LOG_TAG "SDBD_TRACE_SDB"
 #include "log.h"
 
 #include "parameter.h"
 int auth_support ( parameters* in, parameters* out )
 {
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
index 8a180a15922ac3b7c2718d7f7404fbf86eacbe74..80f82c219419f8604da720707787a1dde001fb0f 100644 (file)
@@ -22,7 +22,8 @@
 
 #include <tzplatform_config.h>
 
-#define TRACE_TAG TRACE_SDB
+//#define TRACE_TAG TRACE_SDB
+#define LOG_TAG "SDBD_TRACE_SDB"
 #include "log.h"
 
 #include "sdb.h"
@@ -38,19 +39,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 ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
 
@@ -105,12 +106,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 ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -119,7 +120,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -132,12 +133,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 ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -146,7 +147,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
 
@@ -158,12 +159,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 ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -172,7 +173,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -211,14 +212,14 @@ int verify_peer_ipv6 ( parameters* in, parameters* out )
 int verify_sdbd_launch ( parameters* in, parameters* out )
 {
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -231,12 +232,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 ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
@@ -245,7 +246,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
@@ -262,14 +263,14 @@ int verify_root_cmd ( parameters* in, parameters* out )
 int get_shell_env ( parameters* in, parameters* out )
 {
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
 
@@ -281,19 +282,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 ) {
-        D ( "Invalid argument\n" );
+        E ( "Invalid argument\n" );
         return PLUGIN_CMD_FAIL;
     }
 
     if ( out == NULL ) {
-        D ( "Invalid argument\n" );
+        E ( "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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return PLUGIN_CMD_FAIL;
     }
     out->array_of_parameter[0].type = type_int32;
index 26c5ac4a74c99af7c3dde839a512ecdf06b5712f..d36b33aeb5eddbf23fb8b184ce4ab9ff0b69cee7 100644 (file)
@@ -1,7 +1,8 @@
 #include <linux/usb/ch9.h>
 #include <linux/usb/functionfs.h>
 
-#define   TRACE_TAG  TRACE_USB
+//#define   TRACE_TAG  TRACE_USB
+#define LOG_TAG "SDBD_TRACE_USB"
 
 #define MAX_PACKET_SIZE_FS     64
 #define MAX_PACKET_SIZE_HS     512
index ec03f03903a337838526e38b256699cef760b0a5..fc9056e15933fdb227076955746de51a469fdb3d 100644 (file)
@@ -30,7 +30,8 @@
 #include <sys/smack.h>
 #include <tzplatform_config.h>
 
-#define TRACE_TAG  TRACE_SYNC
+//#define TRACE_TAG  TRACE_SYNC
+#define LOG_TAG "SDBD_TRACE_SYNC"
 #include "log.h"
 
 #include "sdb.h"
@@ -154,7 +155,7 @@ static int mkdirs(int noti_fd, char *name)
             sync_send_label_notify(noti_fd, name, 1);
         }
         if((ret < 0) && (errno != EEXIST)) {
-            D("mkdir(\"%s\") -> errno:%d\n", name, errno);
+            E("mkdir(\"%s\") -> errno:%d\n", name, errno);
             *x = '/';
             return ret;
         }
@@ -208,7 +209,7 @@ static int do_list(int s, const char *path)
 
     d = opendir(path);
     if(d == NULL) {
-        D("failed to open dir due to: errno:%d\n", errno);
+        E("failed to open dir due to: errno:%d\n", errno);
         goto done;
     }
 
@@ -252,7 +253,7 @@ static int fail_message(int s, const char *reason)
     syncmsg msg;
     size_t len = strlen(reason);
 
-    D("sync: failure: %s\n", reason);
+    E("sync: failure: %s\n", reason);
 
     msg.data.id = ID_FAIL;
     msg.data.size = htoll(len);
@@ -284,7 +285,7 @@ static int fail_errno(int fd, int err_no)
 
 static void sync_mediadb(char *path) {
     if (access(CMD_MEDIADB_UPDATE, F_OK) != 0) {
-        D("%s: command not found\n", CMD_MEDIADB_UPDATE);
+        E("%s: command not found\n", CMD_MEDIADB_UPDATE);
         return;
     }
 
@@ -347,7 +348,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)) {
-            D("read failed due to unknown reason\n");
+            E("read failed due to unknown reason\n");
             goto fail;
         }
 
@@ -377,7 +378,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 {
-        D("sync error: %d!!!\n", fd);
+        E("sync error: %d!!!\n", fd);
         return -1;
     }
     sync_send_label_notify(noti_fd, path, 1);
@@ -579,7 +580,7 @@ void file_sync_service(int fd, void *cookie)
     int s[2];
 
     if(sdb_socketpair(s)) {
-        D("cannot create service socket pair\n");
+        E("cannot create service socket pair\n");
         exit(-1);
     }
 
@@ -616,7 +617,7 @@ void file_sync_service(int fd, void *cookie)
 
             rv = select(fd + 1, &set, NULL, NULL, &timeout);
             if (rv == -1) {
-                D("sync file descriptor select failed\n");
+                E("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");
@@ -671,7 +672,7 @@ fail:
         sdb_close(s[1]);
     }
 
-    D("sync: done\n");
+    I("sync: done\n");
     sync_send_label_notify(s[0], name, 0);
     sdb_close(s[0]);
     sdb_close(fd);
index e7aff88cdcadf7be3c89338be16aaac5ea11080e..3b95ada40e676cbed7da03560dcb937219f8d2d5 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -18,6 +18,7 @@
 #define __LOG_H
 
 #include <errno.h>
+#include <dlog.h>
 
 #include "sysdeps.h"
 
@@ -62,10 +63,14 @@ 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(...)                                      \
+
+#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(...)                                      \
         do {                                           \
             if (SDB_TRACING) {                         \
                 sdb_mutex_lock(&D_lock);               \
@@ -89,7 +94,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 2e257fe225a9679eebd8c86e34d7a46b7e2fb540..96956b70dcda17aef2977ab6e125373a699dec6f 100644 (file)
@@ -17,7 +17,8 @@
 #include <string.h>
 #include <dlfcn.h>
 
-#define TRACE_TAG TRACE_SDB
+//#define TRACE_TAG TRACE_SDB
+#define LOG_TAG "SDBD_TRACE_SDB"
 #include "log.h"
 
 #include "sdb.h"
@@ -76,7 +77,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 {
-        D ("hashtable is not created\n");
+        I ("hashtable is not created\n");
     }
     return 0;
 }
@@ -91,13 +92,13 @@ static int load_plugin_not_default()
 
     g_plugin_handle = dlopen ( PLUGIN_PATH, RTLD_NOW );
     if ( g_plugin_handle == NULL ) {
-        D ( "failed to dlopen(%s). error: %s\n", PLUGIN_PATH, dlerror() );
+        E ( "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 ) {
-        D ( "failed to get the sdbd plugin init function. error: %s\n", dlerror() );
+        E ( "failed to get the sdbd plugin init function. error: %s\n", dlerror() );
         dlclose ( g_plugin_handle );
         g_plugin_handle = NULL;
         return 0;
@@ -131,7 +132,7 @@ void load_sdbd_plugin()
         plugin_sync_proc = default_plugin_sync_proc;
         plugin_async_proc = default_plugin_async_proc;
 
-        D ( "using default plugin interface.\n" );
+        I ( "using default plugin interface.\n" );
     } else {
         D ( "using sdbd plugin interface.(%s)\n", PLUGIN_PATH );
 
@@ -234,7 +235,7 @@ static int create_async_proc_thread( int cmd, parameters* in )
     if (sdb_socketpair(s)) {
         release_parameters(in);
         free(in);
-        D("cannot create async proc socket pair\n");
+        E("cannot create async proc socket pair\n");
         return -1;
     }
 
@@ -256,7 +257,7 @@ static int create_async_proc_thread( int cmd, parameters* in )
         sdb_close(s[1]);
         release_parameters(in);
         free(in);
-        D("cannot create async proc thread\n");
+        E("cannot create async proc thread\n");
         return -1;
     }
 
@@ -275,7 +276,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -346,7 +347,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) {
-            D("failed to allocate memory for the parameter\n");
+            E("failed to allocate memory for the parameter\n");
             return success;
         }
         in.array_of_parameter[0].type = type_string;
@@ -381,7 +382,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return result;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -413,7 +414,7 @@ int request_appcmd_to_plugin ( const char* in_buf )
 
     in = (parameters*)malloc(sizeof(parameters));
     if (in == NULL) {
-        D("failed to allocate memory for the parameters\n");
+        E("failed to allocate memory for the parameters\n");
         return -1;
     }
 
@@ -422,7 +423,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);
-            D("failed to allocate memory for the parameter\n");
+            E("failed to allocate memory for the parameter\n");
             return -1;
         }
         in->array_of_parameter[0].type = type_string;
index 8bd9b9dbd488cb92fa8b470efb5f1411bdacf267..7ed53f17e320e5930f9c0f26f49175ceec4b98b4 100644 (file)
@@ -3,7 +3,8 @@
 
 //#define LOG_TAG "SDBD"
 //#include <dlog.h>
-#define TRACE_TAG TRACE_SDB
+//#define TRACE_TAG TRACE_SDB
+#define LOG_TAG "SDBD_TRACE_SDB"
 #include "log.h"
 
 #include "plugin.h"
@@ -66,7 +67,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -93,7 +94,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -125,7 +126,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -154,7 +155,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -186,7 +187,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -215,7 +216,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
@@ -249,7 +250,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) {
-        D("failed to allocate memory for the parameter\n");
+        E("failed to allocate memory for the parameter\n");
         return success;
     }
     in.array_of_parameter[0].type = type_int32;
index b4c3e61dd209d28a29b04617cfb8f495b3812b28..38a6b21ae2a62294e02cb4af79e12d8aca429958 100644 (file)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 
-#define  TRACE_TAG   TRACE_SDB
+//#define  TRACE_TAG   TRACE_SDB
+#define LOG_TAG "SDBD_TRACE_SDB"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -180,7 +181,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) {
-        D("failed to get container information: %d\n", errno);
+        E("failed to get container information: %d\n", errno);
         return 0;
     } else {
         D("tizen container: %d\n", value);
@@ -234,7 +235,7 @@ static char* get_sdb_log_conf(const char* key)
 
     fd = unix_open(SDB_LOGCONF_PATH, O_RDONLY);
     if (fd < 0) {
-        D("failed to open '%s' file: %d\n", SDB_LOGCONF_PATH, errno);
+        E("failed to open '%s' file: %d\n", SDB_LOGCONF_PATH, errno);
         return NULL;
     }
 
@@ -383,12 +384,12 @@ void put_apacket(apacket *p)
 
 void handle_online(void)
 {
-    D("sdb: online\n");
+    I("sdb: online\n");
 }
 
 void handle_offline(atransport *t)
 {
-    D("sdb: offline\n");
+    I("sdb: offline\n");
     //Close the associated usb
     run_transport_disconnects(t);
 }
@@ -466,10 +467,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 메시지 파싱
-                D("security_parse_server_hello success\n");
+                I("security_parse_server_hello success\n");
                 enc_p = get_apacket();
                 if(security_gen_client_hello(t->sessionID, enc_p) == 1){ // hello 메시지 생성
-                    D("security_gen_client_hello success\n");
+                    I("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;
@@ -477,7 +478,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                     send_packet(enc_p, t);
                 }
                 else { // hello 메시지 생성 실패
-                    D("security_gen_client_hello error\n");
+                    E("security_gen_client_hello error\n");
                     send_encr_fail(p, t, ENCR_ON_FAIL); // 암호화 on 실패 메시지 전송
                     t->encryption = ENCR_OFF; // 암호화 모드는 off
                     security_deinit(t->sessionID);
@@ -485,7 +486,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                 }
             }
             else{ // hello 메시지 파싱 실패
-                D("security_parse_server_hello error\n");
+                E("security_parse_server_hello error\n");
                 send_encr_fail(p, t, ENCR_ON_FAIL);
                 t->encryption = ENCR_OFF;
                 security_deinit(t->sessionID);
@@ -493,7 +494,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                 return -1;
             }
         } else { // init 실패
-            D("security_init error\n");
+            E("security_init error\n");
             send_encr_fail(p, t, ENCR_ON_FAIL);
             t->encryption = ENCR_OFF;
             if (retVal == 0)
@@ -508,7 +509,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 메시지 생성
-                D("security_gen_client_ack success\n");
+                I("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;
@@ -516,7 +517,7 @@ int handle_encr_packet(apacket* p, atransport *t){
                 send_packet(enc_p, t);
             }
             else { // ack 메시지 생성에 실패한 경우
-                D("security_gen_client_ack error\n");
+                E("security_gen_client_ack error\n");
                 send_encr_fail(p, t, ENCR_ON_FAIL);
                 t->encryption = ENCR_OFF;
                 security_deinit(t->sessionID);
@@ -524,7 +525,7 @@ int handle_encr_packet(apacket* p, atransport *t){
             }
         }
         else { // ack 메시지 파싱에 실패한 경우
-            D("security_parse_server_ack error\n");
+            E("security_parse_server_ack error\n");
             send_encr_fail(p, t, ENCR_ON_FAIL);
             t->encryption = ENCR_OFF;
             security_deinit(t->sessionID);
@@ -541,7 +542,7 @@ int handle_encr_packet(apacket* p, atransport *t){
             send_packet(enc_p, t);
         }
         else { // 암호화 모드 off에 실패한 경우
-            D("security_deinit error\n");
+            E("security_deinit error\n");
             send_encr_fail(p, t, ENCR_OFF_FAIL); // 암호화 모드 off 실패 메시지 전송
             return -1;
         }
@@ -563,12 +564,12 @@ int handle_encr_packet(apacket* p, atransport *t){
     else if (p->msg.arg0 == ENCR_ON_FAIL) // 암호화 모드를 on 하는 도중 실패한 경우 받는 메시지
     {
         t->encryption = ENCR_OFF; // 암호화 모드를 다시 off
-        D("encryption on failed\n");
+        E("encryption on failed\n");
     }
     else if (p->msg.arg0 == ENCR_OFF_FAIL) // 암호화 모드를 off하는 도중 실패한 경우 받는 메시지
     {
         //t->encryption = ENCR_ON;
-        D("encryption off failed\n");
+        E("encryption off failed\n");
     }
     //put_apacket(enc_p);
     return 0;
@@ -579,7 +580,7 @@ int handle_encr_packet(apacket* p, atransport *t){
 
 static void send_ready(unsigned local, unsigned remote, atransport *t)
 {
-    D("Calling send_ready \n");
+    I("Calling send_ready \n");
     apacket *p = get_apacket();
     p->msg.command = A_OKAY;
     p->msg.arg0 = local;
@@ -589,7 +590,7 @@ static void send_ready(unsigned local, unsigned remote, atransport *t)
 
 static void send_close(unsigned local, unsigned remote, atransport *t)
 {
-    D("Calling send_close \n");
+    I("Calling send_close \n");
     apacket *p = get_apacket();
     p->msg.command = A_CLSE;
     p->msg.arg0 = local;
@@ -599,7 +600,7 @@ static void send_close(unsigned local, unsigned remote, atransport *t)
 
 static void send_connect(atransport *t)
 {
-    D("Calling send_connect \n");
+    I("Calling send_connect \n");
     apacket *cp = get_apacket();
     cp->msg.command = A_CNXN;
     cp->msg.arg0 = A_VERSION;
@@ -635,7 +636,7 @@ static void send_connect(atransport *t)
 
 void send_device_status()
 {
-    D("broadcast device status\n");
+    I("broadcast device status\n");
     apacket* cp = get_apacket();
     cp->msg.command = A_STAT;
     cp->msg.arg0 = is_pwlocked;
@@ -679,7 +680,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) {
-        D("buffer size(%d) should be bigger than %d\n", str_size, len+1);
+        E("buffer size(%d) should be bigger than %d\n", str_size, len+1);
         return -1;
     }
 
@@ -713,7 +714,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) {
-        D("fail to get system model:%d\n", errno);
+        E("fail to get system model:%d\n", errno);
         return -1;
     } else {
         s_strncpy(str, value, str_size);
@@ -745,13 +746,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) {
-        D("fail to read /proc/cmdline\n");
+        E("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) {
-            D("could not get the (%s) value from cmdline\n", split);
+            E("could not get the (%s) value from cmdline\n", split);
             sdb_close(fd);
             return -1;
         }
@@ -771,19 +772,19 @@ int get_emulator_guestip(char str[], int str_size) {
 
     s = socket(AF_INET, SOCK_DGRAM, 0);
     if(s < 0) {
-        D("socket error\n");
+        E("socket error\n");
         return -1;
     }
 
     snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", GUEST_IP_INTERFACE);
     if(ioctl(s, SIOCGIFHWADDR, &ifr) < 0) {
-        D("ioctl hwaddr error\n");
+        E("ioctl hwaddr error\n");
         sdb_close(s);
         return -1;
     }
 
     if(ioctl(s, SIOCGIFADDR, &ifr) < 0) {
-        D("ioctl addr error\n");
+        E("ioctl addr error\n");
         sdb_close(s);
         return -1;
     }
@@ -820,28 +821,28 @@ void parse_banner(char *banner, atransport *t)
     }
 
     if(!strcmp(type, "bootloader")){
-        D("setting connection_state to CS_BOOTLOADER\n");
+        I("setting connection_state to CS_BOOTLOADER\n");
         t->connection_state = CS_BOOTLOADER;
         update_transports();
         return;
     }
 
     if(!strcmp(type, "device")) {
-        D("setting connection_state to CS_DEVICE\n");
+        I("setting connection_state to CS_DEVICE\n");
         t->connection_state = CS_DEVICE;
         update_transports();
         return;
     }
 
     if(!strcmp(type, "recovery")) {
-        D("setting connection_state to CS_RECOVERY\n");
+        I("setting connection_state to CS_RECOVERY\n");
         t->connection_state = CS_RECOVERY;
         update_transports();
         return;
     }
 
     if(!strcmp(type, "sideload")) {
-        D("setting connection_state to CS_SIDELOAD\n");
+        I("setting connection_state to CS_SIDELOAD\n");
         t->connection_state = CS_SIDELOAD;
         update_transports();
         return;
@@ -872,10 +873,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);
 
@@ -906,7 +907,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
-            D("open failed due to password locked before get A_CNXN:%d\n", t->connection_state);
+            E("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) {
@@ -952,7 +953,7 @@ void handle_packet(apacket *p, atransport *t)
                 p->len = p->msg.data_length;
 
                 if(s->enqueue(s, p) == 0) {
-                    D("Enqueue the socket\n");
+                    I("Enqueue the socket\n");
                     send_ready(s->id, rid, t);
                 }
                 return;
@@ -1155,7 +1156,7 @@ static int install_listener(const char *local_name, const char *connect_to, atra
     }
 
     if (close_on_exec(l->fd) < 0) {
-        D("fail to close fd exec:%d\n",l->fd);
+        E("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);
@@ -1302,17 +1303,17 @@ static void booting_done_signal_subscriber(GDBusConnection *connection,
 
     booting_done = 1;
     if (access(SDBD_BOOT_INFO_FILE, F_OK) == 0) {
-        D("booting is already done\n");
+        I("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);
         }
-        D("booting is done\n");
+        I("booting is done\n");
     }
 
-    D("handled the booting done signal\n");
+    I("handled the booting done signal\n");
     g_main_loop_quit(g_mainloop);
 }
 
@@ -1325,17 +1326,17 @@ static void *bootdone_cb(void *args)
     connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
     if (connection == NULL) {
         if (error != NULL) {
-            D("failed to connect to the system bus: %s\n", error->message);
+            E("failed to connect to the system bus: %s\n", error->message);
             g_error_free(error);
         } else {
-            D("failed to connect to the system bus\n");
+            E("failed to connect to the system bus\n");
         }
         return NULL;
     }
 
     g_mainloop = g_main_loop_new(NULL, false);
     if (g_mainloop == NULL) {
-        D("failed to create a g_main_loop\n");
+        E("failed to create a g_main_loop\n");
         goto bootdone_out;
     }
 
@@ -1344,11 +1345,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) {
-        D("failed to subscribe to the booting done signal\n");
+        E("failed to subscribe to the booting done signal\n");
         goto bootdone_out;
     }
 
-    D("wait for the booting done signal\n");
+    I("wait for the booting done signal\n");
     g_main_loop_run(g_mainloop);
 
     g_dbus_connection_signal_unsubscribe(connection, id);
@@ -1360,7 +1361,7 @@ bootdone_out:
     if (connection != NULL) {
         g_object_unref(connection);
     }
-    D("exit the bootdone_cb thread\n");
+    I("exit the bootdone_cb thread\n");
 
     return NULL;
 }
@@ -1369,10 +1370,10 @@ void register_bootdone_cb()
 {
     sdb_thread_t t;
     if (sdb_thread_create(&t, bootdone_cb, NULL)) {
-        D("can not create a service thread to check the booting done\n");
+        E("can not create a service thread to check the booting done\n");
         return;
     }
-    D("created the bootdone_cb thread\n");
+    I("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) {
@@ -1387,11 +1388,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) {
-        D("failed to allocate group_ids(%zu)\n", (ngroups + default_groups_size) * sizeof(gid_t));
+        E("failed to allocate group_ids(%zu)\n", (ngroups + default_groups_size) * sizeof(gid_t));
         return -1;
     }
     if (getgrouplist(name, gid, group_ids, &ngroups) == -1) {
-        D("failed to getgrouplist(), ngroups = %d\n", ngroups);
+        E("failed to getgrouplist(), ngroups = %d\n", ngroups);
         free(group_ids);
         return -1;
     }
@@ -1411,7 +1412,7 @@ static int sdbd_set_groups(const char *name, int gid, struct group_info default_
         }
     }
     if (setgroups(ngroups+added_group_cnt, group_ids) != 0) {
-        D("failed to setgroups().\n");
+        E("failed to setgroups().\n");
         free(group_ids);
         return -1;
     }
@@ -1427,10 +1428,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) {
-            D("Not found passwd : username(%s)\n", user_name);
+            E("Not found passwd : username(%s)\n", user_name);
         } else {
             errno = ret;
-            D("failed to getpwnam_r\n");
+            E("failed to getpwnam_r\n");
         }
         return -1;
     }
@@ -1445,10 +1446,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) {
-            D("Not found group : groupname(%s)\n", group_name);
+            E("Not found group : groupname(%s)\n", group_name);
         } else {
             errno = ret;
-            D("failed to getgrnam_r\n");
+            E("failed to getgrnam_r\n");
         }
         return -1;
     }
@@ -1458,7 +1459,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) {
-        D("failed to init sdk user information.\n");
+        E("failed to init sdk user information.\n");
         return -1;
     }
 
@@ -1469,23 +1470,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) {
-            D("set root user id failed (errno: %d)\n", errno);
+            E("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) {
-        D("set groups failed (errno: %d)\n", errno);
+        E("set groups failed (errno: %d)\n", errno);
         return -1;
     }
 
     if (setgid(g_sdk_group_id) != 0) {
-        D("set group id failed (errno: %d)\n", errno);
+        E("set group id failed (errno: %d)\n", errno);
         return -1;
     }
 
     if (setuid(g_sdk_user_id) != 0) {
-        D("set user id failed (errno: %d)\n", errno);
+        E("set user id failed (errno: %d)\n", errno);
         return -1;
 //        if(is_drop_capability_after_fork) {
 //            return -1;
@@ -1493,7 +1494,7 @@ int set_sdk_user_privileges(int is_drop_capability_after_fork) {
     }
 
     if (chdir(g_sdk_home_dir) < 0) {
-        D("unable to change working directory to %s\n", g_sdk_home_dir);
+        E("unable to change working directory to %s\n", g_sdk_home_dir);
     }
 
     // TODO: use pam later
@@ -1507,19 +1508,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) {
-        D("set root groups failed (errno: %d)\n", errno);
+        E("set root groups failed (errno: %d)\n", errno);
     }
 
     if (setgid(g_root_group_id) != 0) {
-        D("set root group id failed (errno: %d)\n", errno);
+        E("set root group id failed (errno: %d)\n", errno);
     }
 
     if (setuid(g_root_user_id) != 0) {
-        D("set root user id failed (errno: %d)\n", errno);
+        E("set root user id failed (errno: %d)\n", errno);
     }
 
     if (chdir(g_root_home_dir) < 0) {
-        D("unable to change root working directory to %s\n", g_sdk_home_dir);
+        E("unable to change root working directory to %s\n", g_sdk_home_dir);
     }
 
     // TODO: use pam later
@@ -1562,7 +1563,7 @@ static int init_sdb_default_groups() {
     bufsize = get_group_bufsize();
     buf = malloc(bufsize);
     if (buf == NULL) {
-        D("failed to allocate gruop buf(%ld)\n", bufsize);
+        E("failed to allocate gruop buf(%ld)\n", bufsize);
         return -1;
     }
 
@@ -1571,7 +1572,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 {
-            D("failed get group info.(errno: %d)\n", errno);
+            E("failed get group info.(errno: %d)\n", errno);
         }
     }
 
@@ -1599,11 +1600,11 @@ static int init_root_userinfo() {
     bufsize = get_passwd_bufsize();
     buf = malloc(bufsize);
     if (buf == NULL) {
-        D("failed to allocate passwd buf(%ld)\n", bufsize);
+        E("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) {
-            D("failed to get root user passwd info.(errno: %d)\n", errno);
+            E("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);
@@ -1618,7 +1619,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) {
-        D("failed to allocate for home dir env string\n");
+        E("failed to allocate for home dir env string\n");
     } else {
         snprintf(g_root_home_dir_env, env_size, "HOME=%s", g_root_home_dir);
     }
@@ -1636,17 +1637,17 @@ static int init_sdk_userinfo() {
     }
 
     if (init_sdb_default_groups() < 0) {
-        D("failed to initialize default groups.\n");
+        E("failed to initialize default groups.\n");
     }
 
     bufsize = get_passwd_bufsize();
     buf = malloc(bufsize);
     if (buf == NULL) {
-        D("failed to allocate passwd buf(%ld)\n", bufsize);
+        E("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) {
-            D("get user passwd info.(errno: %d)\n", errno);
+            E("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);
@@ -1661,7 +1662,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) {
-        D("failed to allocate for home dir env string\n");
+        E("failed to allocate for home dir env string\n");
     } else {
         snprintf(g_sdk_home_dir_env, env_size, "HOME=%s", g_sdk_home_dir);
     }
@@ -1680,7 +1681,7 @@ static int safe_system(char *cmd, char *argv[], char *envp[]) {
             return -1;
         case 0:
             execve(cmd, argv, envp);
-            D("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
+            E("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
             exit(-1);
         default:
             for (;;) {
@@ -1724,7 +1725,7 @@ static void init_sdk_requirements() {
                 NULL,
             };
             if (safe_system(cmd, args, envp) < 0) {
-                D("failed to change ownership to sdk user to %s\n", g_sdk_home_dir);
+                E("failed to change ownership to sdk user to %s\n", g_sdk_home_dir);
             }
 
             /* free environment variables */
@@ -1754,7 +1755,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch),
                     "%s", UNKNOWN);
-        D("fail to get the CPU architecture of model:%d\n", errno);
+        E("fail to get the CPU architecture of model:%d\n", errno);
     } else {
         snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch),
                     "%s", value);
@@ -1767,7 +1768,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_SECURE);
+        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_SECURE);
         snprintf(g_capabilities.secure_protocol, sizeof(g_capabilities.secure_protocol),
                     "%s", DISABLED);
     }
@@ -1776,7 +1777,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_INTER_SHELL);
+        E("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);
     }
@@ -1785,7 +1786,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_FILESYNC);
+        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_FILESYNC);
         snprintf(g_capabilities.filesync_support, sizeof(g_capabilities.filesync_support),
                     "%s", DISABLED);
     }
@@ -1794,7 +1795,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_USB_PROTOCOL);
+        E("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);
     }
@@ -1803,7 +1804,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_SOCK_PROTOCOL);
+        E("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);
     }
@@ -1815,7 +1816,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_ROOT_ONOFF);
+        E("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);
     }
@@ -1824,7 +1825,7 @@ static void init_capabilities(void) {
     // Encryption support
     if(!request_capability_to_plugin(CAPABILITY_ENCRYPTION, g_capabilities.encryption_support,
                             sizeof(g_capabilities.encryption_support))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_ENCRYPTION);
+        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_ENCRYPTION);
         snprintf(g_capabilities.encryption_support, sizeof(g_capabilities.encryption_support),
                     "%s", DISABLED);
     }
@@ -1854,7 +1855,7 @@ static void init_capabilities(void) {
 
     // SDK Tool path
     if (SDK_TOOL_PATH == NULL) {
-        D("fail to get SDK tool path.\n");
+        E("fail to get SDK tool path.\n");
         snprintf(g_capabilities.sdk_toolpath, sizeof(g_capabilities.sdk_toolpath),
                     "%s", UNKNOWN);
     } else {
@@ -1867,7 +1868,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.profile_name, sizeof(g_capabilities.profile_name),
                     "%s", UNKNOWN);
-        D("fail to get profile name:%d\n", errno);
+        E("fail to get profile name:%d\n", errno);
     } else {
         snprintf(g_capabilities.profile_name, sizeof(g_capabilities.profile_name),
                     "%s", value);
@@ -1882,7 +1883,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.vendor_name, sizeof(g_capabilities.vendor_name),
                     "%s", UNKNOWN);
-        D("fail to get the Vendor name:%d\n", errno);
+        E("fail to get the Vendor name:%d\n", errno);
     } else {
         snprintf(g_capabilities.vendor_name, sizeof(g_capabilities.vendor_name),
                     "%s", value);
@@ -1895,7 +1896,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_CAN_LAUNCH);
+        E("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);
     }
@@ -1912,7 +1913,7 @@ static void init_capabilities(void) {
     } else {
         snprintf(g_capabilities.device_name, sizeof(g_capabilities.device_name),
                 "%s", UNKNOWN);
-        D("fail to get the Device name:%d\n", errno);
+        E("fail to get the Device name:%d\n", errno);
     }
 
 
@@ -1921,7 +1922,7 @@ static void init_capabilities(void) {
     if (ret != SYSTEM_INFO_ERROR_NONE) {
         snprintf(g_capabilities.platform_version, sizeof(g_capabilities.platform_version),
                     "%s", UNKNOWN);
-        D("fail to get platform version:%d\n", errno);
+        E("fail to get platform version:%d\n", errno);
     } else {
         snprintf(g_capabilities.platform_version, sizeof(g_capabilities.platform_version),
                     "%s", value);
@@ -1934,7 +1935,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_PRODUCT_VER);
+        E("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);
     }
@@ -1948,7 +1949,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_PLUGIN_VER);
+        E("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);
     }
@@ -1957,7 +1958,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))) {
-           D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_LOG_ENABLE);
+           E("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);
     }
@@ -1965,7 +1966,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))) {
-           D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_LOG_PATH);
+           E("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);
     }
@@ -1973,7 +1974,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))) {
-           D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_APPCMD);
+           E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_APPCMD);
            snprintf(g_capabilities.appcmd_support, sizeof(g_capabilities.appcmd_support),
                        "%s", UNKNOWN);
     }
@@ -1986,7 +1987,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))) {
-        D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_DEBUGMODE);
+        E("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_DEBUGMODE);
         snprintf(g_capabilities.pkgcmd_debugmode, sizeof(g_capabilities.pkgcmd_debugmode),
                 "%s", ENABLED);
     }
@@ -2022,14 +2023,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;
-            D("This target type is Emulator\n");
+            I("This target type is Emulator\n");
         } else {
             g_is_emulator = 0;
-            D("This target type is Device\n");
+            I("This target type is Device\n");
         }
     } else {
         g_is_emulator = -1;
-        D("failed to get the model name.\n");
+        E("failed to get the model name.\n");
     }
 }
 
@@ -2056,13 +2057,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)) {
-        D("sdbd should be launched in develop mode.\n");
+        E("sdbd should be launched in develop mode.\n");
         return -1;
     }
 
@@ -2113,7 +2114,7 @@ int sdb_main(int server_port)
         cap.inheritable = 0;
         capset(&header, &cap);
 #endif
-        D("Local port disabled\n");
+        I("Local port disabled\n");
     } else {
         char local_name[30];
         build_local_name(local_name, sizeof(local_name), server_port);
@@ -2163,7 +2164,7 @@ int sdb_main(int server_port)
 
     sdb_notify_startup(0, "READY=1");
 
-    D("Event loop starting\n");
+    I("Event loop starting\n");
 
     fdevent_loop();
 
@@ -2177,12 +2178,12 @@ int sdb_main(int server_port)
 int copy_packet(apacket* dest, apacket* src) {
 
     if(dest == NULL) {
-        D("dest packet is NULL\n");
+        E("dest packet is NULL\n");
         return -1;
     }
 
     if(src == NULL) {
-        D("src packet is NULL\n");
+        E("src packet is NULL\n");
         return -1;
     }
 
@@ -2301,7 +2302,7 @@ int main(int argc, char **argv)
         return EXIT_FAILURE;
     }
 
-    D("Handling main()\n");
+    I("Handling main()\n");
 
     //sdbd will never die on emulator!
     signal(SIGTERM, handle_sig_term); /* tizen specific */
index ddf4b18dffa30f7de30169341eb1de6c6783881b..c734c10564a3afb706845d32a0eb7991dc98aae2 100644 (file)
@@ -11,7 +11,8 @@
 #include "sysdeps.h"
 #include "sdktools.h"
 
-#define  TRACE_TAG  TRACE_SERVICES
+//#define  TRACE_TAG  TRACE_SERVICES
+#define LOG_TAG "SDBD_TRACE_SEVICES"
 #include "log.h"
 
 #include "sdb.h"
@@ -75,11 +76,11 @@ static int get_application_install_path(char* pkg_path) {
 
     fp = popen("/usr/bin/pkgcmd -a", "r");
     if (fp == NULL) {
-        D("failed : popen pkgcmd -a\n");
+        E("failed : popen pkgcmd -a\n");
         return 0;
     }
     if (!fgets(ret_str, PATH_MAX+64, fp)) {
-        D("failed : fgets pkgcmd -a\n");
+        E("failed : fgets pkgcmd -a\n");
         pclose(fp);
         return 0;
     }
@@ -90,7 +91,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) {
-        D("failed : parsing fail (str:%s)\n", ret_str);
+        E("failed : parsing fail (str:%s)\n", ret_str);
         return 0;
     }
 
@@ -105,7 +106,7 @@ int is_pkg_file_path(const char* path) {
     char pkg_path_regx[PATH_MAX+64] = {0,};
 
     if (!get_application_install_path(pkg_path)) {
-        D("failed to get application install path\n");
+        E("failed to get application install path\n");
         return 0;
     }
 
@@ -114,7 +115,7 @@ int is_pkg_file_path(const char* path) {
 
     ret = regcomp(&regex, pkg_path_regx, REG_EXTENDED);
     if (ret){
-        D("failed : recomp (error:%d)\n", ret);
+        E("failed : recomp (error:%d)\n", ret);
         return 0;
     }
 
@@ -122,7 +123,7 @@ int is_pkg_file_path(const char* path) {
     regfree(&regex);
 
     if (ret){
-        D("This path is NOT package file: %s\n", path);
+        E("This path is NOT package file: %s\n", path);
         return 0;
     }
 
index 6d98e18e7926e28663d703e200a8b453e59a550b..9f2d7bf45923cbc0c40bc052246611ff923159cb 100644 (file)
@@ -23,7 +23,8 @@
 
 #include "sysdeps.h"
 
-#define  TRACE_TAG  TRACE_SERVICES
+//#define  TRACE_TAG  TRACE_SERVICES
+#define LOG_TAG "SDBD_TRACE_SERVICES"
 #include "log.h"
 
 #include "sdb.h"
@@ -164,11 +165,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 {
-            D("failed to get environment value using tzplatform_getenv");
+            E("failed to get environment value using tzplatform_getenv");
             snprintf(buf, sizeof(buf), "%d", ERROR_TZPLATFORM_ENV_GENERAL);
         }
     } else {
-        D("environment name (%s) is invalid\n", env_name);
+        E("environment name (%s) is invalid\n", env_name);
         snprintf(buf, sizeof(buf), "%d", ERROR_TZPLATFORM_ENV_INVALID_VARIABLES);
     }
     writex(fd, buf, strlen(buf));
@@ -218,18 +219,18 @@ void inoti_service(int fd, void *arg)
     int ifd;
     char buffer[BUF_LEN];
 
-    D( "inoti_service start\n");
+    I( "inoti_service start\n");
     ifd = inotify_init();
 
     if ( ifd < 0 ) {
-        D( "inotify_init failed\n");
+        E( "inotify_init failed\n");
         sdb_close(fd);
         return;
     }
 
     wd = inotify_add_watch(ifd, CS_PATH, IN_CREATE | IN_MOVE);
     if ( wd < 0 ) {
-        D("inotify_add_watch failed (errno :%d)\n", errno);
+        E("inotify_add_watch failed (errno :%d)\n", errno);
         sdb_close(ifd);
         sdb_close(fd);
         return;
@@ -240,7 +241,7 @@ void inoti_service(int fd, void *arg)
         length = sdb_read( ifd, buffer, BUF_LEN );
 
         if ( length < 0 ) {
-            D( "inoti read failed\n");
+            E( "inoti read failed\n");
             goto done;
         }
         int payload = length >= EVENT_SIZE ? length - EVENT_SIZE : 0;
@@ -256,7 +257,7 @@ void inoti_service(int fd, void *arg)
                             writex(fd, cspath, len);
                             free(cspath);
                         } else {
-                            D( "asprintf was failed\n" );
+                            E( "asprintf was failed\n" );
                         }
                     }
                 } else if (event->mask & IN_MOVE) {
@@ -268,7 +269,7 @@ void inoti_service(int fd, void *arg)
                             writex(fd, cspath, len);
                             free(cspath);
                         } else {
-                            D("asprintf was failed\n");
+                            E("asprintf was failed\n");
                         }
                     }
                 }
@@ -284,7 +285,7 @@ done:
     inotify_rm_watch( ifd, wd );
     sdb_close(ifd);
     sdb_close(fd);
-    D( "inoti_service end\n");
+    I( "inoti_service end\n");
 }
 
 #if 0
@@ -328,7 +329,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
     int s[2];
 
     if(sdb_socketpair(s)) {
-        D("cannot create service socket pair\n");
+        E("cannot create service socket pair\n");
         return -1;
     }
 
@@ -342,7 +343,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
         free(sti);
         sdb_close(s[0]);
         sdb_close(s[1]);
-        D("cannot create service thread\n");
+        E("cannot create service thread\n");
         return -1;
     }
 
@@ -368,23 +369,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){
-        D("[ cannot open /dev/ptmx - errno:%d ]\n",errno);
+        E("[ cannot open /dev/ptmx - errno:%d ]\n",errno);
         return -1;
     }
     if (fcntl(ptm, F_SETFD, FD_CLOEXEC) < 0) {
-        D("[ cannot set cloexec to /dev/ptmx - errno:%d ]\n",errno);
+        E("[ cannot set cloexec to /dev/ptmx - errno:%d ]\n",errno);
     }
 
     if(grantpt(ptm) || unlockpt(ptm) ||
         ptsname_r(ptm, devname, sizeof(devname)) != 0 ){
-        D("[ trouble with /dev/ptmx - errno:%d ]\n", errno);
+        E("[ trouble with /dev/ptmx - errno:%d ]\n", errno);
         sdb_close(ptm);
         return -1;
     }
 
     *pid = fork();
     if(*pid < 0) {
-        D("- fork failed: errno:%d -\n", errno);
+        E("- fork failed: errno:%d -\n", errno);
         sdb_close(ptm);
         return -1;
     }
@@ -413,7 +414,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
-               D("sdb: unable to open %s due to errno:%d\n", text, errno);
+               E("sdb: unable to open %s due to errno:%d\n", text, errno);
             }
         }
 
@@ -474,11 +475,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) {
-            D("sdb: control level != SOL_SOCKET");
+            I("sdb: control level != SOL_SOCKET");
             exit(-1);
         }
         if (pheader->cmsg_type != SCM_RIGHTS) {
-            D("sdb: control type != SCM_RIGHTS");
+            I("sdb: control type != SCM_RIGHTS");
             exit(-1);
         }
         memcpy(recvfd, CMSG_DATA(pheader), sizeof(int));
@@ -493,7 +494,7 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
 {
     *pid = fork();
     if(*pid < 0) {
-        D("- fork failed: errno:%d -\n", errno);
+        E("- fork failed: errno:%d -\n", errno);
         return -1;
     }
 
@@ -504,7 +505,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) {
-                    D("failed to set SDK user privileges\n");
+                    E("failed to set SDK user privileges\n");
                     exit(-1);
                 }
             }
@@ -513,7 +514,7 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
         }
         /* exec sdbduser */
         execve(cmd, argv, envp);
-        D("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
+        E("- exec '%s' failed: (errno:%d) -\n", cmd, errno);
         exit(-1);
     } else {
         // Don't set child's OOM adjustment to zero.
@@ -532,14 +533,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) {
-            D("failed to get socket path, %d\n", errno);
+            E("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) {
-            D("socket error, %d\n", errno);
+            E("socket error, %d\n", errno);
             free(sockpath);
             return -1;
         }
@@ -554,9 +555,9 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
             usleep(10000);
         }
         if (trycnt == 100) {
-            D("failed to connect, errno: %d\n", errno);
+            E("failed to connect, errno: %d\n", errno);
             if (sdb_close(sock) == -1) {
-                D("close sock error, %d\n", errno);
+                E("close sock error, %d\n", errno);
             }
             free(sockpath);
             return -1;
@@ -564,9 +565,9 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
 
         char c;
         if (recv_fd(sock, &c, 1, &ptm) == -1) {
-            D("recv_fd error, %d\n", errno);
+            E("recv_fd error, %d\n", errno);
             if (sdb_close(sock) == -1) {
-                D("close sock error, %d\n", errno);
+                E("close sock error, %d\n", errno);
             }
             free(sockpath);
             return -1;
@@ -575,11 +576,11 @@ int create_userprocess(const char *cmd, pid_t *pid, char * const argv[], char *
         }
 
         if (sdb_close(sock) == -1) {
-            D("close sock error, %d\n", errno);
+            E("close sock error, %d\n", errno);
         }
         free(sockpath);
 
-        D("getting child's ptm successed.\n");
+        I("getting child's ptm successed.\n");
         return ptm;
     }
 }
@@ -715,13 +716,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) {
-        D("Cannot allocate the shell commnad buffer.");
+        E("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)) {
-        D("Failed to convert the shell command. (%s)\n", name);
+        E("Failed to convert the shell command. (%s)\n", name);
         free(envp_plugin);
         return -1;
     } else {
@@ -737,7 +738,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)) {
-            D("This shell command is invalid. (%s)\n", name);
+            E("This shell command is invalid. (%s)\n", name);
             return -1;
         }
 
@@ -745,13 +746,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) {
-            D("Cannot allocate the shell commnad buffer.");
+            E("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)) {
-            D("Failed to convert the shell command. (%s)\n", name);
+            E("Failed to convert the shell command. (%s)\n", name);
             free(new_cmd);
             return -1;
         }
@@ -771,7 +772,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()) {
-            D("This platform dose NOT support the interactive shell\n");
+            E("This platform dose NOT support the interactive shell\n");
             return -1;
         }
 
@@ -815,7 +816,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) {
-        D("cannot create service thread\n");
+        E("cannot create service thread\n");
         return -1;
     }
 
@@ -826,7 +827,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) {
-            D("failed to sync window size.\n");
+            E("failed to sync window size.\n");
         }
     }
 
@@ -839,7 +840,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);
-        D("cannot create service thread\n");
+        E("cannot create service thread\n");
         return -1;
     }
 
@@ -853,7 +854,7 @@ static int create_sync_subprocess(void (*func)(int, void *), void* cookie) {
     int s[2];
 
     if(sdb_socketpair(s)) {
-        D("cannot create service socket pair\n");
+        E("cannot create service socket pair\n");
         return -1;
     }
 
@@ -868,10 +869,10 @@ static int create_sync_subprocess(void (*func)(int, void *), void* cookie) {
         // FIXME: do not wait child process hear
         //waitpid(pid, &ret, 0);
     } else {
-        D("- fork failed: errno:%d -\n", errno);
+        E("- fork failed: errno:%d -\n", errno);
         sdb_close(s[0]);
         sdb_close(s[1]);
-        D("cannot create sync service sub process\n");
+        E("cannot create sync service sub process\n");
         return -1;
     }
 
@@ -918,7 +919,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));
-        D("fail to get system model:%d\n", errno);
+        E("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);
@@ -930,7 +931,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));
-        D("fail to get platform name:%d\n", errno);
+        E("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);
@@ -944,7 +945,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));
-        D("fail to get platform version:%d\n", errno);
+        E("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);
@@ -956,7 +957,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));
-        D("fail to get profile name:%d\n", errno);
+        E("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);
@@ -1129,10 +1130,10 @@ static void sync_windowsize(int fd, void *cookie) {
         win_sz.ws_col = columns;
 
         if (ioctl(s->fd, TIOCSWINSZ, &win_sz) < 0) {
-            D("failed to sync window size.\n");
+            E("failed to sync window size.\n");
             return;
         }
-        D("success to sync window size.\n");
+        I("success to sync window size.\n");
     }
 }
 
@@ -1143,11 +1144,11 @@ void get_boot(int fd, void *cookie) {
     int interval = 1000;
     while (time < COMMAND_TIMEOUT) {
         if (booting_done == 1) {
-            D("get_boot:platform booting is done\n");
+            I("get_boot:platform booting is done\n");
             snprintf(buf, sizeof(buf), "%s", "1");
             break;
         }
-        D("get_boot:platform booting is in progress\n");
+        I("get_boot:platform booting is in progress\n");
         sdb_sleep_ms(interval);
         time += interval;
     }
@@ -1322,7 +1323,7 @@ int service_to_fd(const char *name)
 
     if (ret >= 0) {
         if (close_on_exec(ret) < 0) {
-            D("failed to close fd exec\n");
+            E("failed to close fd exec\n");
         }
     }
     return ret;
index 12baadee80ed0594b38dc3b153b69dd8c936a9d0..ebc75508fecb2752969126c218a33dbeb6cecbaf 100644 (file)
@@ -23,7 +23,8 @@
 
 #include "sysdeps.h"
 
-#define  TRACE_TAG  TRACE_SOCKETS
+//#define  TRACE_TAG  TRACE_SOCKETS
+#define LOG_TAG "SDBD_TRACE_SOCKETS"
 #include "log.h"
 
 #include "sdb.h"
@@ -156,7 +157,7 @@ static int local_socket_enqueue(asocket *s, apacket *p)
             continue;
         }
         if((r == 0) || (errno != EAGAIN)) {
-            D( "LS(%d): not ready, errno=%d\n", s->id, errno);
+            E( "LS(%d): not ready, errno=%d\n", s->id, errno);
             s->close(s);
             return 1; /* not ready (error) */
         } else {
@@ -262,7 +263,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.
@@ -333,8 +334,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;
@@ -349,8 +350,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)) {
@@ -358,7 +359,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
@@ -393,7 +394,7 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
             ** bytes of readable data.
             */
 //        s->close(s);
-        D("LS(%d): FDE_ERROR (fd=%d)\n", s->id, s->fd);
+        E("LS(%d): FDE_ERROR (fd=%d)\n", s->id, s->fd);
 
         return;
     }
@@ -448,8 +449,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;
@@ -524,7 +525,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;
 
@@ -532,7 +533,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;
@@ -647,11 +648,11 @@ static int smart_socket_enqueue(asocket *s, apacket *p)
 
     len = unhex(p->data, 4);
     if((len < 1) ||  (len > 1024)) {
-        D("SS(%d): bad size (%d)\n", s->id, len);
+        E("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);
@@ -660,7 +661,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 d6ecd6697f3a42cd597855f1322d0445a014aadb..a5df573f8558f3044985d3073a10c54c4d111ed6 100644 (file)
@@ -22,7 +22,8 @@
 
 #include "sysdeps.h"
 
-#define   TRACE_TAG  TRACE_TRANSPORT
+//#define   TRACE_TAG  TRACE_TRANSPORT
+#define LOG_TAG "SDBD_TRACE_TRANSPORT"
 #include "log.h"
 
 #include "sdb.h"
@@ -72,7 +73,7 @@ static void  dump_hex( const unsigned char*  ptr, size_t  len )
         *pb++ =  c;
     }
     *pb++ = '\0';
-    DR("%s\n", buffer);
+//    D("%s\n", buffer);
 }
 
 static const char *statename(atransport *t)
@@ -155,8 +156,7 @@ 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,16 +178,14 @@ read_packet(int  fd, const char* name, apacket** ppacket)
             len -= r;
             p   += r;
         } else {
-            D("%s: read_packet (fd=%d), error ret=%d errno=%d\n", name, fd, r, errno);
+            E("%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
-    if (SDB_TRACING) {
-        dump_packet(name, "from remote", *ppacket);
-    }
+    dump_packet(name, "from remote", *ppacket);
 #endif
     return 0;
 }
@@ -204,9 +202,7 @@ write_packet(int  fd, const char* name, apacket** ppacket)
     }
 
 #if SDB_TRACE
-    if (SDB_TRACING) {
-        dump_packet(name, "to remote", *ppacket);
-    }
+    dump_packet(name, "to remote", *ppacket);
 #endif
     while(len > 0) {
         r = sdb_write(fd, p, len);
@@ -214,7 +210,7 @@ write_packet(int  fd, const char* name, apacket** ppacket)
             len -= r;
             p += r;
         } else {
-            D("%s: write_packet (fd=%d) error ret=%d errno=%d\n", name, fd, r, errno);
+            E("%s: write_packet (fd=%d) error ret=%d errno=%d\n", name, fd, r, errno);
             if((r < 0) && (errno == EINTR)) continue;
             return -1;
         }
@@ -225,11 +221,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)){
-            D("%s: failed to read packet from transport socket on fd %d\n", t->serial, fd);
+            E("%s: failed to read packet from transport socket on fd %d\n", t->serial, fd);
         } else {
             handle_packet(p, (atransport *) _t);
         }
@@ -255,7 +251,7 @@ void send_packet(apacket *p, atransport *t)
     print_packet("send", p);
 
     if (t == NULL) {
-        D("Transport is null \n");
+        E("Transport is null \n");
         fatal("Transport is null");
     }
 
@@ -291,7 +287,7 @@ static void *output_thread(void *_t)
     p->msg.magic = A_SYNC ^ 0xffffffff;
     if(write_packet(t->fd, t->serial, &p)) {
         put_apacket(p);
-        D("%s: failed to write SYNC packet\n", t->serial);
+        E("%s: failed to write SYNC packet\n", t->serial);
         goto oops;
     }
 
@@ -300,8 +296,7 @@ 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) // 현재 연결이 암호화 모드이고, 암호화 관련 메시지가 아닌 경우, 메시지 복호화
@@ -313,11 +308,11 @@ static void *output_thread(void *_t)
 
             if(write_packet(t->fd, t->serial, &p)){
                 put_apacket(p);
-                D("%s: failed to write apacket to transport\n", t->serial);
+                E("%s: failed to write apacket to transport\n", t->serial);
                 goto oops;
             }
         } else {
-            D("%s: remote read failed for transport\n", t->serial);
+            E("%s: remote read failed for transport\n", t->serial);
             put_apacket(p);
             break;
         }
@@ -331,7 +326,7 @@ static void *output_thread(void *_t)
     p->msg.magic = A_SYNC ^ 0xffffffff;
     if(write_packet(t->fd, t->serial, &p)) {
         put_apacket(p);
-        D("%s: failed to write SYNC apacket to transport", t->serial);
+        E("%s: failed to write SYNC apacket to transport", t->serial);
     }
 
 oops:
@@ -352,7 +347,7 @@ static void *input_thread(void *_t)
 
     for(;;){
         if(read_packet(t->fd, t->serial, &p)) {
-            D("%s: failed to read apacket from transport on fd %d\n",
+            E("%s: failed to read apacket from transport on fd %d\n",
                t->serial, t->fd );
             break;
         }
@@ -379,7 +374,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) // 현재 연결이 암호화 모드이고, 암호화 관련 메시지가 아닌 경우, 메시지를 암호화
@@ -444,7 +439,7 @@ transport_read_action(int  fd, struct tmsg*  m)
             p   += r;
         } else {
             if((r < 0) && (errno == EINTR)) continue;
-            D("transport_read_action: on fd %d, error %d\n",
+            E("transport_read_action: on fd %d, error %d\n",
               fd, errno);
             return -1;
         }
@@ -466,7 +461,7 @@ transport_write_action(int  fd, struct tmsg*  m)
             p   += r;
         } else {
             if((r < 0) && (errno == EINTR)) continue;
-            D("transport_write_action: on fd %d, error %d\n",
+            E("transport_write_action: on fd %d, error %d\n",
               fd, errno);
             return -1;
         }
@@ -739,7 +734,7 @@ void register_socket_transport(int s, const char *serial, int port, int local, c
 {
     atransport *t = calloc(1, sizeof(atransport));
     if (t == NULL) {
-        D("failed to allocate memory of transport struct\n");
+        E("failed to allocate memory of transport struct\n");
         return;
     }
     char buff[32];
@@ -833,7 +828,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) {
-        D("failed to allocate memory of transport struct\n");
+        E("failed to allocate memory of transport struct\n");
         return;
     }
 
@@ -865,8 +860,10 @@ void unregister_usb_transport(usb_handle *usb)
     sdb_mutex_unlock(&transport_lock);
 }
 
-#undef TRACE_TAG
-#define TRACE_TAG  TRACE_RWX
+//#undef TRACE_TAG
+//#define TRACE_TAG  TRACE_RWX
+#undef LOG_TAG
+#define LOG_TAG "SDBD_TRACE_RWX"
 
 int readx(int fd, void *ptr, size_t len)
 {
@@ -874,7 +871,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) {
@@ -882,18 +879,18 @@ int readx(int fd, void *ptr, size_t len)
             p += r;
         } else {
             if (r < 0) {
-                D("readx: fd=%d error %d\n", fd, errno);
+                E("readx: fd=%d error %d\n", fd, errno);
                 if (errno == EINTR)
                     continue;
             } else {
-                D("readx: fd=%d disconnected\n", fd);
+                E("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;
@@ -905,7 +902,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) {
@@ -915,11 +912,11 @@ int writex(int fd, const void *ptr, size_t len)
             p += r;
         } else {
             if (r < 0) {
-                D("writex: fd=%d error %d\n", fd, errno);
+                E("writex: fd=%d error %d\n", fd, errno);
                 if (errno == EINTR)
                     continue;
             } else {
-                D("writex: fd=%d disconnected\n", fd);
+                E("writex: fd=%d disconnected\n", fd);
             }
             return -1;
         }
@@ -930,12 +927,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)) {
-        D("check_header(): invalid magic\n");
+        E("check_header(): invalid magic\n");
         return -1;
     }
 
     if(p->msg.data_length > t->max_payload) {
-        D("check_header(): %d > transport->max_payload(%zu)\n", p->msg.data_length, t->max_payload);
+        E("check_header(): %d > transport->max_payload(%zu)\n", p->msg.data_length, t->max_payload);
         return -1;
     }
 
index 20f27478250ebd9927eec3cb9ff8b5a9349ef81c..16cd7dece98c2ab0b463804578db40beead72a1f 100644 (file)
@@ -32,7 +32,8 @@
 #include <unistd.h>
 #endif
 
-#define  TRACE_TAG  TRACE_TRANSPORT
+//#define  TRACE_TAG  TRACE_TRANSPORT
+#define LOG_TAG "SDBD_TRACE_TRANSPORT"
 #include "log.h"
 
 #include "sdb.h"
@@ -65,7 +66,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))){
-        D("remote local: read terminated (message)\n");
+        E("remote local: read terminated (message)\n");
         return -1;
     }
 
@@ -76,17 +77,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)) {
-        D("bad header: terminated (data)\n");
+        E("bad header: terminated (data)\n");
         return -1;
     }
 
     if(readx(t->sfd, p->data, p->msg.data_length)){
-        D("remote local: terminated (data)\n");
+        E("remote local: terminated (data)\n");
         return -1;
     }
 
     if(check_data(p)) {
-        D("bad data: terminated (data)\n");
+        E("bad data: terminated (data)\n");
         return -1;
     }
 
@@ -104,7 +105,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)) {
-        D("remote local: write terminated\n");
+        E("remote local: write terminated\n");
         return -1;
     }
 
@@ -128,7 +129,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) {
-            D("failed to close fd exec\n");
+            E("failed to close fd exec\n");
         }
         disable_tcp_nagle(fd);
         snprintf(buf, sizeof buf, "%s%d", LOCAL_CLIENT_PREFIX, console_port);
@@ -167,7 +168,7 @@ static void *server_socket_thread(void * arg)
                 continue;
             }
             if (close_on_exec(serverfd) < 0) {
-                D("failed to close serverfd exec\n");
+                E("failed to close serverfd exec\n");
             }
         }
 
@@ -183,7 +184,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) {
-                D("failed to close fd exec\n");
+                E("failed to close fd exec\n");
             }
             disable_tcp_nagle(fd);
 
@@ -219,7 +220,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) {
-                    D("failed to set keep alive option. FD(%d), errno=%d\n", fd, errno);
+                    E("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);
@@ -228,7 +229,7 @@ static void *server_socket_thread(void * arg)
                 register_socket_transport(fd, "host", port, 1, NULL);
             }
         } else {
-            D("failed to accept() from sdb server\n");
+            E("failed to accept() from sdb server\n");
             //FIXME: implements error handle for EMFILE or ENFILE
         }
     }
@@ -356,7 +357,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) {
-        D("failed to set file O_NONBLOCK status flag for socket %d: errno:%d\n",
+        E("failed to set file O_NONBLOCK status flag for socket %d: errno:%d\n",
                      sockfd, errno);
     }
 
@@ -387,11 +388,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
-        D("select error: sockfd not set\n");
+        E("select error: sockfd not set\n");
 
     done:
     if(fcntl(sockfd, F_SETFL, flags) == -1) { /* restore file status flags */
-        D("failed to restore file status flag for socket %d\n",
+        E("failed to restore file status flag for socket %d\n",
                  sockfd);
     }
 
@@ -420,22 +421,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) {
-        D("could not create socket\n");
+        E("could not create socket\n");
         return -1;
     }
     ret = connect_nonb(s, (struct sockaddr*) &server, sizeof(server), connect_timeout);
     if (ret < 0) {
-        D("could not connect to server\n");
+        E("could not connect to server\n");
         sdb_close(s);
         return -1;
     }
     if (writex(s, request, strlen(request)) != 0) {
-        D("could not send notification request to host\n");
+        E("could not send notification request to host\n");
         sdb_close(s);
         return -1;
     }
     sdb_close(s);
-    D("sent notification request to host\n");
+    I("sent notification request to host\n");
 
     return 0;
 }
@@ -461,7 +462,7 @@ static void* notify_sdbd_startup_thread(void* ptr) {
         return NULL;
     }
     if (get_emulator_hostip(host_ip, sizeof host_ip) == -1) {
-       D("failed to get emulator host ip\n");
+       E("failed to get emulator host ip\n");
        return NULL;
     }
     // XXX: Known issue - log collision
@@ -481,7 +482,7 @@ static void* notify_sdbd_startup_thread(void* ptr) {
         }
 
         if (get_emulator_guestip(guest_ip, sizeof guest_ip) == -1) {
-            D("failed to get emulator guest ip\n");
+            E("failed to get emulator guest ip\n");
             goto sleep_and_continue;
         }
 
index 471aa879fc5c408e4416ea2b08b8284d2cdd0651..add59017818d274b1e7b557de5715e5f27ec4bd0 100644 (file)
@@ -20,7 +20,8 @@
 
 #include <sysdeps.h>
 
-#define  TRACE_TAG  TRACE_TRANSPORT
+//#define  TRACE_TAG  TRACE_TRANSPORT
+#define LOG_TAG "SDBD_TRACE_TRANSPORT"
 #include "log.h"
 
 #include "sdb.h"
@@ -51,26 +52,26 @@ unsigned host_to_le32(unsigned n)
 static int remote_read(apacket *p, atransport *t)
 {
     if(usb_read(t->usb, &p->msg, sizeof(amessage))){
-        D("remote usb: read terminated (message)\n");
+        E("remote usb: read terminated (message)\n");
         return -1;
     }
 
     fix_endians(p);
 
     if(check_header(p, t)) {
-        D("remote usb: check_header failed\n");
+        E("remote usb: check_header failed\n");
         return -1;
     }
 
     if(p->msg.data_length) {
         if(usb_read(t->usb, p->data, p->msg.data_length)){
-            D("remote usb: terminated (data)\n");
+            E("remote usb: terminated (data)\n");
             return -1;
         }
     }
 
     if(check_data(p)) {
-        D("remote usb: check_data failed\n");
+        E("remote usb: check_data failed\n");
         return -1;
     }
 
@@ -84,12 +85,12 @@ static int remote_write(apacket *p, atransport *t)
     fix_endians(p);
 
     if(usb_write(t->usb, &p->msg, sizeof(amessage))) {
-        D("remote usb: 1 - write terminated\n");
+        E("remote usb: 1 - write terminated\n");
         return -1;
     }
     if(p->msg.data_length == 0) return 0;
     if(usb_write(t->usb, &p->data, size)) {
-        D("remote usb: 2 - write terminated\n");
+        E("remote usb: 2 - write terminated\n");
         return -1;
     }
 
index b33e68f6b13dc654710be3cbcdb7b65c88f4d193..dd9fa6563716385345f9acd881cb65e8d9b472a9 100644 (file)
@@ -28,7 +28,8 @@
 
 #include "sysdeps.h"
 
-#define   TRACE_TAG  TRACE_USB
+//#define   TRACE_TAG  TRACE_USB
+#define LOG_TAG "SDBD_TRACE_USB"
 #include "log.h"
 
 #include "sdb.h"
@@ -73,7 +74,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) {
-        D("[ %s: cannot open control endpoint ]\n", h->EP0_NAME);
+        E("[ %s: cannot open control endpoint ]\n", h->EP0_NAME);
         h->control = -errno;
         sdb_mutex_unlock(&h->control_lock);
         goto error;
@@ -83,7 +84,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) {
-        D("[ %s: cannot write descriptors ]\n", h->EP0_NAME);
+        E("[ %s: cannot write descriptors ]\n", h->EP0_NAME);
         sdb_mutex_unlock(&h->control_lock);
         goto error;
     }
@@ -92,7 +93,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) {
-        D("[ %s: cannot write strings ]\n", h->EP0_NAME);
+        E("[ %s: cannot write strings ]\n", h->EP0_NAME);
         sdb_mutex_unlock(&h->control_lock);
         goto error;
     }
@@ -105,7 +106,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) {
-        D("[ %s: cannot open bulk-out endpoint ]\n", h->EP_OUT_NAME);
+        E("[ %s: cannot open bulk-out endpoint ]\n", h->EP_OUT_NAME);
         h->bulk_out = -errno;
         goto error;
     }
@@ -113,7 +114,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) {
-        D("[ %s: cannot open bulk-in endpoint ]\n", h->EP_IN_NAME);
+        E("[ %s: cannot open bulk-in endpoint ]\n", h->EP_IN_NAME);
         h->bulk_in = -errno;
         goto error;
     }
@@ -168,7 +169,7 @@ static void *usb_open_thread(void *x)
     }
 
     if (usb->control < 0 || usb->bulk_in < 0 || usb->bulk_out < 0) {
-        D("[ opening device failed ]\n");
+        E("[ opening device failed ]\n");
         return (void *)-1;
     }
 
@@ -467,7 +468,7 @@ int ffs_usb_write(usb_handle *h, const void *data, int len)
 
     n = bulk_write(h->bulk_in, data, len);
     if(n != len) {
-        D("ERROR: fd = %d, n = %d, errno = %d\n",
+        E("ERROR: fd = %d, n = %d, errno = %d\n",
             h->bulk_in, n, errno);
         return -1;
     }
@@ -488,7 +489,7 @@ int ffs_usb_read(usb_handle *h, void *data, size_t len)
 
     n = bulk_read(h->bulk_out, data, len);
     if(n != len) {
-        D("ERROR: fd = %d, n = %d, errno = %d\n",
+        E("ERROR: fd = %d, n = %d, errno = %d\n",
             h->bulk_out, n, errno);
         return -1;
     }
index 0d8f2be1034e358d351d2572cf172b97e0d65f57..7cfe9eefe41bb988e04dea3463328952fa563190 100644 (file)
@@ -38,7 +38,8 @@
 
 #include "sysdeps.h"
 
-#define   TRACE_TAG  TRACE_USB
+//#define   TRACE_TAG  TRACE_USB
+#define LOG_TAG "SDBD_TRACE_USB"
 #include "log.h"
 
 #include "sdb.h"
@@ -180,7 +181,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) {
-                D("desclength %d is too small\n", desclength);
+                E("desclength %d is too small\n", desclength);
                 sdb_close(fd);
                 continue;
             }
@@ -209,7 +210,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) {
-                D("usb_config_descriptor not found\n");
+                E("usb_config_descriptor not found\n");
                 sdb_close(fd);
                 continue;
             }
@@ -224,7 +225,7 @@ static void find_usb_device(const char *base,
                     bufptr += length;
 
                     if (length != USB_DT_INTERFACE_SIZE) {
-                        D("interface descriptor has wrong size\n");
+                        E("interface descriptor has wrong size\n");
                         break;
                     }
 
@@ -237,7 +238,7 @@ static void find_usb_device(const char *base,
                             is_sdb_interface(vid, pid, interface->bInterfaceClass,
                             interface->bInterfaceSubClass, interface->bInterfaceProtocol))  {
 
-                        D("looking for bulk endpoints\n");
+                        I("looking for bulk endpoints\n");
                             // looks like SDB...
                         ep1 = (struct usb_endpoint_descriptor *)bufptr;
                         bufptr += USB_DT_ENDPOINT_SIZE;
@@ -249,14 +250,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) {
-                            D("endpoints not found\n");
+                            I("endpoints not found\n");
                             break;
                         }
 
                             // both endpoints should be bulk
                         if (ep1->bmAttributes != USB_ENDPOINT_XFER_BULK ||
                             ep2->bmAttributes != USB_ENDPOINT_XFER_BULK) {
-                            D("bulk endpoints not found\n");
+                            I("bulk endpoints not found\n");
                             continue;
                         }
                             /* aproto 01 needs 0 termination */
@@ -307,7 +308,7 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len)
     urb->buffer = (void*) data;
     urb->buffer_length = len;
 
-    D("++ write ++\n");
+    I("++ write ++\n");
 
     sdb_mutex_lock(&h->lock);
     if(h->dead) {
@@ -342,7 +343,7 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len)
     }
 fail:
     sdb_mutex_unlock(&h->lock);
-    D("-- write --\n");
+    I("-- write --\n");
     return res;
 }
 
@@ -375,7 +376,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len)
 
     h->urb_in_busy = 1;
     for(;;) {
-        D("[ reap urb - wait ]\n");
+        I("[ reap urb - wait ]\n");
         h->reaper_thread = pthread_self();
         sdb_mutex_unlock(&h->lock);
         res = ioctl(h->desc, USBDEVFS_REAPURB, &out);
@@ -390,7 +391,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len)
             if(saved_errno == EINTR) {
                 continue;
             }
-            D("[ reap urb - error ]\n");
+            E("[ reap urb - error ]\n");
             break;
         }
         D("[ urb @%p status = %d, actual = %d ]\n",
@@ -407,7 +408,7 @@ static int usb_bulk_read(usb_handle *h, void *data, int len)
             break;
         }
         if(out == &h->urb_out) {
-            D("[ reap urb - OUT compelete ]\n");
+            I("[ reap urb - OUT compelete ]\n");
             h->urb_out_busy = 0;
             sdb_cond_broadcast(&h->notify);
         }
@@ -439,7 +440,7 @@ int usb_write(usb_handle *h, const void *_data, int len)
 
         n = usb_bulk_write(h, data, xfer);
         if(n != xfer) {
-            D("ERROR: n = %d, errno = %d\n",
+            E("ERROR: n = %d, errno = %d\n",
                 n, errno);
             return -1;
         }
@@ -461,7 +462,7 @@ int usb_read(usb_handle *h, void *_data, size_t len)
     unsigned char *data = (unsigned char*) _data;
     int n;
 
-    D("++ usb_read ++\n");
+    I("++ usb_read ++\n");
     while(len > 0) {
         int xfer = (len > 4096) ? 4096 : len;
 
@@ -470,14 +471,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)) {
-                D("[ timeout ]\n");
+                I("[ timeout ]\n");
                 if(n > 0){
                     data += n;
                     len -= n;
                 }
                 continue;
             }
-            D("ERROR: n = %d, errno = %d \n",
+            E("ERROR: n = %d, errno = %d \n",
                 n, errno);
             return -1;
         }
@@ -486,7 +487,7 @@ int usb_read(usb_handle *h, void *_data, size_t len)
         data += xfer;
     }
 
-    D("-- usb_read --\n");
+    I("-- usb_read --\n");
     return 0;
 }
 
@@ -527,7 +528,7 @@ void usb_kick(usb_handle *h)
 
 int usb_close(usb_handle *h)
 {
-    D("[ usb close ... ]\n");
+    I("[ usb close ... ]\n");
     sdb_mutex_lock(&usb_lock);
     h->next->prev = h->prev;
     h->prev->next = h->next;
@@ -595,7 +596,7 @@ static void register_device(const char *dev_name,
         /* tizen specific */
         n = ioctl(usb->desc, USBDEVFS_RESET);
         if(n != 0) {
-            D("[ usb reset failed %s fd = %d]\n", usb->fname, usb->desc);
+            E("[ usb reset failed %s fd = %d]\n", usb->fname, usb->desc);
             goto fail;
         }
         n = ioctl(usb->desc, USBDEVFS_SETCONFIGURATION, &bConfigurationValue);
@@ -606,7 +607,7 @@ static void register_device(const char *dev_name,
 
         n = ioctl(usb->desc, USBDEVFS_CLAIMINTERFACE, &interface);
         if(n != 0) {
-            D("[ usb claim failed %s fd = %d]\n", usb->fname, usb->desc);
+            E("[ usb claim failed %s fd = %d]\n", usb->fname, usb->desc);
             goto fail;
         }
     }
@@ -674,7 +675,7 @@ static void register_device(const char *dev_name,
     return;
 
 fail:
-    D("[ usb open %s error=%d]\n",
+    E("[ usb open %s error=%d]\n",
         usb->fname,  errno);
     if(usb->desc >= 0) {
         sdb_close(usb->desc);
@@ -684,7 +685,7 @@ fail:
 
 void* device_poll_thread(void* unused)
 {
-    D("Created device thread\n");
+    I("Created device thread\n");
     for(;;) {
             /* XXX use inotify */
         find_usb_device("/dev/bus/usb", register_device);
index a4840c916483dbf1ef47a396560bdb97d43c7836..da86cd23fd3f414a943d0f4b3f9ea683851d73c3 100644 (file)
@@ -26,7 +26,8 @@
 
 #include "sysdeps.h"
 
-#define   TRACE_TAG  TRACE_USB
+//#define   TRACE_TAG  TRACE_USB
+#define LOG_TAG "SDBD_TRACE_USB"
 #include "log.h"
 
 #include "sdb.h"
@@ -58,20 +59,20 @@ static void *usb_open_thread(void *x)
             if (fd < 0) {
                 // to support older kernels
                 //fd = unix_open("/dev/android", O_RDWR);
-                D("[ opening %s device failed ]\n", USB_NODE_FILE);
+                E("[ 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) {
-            D("[closing fd exec failed ]\n");
+            E("[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);
     }
 
@@ -85,20 +86,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) {
-        D("ERROR: fd = %d, n = %d, errno = %d\n",
+        E("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.
@@ -109,14 +110,14 @@ int linux_usb_read(usb_handle *h, void *data, size_t len)
             if (errno == EINTR) {
                 continue;
             } else {
-                D("ERROR: fd = %d, n = %d, errno = %d\n", h->fd, n, errno);
+                E("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;
 }
 
@@ -128,7 +129,7 @@ void linux_usb_init()
 
     h = calloc(1, sizeof(usb_handle));
     if (h == NULL) {
-        D("failed to allocate memory of usb_handle\n");
+        E("failed to allocate memory of usb_handle\n");
         return;
     }
 
@@ -144,12 +145,12 @@ void linux_usb_init()
 #if 0 /* tizen specific */
     fd = unix_open("/dev/android_sdb_enable", O_RDWR);
     if (fd < 0) {
-       D("failed to open /dev/android_sdb_enable\n");
+       E("failed to open /dev/android_sdb_enable\n");
     } else {
         close_on_exec(fd);
     }
 #endif
-    D("[ usb_init - starting thread ]\n");
+    I("[ usb_init - starting thread ]\n");
     if(sdb_thread_create(&tid, usb_open_thread, h)){
         fatal_errno("cannot create usb thread");
     }
@@ -157,7 +158,7 @@ void linux_usb_init()
 
 void linux_usb_kick(usb_handle *h)
 {
-    D("usb_kick\n");
+    I("usb_kick\n");
     sdb_mutex_lock(&h->lock);
     sdb_close(h->fd);
     h->fd = -1;