From dea3eb17ad4325ac20d1535c1c030a9ac580da81 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Thu, 25 Apr 2013 09:26:46 -0400 Subject: [PATCH] viced: Add support for -config and -logfile options Add options to the fileserver to specify alternate locations for the log file and the config. This will be useful for testing purposes. Change-Id: I3550bd993fe5fd2cd9b90425962c95cb1c7d98ea Reviewed-on: http://gerrit.openafs.org/9830 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- .../pod8/fragments/dafileserver-synopsis.pod | 1 + doc/man-pages/pod8/fragments/fileserver-options.pod | 15 +++++++++++++++ doc/man-pages/pod8/fragments/fileserver-synopsis.pod | 1 + src/viced/viced.c | 20 +++++++++++++++----- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod b/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod index f1f633c..3a5aa3c 100644 --- a/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod +++ b/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod @@ -56,3 +56,4 @@ B S<<< [B<-unsafe-nosalvage>] >>> S<<< [B<-offline-timeout> >] >>> S<<< [B<-offline-shutdown-timeout> >] >>> + S<<< [B<-logfile >] >>> S<<< [B<-config >] >>> diff --git a/doc/man-pages/pod8/fragments/fileserver-options.pod b/doc/man-pages/pod8/fragments/fileserver-options.pod index a35faa0..d2059ea 100644 --- a/doc/man-pages/pod8/fragments/fileserver-options.pod +++ b/doc/man-pages/pod8/fragments/fileserver-options.pod @@ -426,3 +426,18 @@ any other option, whereas others argue that choosing anything besides the C option allows for an unacceptable risk of data loss. This may depend on your usage patterns, your platform and filesystem, and who you talk to about this topic. + +=item B<-logfile> > + +Sets the file to use for server logging. If logfile is not specified and +no other logging options are supplied, this will be F. +Note that this option is intended for debugging and testing purposes. +Changing the location of the log file from the command line may result +in undesirable interactions with tools such as B. + +=item B<-config> > + +Set the location of the configuration directory used to configure this +service. In a typical configuration this will be F - this +option allows the use of alternative configuration locations for testing +purposes. diff --git a/doc/man-pages/pod8/fragments/fileserver-synopsis.pod b/doc/man-pages/pod8/fragments/fileserver-synopsis.pod index 1dc3188..e6210a5 100644 --- a/doc/man-pages/pod8/fragments/fileserver-synopsis.pod +++ b/doc/man-pages/pod8/fragments/fileserver-synopsis.pod @@ -48,3 +48,4 @@ B S<<< [B<-offline-timeout> >] >>> S<<< [B<-offline-shutdown-timeout> >] >>> S<<< [B<-sync> >] >>> + S<<< [B<-logfile >] >>> S<<< [B<-config >] >>> diff --git a/src/viced/viced.c b/src/viced/viced.c index afffe53..10bd61d 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -93,6 +93,7 @@ static afs_int32 Do_VLRegisterRPC(void); int eventlog = 0, rxlog = 0; FILE *debugFile; +char *logFile = NULL; pthread_mutex_t fsync_glock_mutex; pthread_cond_t fsync_cond; @@ -1161,12 +1162,16 @@ ParseArgs(int argc, char *argv[]) cmd_AddParmAtOffset(opts, OPT_sync, "-sync", CMD_SINGLE, CMD_OPTIONAL, "always | onclose | never"); + /* testing options */ + cmd_AddParmAtOffset(opts, OPT_logfile, "-logfile", CMD_SINGLE, + CMD_OPTIONAL, "location of log file"); + cmd_AddParmAtOffset(opts, OPT_config, "-config", CMD_SINGLE, + CMD_OPTIONAL, "configuration location"); + code = cmd_Parse(argc, argv, &opts); if (code) return -1; - /* XXX - cmd_OptionAsString(opts, OPT_config, &configDir); */ - cmd_OpenConfigFile(AFSDIR_SERVER_CONFIG_FILE_FILEPATH); cmd_SetCommandName("fileserver"); @@ -1355,7 +1360,6 @@ ParseArgs(int argc, char *argv[]) } cmd_OptionAsInt(opts, OPT_debug, &LogLevel); - /* XXX - cmd_OptionAsString(opts, OPT_logfile, &logFile); */ cmd_OptionAsFlag(opts, OPT_mrafslogs, &mrafsStyleLogs); if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) { @@ -1423,6 +1427,10 @@ ParseArgs(int argc, char *argv[]) busy_threshold = 3 * rxpackets / 2; } + cmd_OptionAsString(opts, OPT_logfile, &logFile); + cmd_OptionAsString(opts, OPT_config, &FS_configPath); + + if (auditFileName) osi_audit_file(auditFileName); @@ -1849,6 +1857,9 @@ main(int argc, char *argv[]) /* check for the parameter file */ CheckParms(); + FS_configPath = strdup(AFSDIR_SERVER_ETC_DIRPATH); + logFile = strdup(AFSDIR_SERVER_FILELOG_FILEPATH); + if (ParseArgs(argc, argv)) { exit(-1); } @@ -1861,7 +1872,6 @@ main(int argc, char *argv[]) exit(1); } #endif - FS_configPath = strdup(AFSDIR_SERVER_ETC_DIRPATH); confDir = afsconf_Open(FS_configPath); if (!confDir) { @@ -1877,7 +1887,7 @@ main(int argc, char *argv[]) #ifndef AFS_NT40_ENV serverLogSyslogTag = "fileserver"; #endif - OpenLog(AFSDIR_SERVER_FILELOG_FILEPATH); + OpenLog(logFile); SetupLogSignals(); LogCommandLine(argc, argv, "starting", "", "File server", FSLog); -- 1.9.4