volser: Add -config and -logfile options
authorMarc Dionne <marc.dionne@your-file-system.com>
Thu, 25 Apr 2013 12:57:27 +0000 (08:57 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Sun, 2 Jun 2013 12:39:55 +0000 (05:39 -0700)
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 <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

doc/man-pages/pod8/fragments/volserver-options.pod
doc/man-pages/pod8/fragments/volserver-synopsis.pod
src/volser/volmain.c

index 1ad49a0..4bc80e9 100644 (file)
@@ -85,6 +85,21 @@ operations.
 This is the same as the B<-sync> option in L<fileserver(8)>. See
 L<fileserver(8)>.
 
+=item B<-logfile> <I<log file>>
+
+Sets the file to use for server logging.  If logfile is not specified and
+no other logging options are supplied, this will be F</usr/afs/logs/VolserLog>.
+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<bos>.
+
+=item B<-config> <I<configuration directory>>
+
+Set the location of the configuration directory used to configure this
+service.  In a typical configuration this will be F</usr/afs/etc> - 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
index 0340a50..1c10106 100644 (file)
@@ -1,6 +1,7 @@
 B<volserver>
     [B<-log>] S<<< [B<-p> <I<number of processes>>] >>>
     S<<< [B<-auditlog> <I<log path>>] >>> [B<-audit-interface> (file | sysvmq)]
+    S<<< [B<-logfile <I<log file>>] >>> S<<< [B<-config <I<configuration path>>] >>>
     S<<< [B<-udpsize> <I<size of socket buffer in bytes>>] >>>
     S<<< [B<-d> <I<debug level>>] >>>
     [B<-nojumbo>] [B<-jumbo>] 
index 286627d..133284c 100644 (file)
@@ -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);
     }