From 11a92242676edbf9dfe88d401844e433f6ccb81b Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Thu, 25 Apr 2013 08:57:27 -0400 Subject: [PATCH] volser: Add -config and -logfile options Add options to specify alternate locations for the configuration files and the log file. This will be helpful for testing. Change-Id: I4169bc1944719773155931860c6a6dd2fd672f53 Reviewed-on: http://gerrit.openafs.org/9828 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- .../pod8/fragments/volserver-options.pod | 15 +++++++++++++ .../pod8/fragments/volserver-synopsis.pod | 1 + src/volser/volmain.c | 21 +++++++++++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/doc/man-pages/pod8/fragments/volserver-options.pod b/doc/man-pages/pod8/fragments/volserver-options.pod index 1ad49a069..4bc80e963 100644 --- a/doc/man-pages/pod8/fragments/volserver-options.pod +++ b/doc/man-pages/pod8/fragments/volserver-options.pod @@ -85,6 +85,21 @@ operations. This is the same as the B<-sync> option in L. See L. +=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. + =item B<-help> Prints the online help for this command. All other valid options are diff --git a/doc/man-pages/pod8/fragments/volserver-synopsis.pod b/doc/man-pages/pod8/fragments/volserver-synopsis.pod index 0340a50bc..1c1010681 100644 --- a/doc/man-pages/pod8/fragments/volserver-synopsis.pod +++ b/doc/man-pages/pod8/fragments/volserver-synopsis.pod @@ -1,6 +1,7 @@ B [B<-log>] S<<< [B<-p> >] >>> S<<< [B<-auditlog> >] >>> [B<-audit-interface> (file | sysvmq)] + S<<< [B<-logfile >] >>> S<<< [B<-config >] >>> S<<< [B<-udpsize> >] >>> S<<< [B<-d> >] >>> [B<-nojumbo>] [B<-jumbo>] diff --git a/src/volser/volmain.c b/src/volser/volmain.c index 286627d22..133284c92 100644 --- a/src/volser/volmain.c +++ b/src/volser/volmain.c @@ -77,6 +77,8 @@ int DoPreserveVolumeStats = 0; int rxJumbograms = 0; /* default is to not send and receive jumbograms. */ int rxMaxMTU = -1; char *auditFileName = NULL; +char *logFile = NULL; +char *configDir = NULL; #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */ afs_uint32 SHostAddrs[ADDRSPERSITE]; @@ -271,7 +273,9 @@ enum optionsList { OPT_process, OPT_preserve_vol_stats, OPT_sync, - OPT_syslog + OPT_syslog, + OPT_logfile, + OPT_config }; static int @@ -320,6 +324,10 @@ ParseArgs(int argc, char **argv) { #endif cmd_AddParmAtOffset(opts, OPT_sync, "-sync", CMD_SINGLE, CMD_OPTIONAL, "always | onclose | never"); + 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); @@ -384,6 +392,8 @@ ParseArgs(int argc, char **argv) { return -1; } } + cmd_OptionAsString(opts, OPT_logfile, &logFile); + cmd_OptionAsString(opts, OPT_config, &configDir); return 0; } @@ -430,6 +440,9 @@ main(int argc, char **argv) TTsleep = TTrun = 0; + configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH); + logFile = strdup(AFSDIR_SERVER_VOLSERLOG_FILEPATH); + ParseArgs(argc, argv); if (auditFileName) { @@ -458,7 +471,7 @@ main(int argc, char **argv) #endif /* Open VolserLog and map stdout, stderr into it; VInitVolumePackage2 can log, so we need to do this here */ - OpenLog(AFSDIR_SERVER_VOLSERLOG_FILEPATH); + OpenLog(logFile); VOptDefaults(volumeServer, &opts); if (VInitVolumePackage2(volumeServer, &opts)) { @@ -533,10 +546,10 @@ main(int argc, char **argv) /* Create a single security object, in this case the null security object, for unauthenticated connections, which will be used to control security on connections made to this server */ - tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); + tdir = afsconf_Open(configDir); if (!tdir) { Abort("volser: could not open conf files in %s\n", - AFSDIR_SERVER_ETC_DIRPATH); + configDir); VS_EXIT(1); } -- 2.39.5