salvageserver: Add -logfile option
authorMarc Dionne <marc.dionne@your-file-system.com>
Thu, 25 Apr 2013 15:13:09 +0000 (11:13 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Sun, 2 Jun 2013 12:40:38 +0000 (05:40 -0700)
Allow an alternate location to be specified for the logfile.

Change-Id: I55a05576746e115478a8e48df22f4fdb26634f05
Reviewed-on: http://gerrit.openafs.org/9831
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

doc/man-pages/pod8/salvageserver.pod
src/vol/salvaged.c

index a93a33e..bd8e00a 100644 (file)
@@ -290,6 +290,14 @@ directory.
 Salvageserver runs in client Mode.  The requested volume on the requested
 partition will be scheduled for salvaging by the Salvageserver daemon.
 
+=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/SalsrvLog>.
+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<-help>
 
 Prints the online help for this command. All other valid options are
index bacc860..44ba9c2 100644 (file)
 #include <pthread.h>
 #endif
 
+char *logFileName = NULL;
 
 #if !defined(AFS_DEMAND_ATTACH_FS)
 #error "online salvager only supported for demand attach fileserver"
@@ -183,6 +184,7 @@ enum optionsList {
     OPT_syslog,
     OPT_syslogfacility,
     OPT_datelogs,
+    OPT_logfile,
     OPT_client
 };
 
@@ -378,6 +380,8 @@ main(int argc, char **argv)
     arock.argc = argc;
     arock.argv = argv;
 
+    logFileName = strdup(AFSDIR_SERVER_SALSRVLOG_FILEPATH);
+
     ts = cmd_CreateSyntax("initcmd", handleit, &arock, "initialize the program");
     cmd_AddParmAtOffset(ts, OPT_partition, "-partition", CMD_SINGLE,
            CMD_OPTIONAL, "Name of partition to salvage");
@@ -418,6 +422,9 @@ main(int argc, char **argv)
     cmd_AddParmAtOffset(ts, OPT_client, "-client", CMD_FLAG, CMD_OPTIONAL,
                "Use SALVSYNC to ask salvageserver to salvage a volume");
 
+    cmd_AddParmAtOffset(ts, OPT_logfile, "-logfile", CMD_SINGLE, CMD_OPTIONAL,
+           "Location of log file ");
+
     err = cmd_Dispatch(argc, argv);
     Exit(err);
     return 0; /* not reached */
@@ -496,7 +503,7 @@ SalvageServer(int argc, char **argv)
      * multiple salvagers appending to the log.
      */
 
-    CheckLogFile((char *)AFSDIR_SERVER_SALSRVLOG_FILEPATH);
+    CheckLogFile(logFileName);
 #ifndef AFS_NT40_ENV
 #ifdef AFS_LINUX20_ENV
     fcntl(fileno(logFile), F_SETFL, O_APPEND); /* Isn't this redundant? */