bugfix: must check and create data path

pull/348/head
YuQing 2019-10-25 11:58:20 +08:00
parent ecca01766a
commit 6b1f5e0cca
4 changed files with 37 additions and 16 deletions

View File

@ -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

View File

@ -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)

View File

@ -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 ((result=storage_check_and_make_data_path()) != 0)
{
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;
return result;
}
STORAGE_CHOWN(data_path, geteuid(), getegid())
}
g_last_server_port = g_server_port;
g_last_http_port = g_http_port;
g_storage_join_time = g_current_time;

View File

@ -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)) \
{ \