Skip to content

Commit

Permalink
(master+cs) added error message when a config file can't be loaded (i…
Browse files Browse the repository at this point in the history
…ssue #457)
  • Loading branch information
acid-maker committed Oct 20, 2021
1 parent 89e28fb commit bba0e57
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ This file lists noteworthy changes in MooseFS.
* MooseFS 3.0.117-1 (WIP)

- (master) fixed handling abnormal operation status (issue #456)
- (master+cs) added error message when a config file can't be loaded (issue #457)

* MooseFS 3.0.116-1 (2021-08-10)

Expand Down
7 changes: 6 additions & 1 deletion mfschunkserver/hddspacemgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7197,7 +7197,7 @@ int hdd_folders_reinit(void) {
hddfname = strdup(ETC_PATH "/mfs/mfshdd.cfg");
passert(hddfname);
fd = fopen(hddfname,"r");
if (!fd) {
if (!fd && errno==ENOENT) {
free(hddfname);
hddfname = strdup(ETC_PATH "/mfshdd.cfg");
fd = fopen(hddfname,"r");
Expand All @@ -7211,6 +7211,11 @@ int hdd_folders_reinit(void) {
}

if (!fd) {
if (errno==ENOENT) {
mfs_arg_syslog(LOG_WARNING,"hdd space configuration file (%s) not found",hddfname);
} else {
mfs_arg_errlog(LOG_WARNING,"can't open hdd space configuration file (%s), error",hddfname);
}
free(hddfname);
return -1;
}
Expand Down
8 changes: 6 additions & 2 deletions mfsclient/mfsmount.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,11 @@ static void mfs_opt_parse_cfg_file(const char *filename,int optional,struct fuse
fd = fopen(filename,"r");
if (fd==NULL) {
if (optional==0) {
fprintf(stderr,"can't open cfg file: %s\n",filename);
if (errno==ENOENT) {
fprintf(stderr,"cfg file (%s) doesn't exist\n",filename);
} else {
fprintf(stderr,"can't open cfg file (%s), error: %s\n",filename,strerr(errno));
}
abort();
}
return;
Expand Down Expand Up @@ -611,7 +615,7 @@ static int mfs_opt_proc_stage2(void *data, const char *arg, int key, struct fuse
fuse_opt_add_arg(&helpargs,outargs->argv[0]);
fuse_opt_add_arg(&helpargs,"--version");
fuse_parse_cmdline(&helpargs,NULL,NULL,NULL);
fuse_mount(NULL,&helpargs);
fuse_mount("",&helpargs);
}
#endif
exit(0);
Expand Down
8 changes: 7 additions & 1 deletion mfscommon/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#ifdef WIN32
#include "portable.h"
#else
Expand All @@ -33,6 +34,7 @@

#include "cfg.h"
#include "massert.h"
#include "strerr.h"
#ifdef WIN32
#include <stdarg.h>
static inline void mfs_arg_syslog(uint8_t level,const char *format,...) {
Expand Down Expand Up @@ -66,7 +68,11 @@ int cfg_reload (void) {

fd = fopen(cfgfname,"r");
if (fd==NULL) {
mfs_arg_syslog(LOG_ERR,"cannot load config file: %s",cfgfname);
if (errno==ENOENT) {
mfs_arg_syslog(LOG_ERR,"main config file (%s) not found",cfgfname);
} else {
mfs_arg_syslog(LOG_ERR,"can't load main config file (%s), error: %s",cfgfname,strerr(errno));
}
return 0;
}
while (paramhead!=NULL) {
Expand Down
16 changes: 8 additions & 8 deletions mfscommon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,14 +1402,6 @@ int main(int argc,char **argv) {
mfs_syslog(LOG_WARNING,"default sysconf path has changed - please move " STR(APPNAME) ".cfg from "ETC_PATH"/ to "ETC_PATH"/mfs/");
}

if (runmode==RM_START || runmode==RM_RESTART || runmode==RM_TRY_RESTART) {
if (rundaemon) {
makedaemon();
} else {
set_signal_handlers(0);
}
}

if (cfg_load(cfgfile,logundefined)==0) {
if (userconfig) {
if (rundaemon) {
Expand All @@ -1423,6 +1415,14 @@ int main(int argc,char **argv) {
}
free(cfgfile);

if (runmode==RM_START || runmode==RM_RESTART || runmode==RM_TRY_RESTART) {
if (rundaemon) {
makedaemon();
} else {
set_signal_handlers(0);
}
}

processname_init(argc_back,argv_back); // prepare everything for 'processname_set'

logappname = cfg_getstr("SYSLOG_IDENT",STR(APPNAME));
Expand Down

0 comments on commit bba0e57

Please sign in to comment.