#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <fcntl.h>
#include <tzplatform_config.h>
#include <systemd/sd-login.h>
/* 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);
} 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);
} 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);
} 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);
} 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");
}