return -1;
}
- if (0 > chmod(filename, 0666)) {
+ if (0 > chmod(filename, 0600)) {
SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to change file mode");
return -1;
}
return -1;
}
- if (0 > chmod(filename, 0666)) {
+ if (0 > chmod(filename, 0600)) {
SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to change file mode");
return -1;
}
char normal_file_name[128] = {'\0',};
g_count++;
- snprintf(normal_file_name, sizeof(normal_file_name), "/tmp/vc_normal_%d_%d", getpid(), g_count);
+ while (1) {
+ snprintf(normal_file_name, sizeof(normal_file_name), "/tmp/vc_normal_%d_%d", getpid(), g_count);
+ ret = access(normal_file_name, 0);
+
+ if (0 == ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] File is already exist");
+ if (0 == remove(normal_file_name)) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Remove file");
+ break;
+ } else {
+ g_count++;
+ }
+ } else {
+ break;
+ }
+ }
+
SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] File normal name : %s", normal_file_name);
/* open test file */
- g_normal_file = fopen(normal_file_name, "wb+");
+ g_normal_file = fopen(normal_file_name, "wb+x");
if (!g_normal_file) {
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] File not found!");
}