From: sooyeon.kim Date: Fri, 20 Jan 2017 07:37:45 +0000 (+0900) Subject: Fix engine parser to access directories X-Git-Tag: accepted/tizen/unified/20170428.004007~6^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fstt.git;a=commitdiff_plain;h=f744e25a4a0ad43d1889ccf9216eddd5a1f148d2 Fix engine parser to access directories Change-Id: I5d832f4a5715823aff37dc001d46c221a98f0e74 Signed-off-by: sooyeon.kim (cherry picked from commit 7182e71ccfbd807230f99c9a4fbe73cc49511da2) --- diff --git a/engine-parser/src/stt-engine-parser.c b/engine-parser/src/stt-engine-parser.c index ecf2ba0..281818c 100644 --- a/engine-parser/src/stt-engine-parser.c +++ b/engine-parser/src/stt-engine-parser.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -161,9 +162,11 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t LOGD("[DEBUG] dir_engine_info(%s)", dir_engine_info); /* Make directories */ - if (0 != access(dir_config_base, F_OK)) { +// if (0 != access(dir_config_base, F_OK)) { + if (-1 == open(dir_config_base, O_DIRECTORY)) { + LOGE("[INFO] No directory : %s, errno : %d", dir_config_base, errno); if (0 != mkdir(dir_config_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - LOGE("[ERROR] Fail to make directory : %s", dir_config_base); + LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_config_base, errno); free(dir_config_base); dir_config_base = NULL; free(dir_home); @@ -176,16 +179,18 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t } else { LOGD("Success to make directory : %s", dir_config_base); if (0 != chown(dir_config_base, tmp_uid, tmp_gid)) { - LOGD("[ERROR] Fail to change user and group"); + LOGD("[ERROR] Fail to change user and group, errno : %d", errno); } else { LOGD("[DEBUG] Success to change user and group"); } } } - if (0 != access(dir_home, F_OK)) { +// if (0 != access(dir_home, F_OK)) { + if (-1 == open(dir_home, O_DIRECTORY)) { + LOGE("[INFO] No directory : %s, errno : %d", dir_home, errno); if (0 != mkdir(dir_home, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - LOGE("[ERROR] Fail to make directory : %s", dir_home); + LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_home, errno); free(dir_config_base); dir_config_base = NULL; free(dir_home); @@ -198,16 +203,18 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t } else { LOGD("Success to make directory : %s", dir_home); if (0 != chown(dir_home, tmp_uid, tmp_gid)) { - LOGD("[ERROR] Fail to change user and group"); + LOGD("[ERROR] Fail to change user and group, errno : %d", errno); } else { LOGD("[DEBUG] Success to change user and group"); } } } - if (0 != access(dir_engine_base, F_OK)) { +// if (0 != access(dir_engine_base, F_OK)) { + if (-1 == open(dir_engine_base, O_DIRECTORY)) { + LOGE("[INFO] No directory : %s, errno : %d", dir_engine_base, errno); if (0 != mkdir(dir_engine_base, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - LOGE("[ERROR] Fail to make directory : %s", dir_engine_base); + LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_base, errno); free(dir_config_base); dir_config_base = NULL; free(dir_home); @@ -220,16 +227,18 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t } else { LOGD("Success to make directory : %s", dir_engine_base); if (0 != chown(dir_engine_base, tmp_uid, tmp_gid)) { - LOGD("[ERROR] Fail to change user and group"); + LOGD("[ERROR] Fail to change user and group, errno : %d", errno); } else { LOGD("[DEBUG] Success to change user and group"); } } } - if (0 != access(dir_engine_info, F_OK)) { +// if (0 != access(dir_engine_info, F_OK)) { + if (-1 == open(dir_engine_info, O_DIRECTORY)) { + LOGE("[INFO] No directory : %s, errno : %d", dir_engine_info, errno); if (0 != mkdir(dir_engine_info, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { - LOGE("[ERROR] Fail to make directory : %s", dir_engine_info); + LOGE("[ERROR] Fail to make directory : %s, errno : %d", dir_engine_info, errno); free(dir_config_base); dir_config_base = NULL; free(dir_home); @@ -242,7 +251,7 @@ static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t } else { LOGD("Success to make directory : %s", dir_engine_info); if (0 != chown(dir_engine_info, tmp_uid, tmp_gid)) { - LOGD("[ERROR] Fail to change user and group"); + LOGD("[ERROR] Fail to change user and group, errno : %d", errno); } else { LOGD("[DEBUG] Success to change user and group"); }