salvage-allow-hardlinked-logs-by-date-20030515

FIXES 1259

a switch causes salvager to create salvagelog hardlinks by date so
logs are preserved forever
This commit is contained in:
Jeffrey Hutzelman 2003-05-15 17:23:37 +00:00 committed by Derrick Brashear
parent 390083af2e
commit 5012151295

View File

@ -398,6 +398,9 @@ char * ToString(char *s);
void AskOffline(VolumeId volumeId);
void AskOnline(VolumeId volumeId, char *partition);
void CheckLogFile(void);
#ifndef AFS_NT40_ENV
void TimeStampLogFile(void);
#endif
void ClearROInUseBit(struct VolumeSummary *summary);
void CopyAndSalvage(register struct DirSummary *dir);
int CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume);
@ -580,18 +583,21 @@ static int handleit(struct cmd_syndesc *as)
}
#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);
}
if ( ti = as->parms[16].items) { /* -syslog */
useSyslog = 1;
ShowLog = 0;
}
if ( ti = as->parms[17].items) { /* -syslogfacility */
useSyslogFacility = atoi(ti->data);
}
if (ti = as->parms[18].items) { /* -datelogs */
TimeStampLogFile();
}
#endif
#ifdef FAST_RESTART
if (ti = as->parms[18].items) { /* -DontSalvage */
if (ti = as->parms[19].items) { /* -DontSalvage */
char *msg = "Exiting immediately without salvage. Look into the FileLog to find volumes which really need to be salvaged!";
if ( useSyslog )
@ -772,6 +778,7 @@ int main(int argc, char **argv)
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");
cmd_AddParm(ts, "-datelogs", CMD_FLAG, CMD_OPTIONAL, "Include timestamp in logfile filename");
#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");
@ -3601,6 +3608,26 @@ void CheckLogFile(void)
}
}
#ifndef AFS_NT40_ENV
void TimeStampLogFile(void)
{
char stampSlvgLog[AFSDIR_PATH_MAX];
struct tm *lt;
time_t now;
now = time(0);
lt = localtime(&now);
sprintf(stampSlvgLog, "%s.%04d-%02d-%02d.%02d:%02d:%02d",
AFSDIR_SERVER_SLVGLOG_FILEPATH,
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
lt->tm_hour, lt->tm_min, lt->tm_sec);
/* try to link the logfile to a timestamped filename */
/* if it fails, oh well, nothing we can do */
link(AFSDIR_SERVER_SLVGLOG_FILEPATH, stampSlvgLog);
}
#endif
void showlog(void)
{
char line[256];