diff --git a/HISTORY b/HISTORY index 0ccafe7..f77e853 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,9 @@ -Version 6.01 2019-10-23 +Version 6.01 2019-10-25 * compress and uncompress binlog file by gzip when need, config items in storage.conf: compress_binlog and compress_binlog_time + * bugfix: must check and create data path before write_to_pid_file + in fdfs_storaged.c Version 6.00 2019-10-16 * tracker and storage server support dual IPs diff --git a/storage/fdfs_storaged.c b/storage/fdfs_storaged.c index db6e846..c2fc25b 100644 --- a/storage/fdfs_storaged.c +++ b/storage/fdfs_storaged.c @@ -107,6 +107,11 @@ int main(int argc, char *argv[]) return result; } + if ((result=storage_check_and_make_data_path()) != 0) + { + log_destroy(); + return result; + } snprintf(pidFilename, sizeof(pidFilename), "%s/data/fdfs_storaged.pid", g_fdfs_base_path); if ((result=process_action(pidFilename, argv[2], &stop)) != 0) diff --git a/storage/storage_func.c b/storage/storage_func.c index 7da246e..4229b15 100644 --- a/storage/storage_func.c +++ b/storage/storage_func.c @@ -684,6 +684,29 @@ int storage_write_to_sync_ini_file() return 0; } +int storage_check_and_make_data_path() +{ + char data_path[MAX_PATH_SIZE]; + snprintf(data_path, sizeof(data_path), "%s/data", + g_fdfs_base_path); + if (!fileExists(data_path)) + { + if (mkdir(data_path, 0755) != 0) + { + logError("file: "__FILE__", line: %d, " + "mkdir \"%s\" fail, " + "errno: %d, error info: %s", + __LINE__, data_path, + errno, STRERROR(errno)); + return errno != 0 ? errno : EPERM; + } + + STORAGE_CHOWN(data_path, geteuid(), getegid()) + } + + return 0; +} + static int storage_check_and_make_data_dirs() { int result; @@ -820,21 +843,10 @@ static int storage_check_and_make_data_dirs() } else { - if (!fileExists(data_path)) - { - if (mkdir(data_path, 0755) != 0) - { - logError("file: "__FILE__", line: %d, " \ - "mkdir \"%s\" fail, " \ - "errno: %d, error info: %s", \ - __LINE__, data_path, \ - errno, STRERROR(errno)); - return errno != 0 ? errno : EPERM; - } - - STORAGE_CHOWN(data_path, geteuid(), getegid()) - } - + if ((result=storage_check_and_make_data_path()) != 0) + { + return result; + } g_last_server_port = g_server_port; g_last_http_port = g_http_port; g_storage_join_time = g_current_time; diff --git a/storage/storage_func.h b/storage/storage_func.h index 1208498..5960ac4 100644 --- a/storage/storage_func.h +++ b/storage/storage_func.h @@ -37,6 +37,8 @@ bool storage_id_is_myself(const char *storage_id); int storage_set_tracker_client_ips(ConnectionInfo *conn, const int tracker_index); +int storage_check_and_make_data_path(); + #define STORAGE_CHOWN(path, current_uid, current_gid) \ if (!(g_run_by_gid == current_gid && g_run_by_uid == current_uid)) \ { \