From: Nathan Neulinger Date: Wed, 4 Apr 2001 18:12:18 +0000 (+0000) Subject: salvager-syslog-support-20010404 X-Git-Tag: openafs-stable-1_1_0~228 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=3c597bf21878fa5a2ea776e81a01d72844b26909 salvager-syslog-support-20010404 support for salvager to syslog instead of logging to file --- diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 500eeb4..eb74b08 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -171,6 +171,9 @@ Vnodes with 0 inode pointers in RW volumes are now deleted. #include #include #include /* signal(), kill(), wait(), etc. */ +#ifndef AFS_NT40_ENV +#include +#endif #include "nfs.h" #include "lwp.h" @@ -212,6 +215,12 @@ int ShowSuid = 0; /* -showsuid flag */ int ShowMounts = 0; /* -showmounts flag */ int orphans = ORPH_IGNORE; /* -orphans option */ int Showmode = 0; + +#ifndef AFS_NT40_ENV +int useSyslog = 0; /* -syslog flag */ +int useSyslogFacility = LOG_DAEMON; /* -syslogfacility option */ +#endif + #define MAXPARALLEL 32 int OKToZap; /* -o flag */ @@ -552,8 +561,19 @@ static handleit(as) orphans = ORPH_ATTACH; } +#ifndef AFS_NT40_ENV /* ignore options on NT */ + if ( ti = as->parms[16].items) { /* -syslog */ + useSyslog = 1; + ShowLog = 0; + } + if ( ti = as->parms[17].items) { /* -syslogfacility */ + useSyslogFacility = atoi(ti->data); + } +#endif + + #ifdef FAST_RESTART - if (ti = as->parms[16].items) { /* -DontSalvage */ + if (ti = as->parms[18].items) { /* -DontSalvage */ printf("Exiting immediately without salvage. Look into the FileLog"); printf(" to find volumes which really need to be salvaged!\n"); Exit(0); @@ -726,6 +746,12 @@ char **argv; cmd_AddParm(ts, "-showsuid", CMD_FLAG,CMD_OPTIONAL, "Report on suid/sgid files"); cmd_AddParm(ts, "-showmounts", CMD_FLAG,CMD_OPTIONAL, "Report on mountpoints"); cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL, "ignore | remove | attach"); + + /* note - syslog isn't avail on NT, but if we make it conditional, have + to deal with screwy offsets for cmd params */ + cmd_AddParm(ts, "-syslog", CMD_FLAG, CMD_OPTIONAL, "Write salvage log to syslogs"); + cmd_AddParm(ts, "-syslogfacility", CMD_SINGLE, CMD_OPTIONAL, "Syslog facility number to use"); + #ifdef FAST_RESTART cmd_AddParm(ts, "-DontSalvage", CMD_FLAG, CMD_OPTIONAL, "Don't salvage. This my be set in BosConfig to let the fileserver restart immediately after a crash. Bad volumes will be taken offline"); #endif /* FAST_RESTART */ @@ -1010,8 +1036,15 @@ void SalvageFileSysParallel(struct DiskPartition *partP) ShowLog = 0; for (fd =0; fd < 16; fd++) close(fd); open("/", 0); dup2(0, 1); dup2(0, 2); - sprintf(logFileName, "%s.%d", AFSDIR_SERVER_SLVGLOG_FILEPATH, jobs[startjob]->jobnumb); - logFile = fopen(logFileName, "w"); +#ifndef AFS_NT40_ENV + if ( useSyslog ) { + openlog(NULL, LOG_PID, useSyslogFacility); + } else +#endif + { + sprintf(logFileName, "%s.%d", AFSDIR_SERVER_SLVGLOG_FILEPATH, jobs[startjob]->jobnumb); + logFile = fopen(logFileName, "w"); + } if (!logFile) logFile = stdout; SalvageFileSys1(jobs[startjob]->partP, 0); @@ -1022,6 +1055,9 @@ void SalvageFileSysParallel(struct DiskPartition *partP) } /* while ( thisjob || (!partP && numjobs > 0) ) */ /* If waited for all jobs to complete, now collect log files and return */ +#ifndef AFS_NT40_ENV + if ( ! useSyslog ) /* if syslogging - no need to collect */ +#endif if (!partP) { for (i=0; i