OPT_blockreads,
OPT_parallel,
OPT_tmpdir,
- OPT_showlog,
OPT_orphans,
OPT_syslog,
OPT_syslogfacility,
- OPT_datelogs,
OPT_logfile,
OPT_client
};
free(optstring);
optstring = NULL;
}
- cmd_OptionAsFlag(opts, OPT_showlog, &ShowLog);
if (cmd_OptionAsString(opts, OPT_orphans, &optstring) == 0) {
if (Testing)
orphans = ORPH_IGNORE;
#ifndef AFS_NT40_ENV /* ignore options on NT */
if (cmd_OptionPresent(opts, OPT_syslog)) {
useSyslog = 1;
- ShowLog = 0;
}
cmd_OptionAsInt(opts, OPT_syslogfacility, &useSyslogFacility);
-
- if (cmd_OptionPresent(opts, OPT_datelogs)) {
- TimeStampLogFile((char *)AFSDIR_SERVER_SALSRVLOG_FILEPATH);
- }
#endif
if (cmd_OptionPresent(opts, OPT_client)) {
vid = (VolumeId)vid_l;
}
- if (ShowLog) {
- printf("-showlog does not work with -client\n");
- exit(-1);
- }
-
if (!seenpart || !seenvol) {
printf("You must specify '-partition' and '-volumeid' with the '-client' option\n");
exit(-1);
logFileName = strdup(AFSDIR_SERVER_SALSRVLOG_FILEPATH);
- ts = cmd_CreateSyntax("initcmd", handleit, &arock, "initialize the program");
+ ts = cmd_CreateSyntax("initcmd", handleit, &arock, 0, "initialize the program");
cmd_AddParmAtOffset(ts, OPT_partition, "-partition", CMD_SINGLE,
CMD_OPTIONAL, "Name of partition to salvage");
cmd_AddParmAtOffset(ts, OPT_volumeid, "-volumeid", CMD_SINGLE, CMD_OPTIONAL,
"# of max parallel partition salvaging");
cmd_AddParmAtOffset(ts, OPT_tmpdir, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
"Name of dir to place tmp files ");
- cmd_AddParmAtOffset(ts, OPT_showlog, "-showlog", CMD_FLAG, CMD_OPTIONAL,
- "Show log file upon completion");
cmd_AddParmAtOffset(ts, OPT_orphans, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
"ignore | remove | attach");
"Write salvage log to syslogs");
cmd_AddParmAtOffset(ts, OPT_syslogfacility, "-syslogfacility", CMD_SINGLE,
CMD_OPTIONAL, "Syslog facility number to use");
- cmd_AddParmAtOffset(ts, OPT_datelogs, "-datelogs", CMD_FLAG, CMD_OPTIONAL,
- "Include timestamp in logfile filename");
#endif
cmd_AddParmAtOffset(ts, OPT_client, "-client", CMD_FLAG, CMD_OPTIONAL,
SALVSYNC_response_hdr sres;
VolumePackageOptions opts;
+ /* Send Log() messages to stderr in client mode. */
+ logFile = stderr;
+
VOptDefaults(volumeUtility, &opts);
if (VInitVolumePackage2(volumeUtility, &opts)) {
/* VInitVolumePackage2 can fail on e.g. partition attachment errors,
static int
DoSalvageVolume(struct SalvageQueueNode * node, int slot)
{
- char childLog[AFSDIR_PATH_MAX];
+ char *childLog;
struct DiskPartition64 * partP;
/* do not allow further forking inside salvager */
* another thread may have held the lock on the FILE
* structure when fork was called! */
- snprintf(childLog, sizeof(childLog), "%s.%d",
- AFSDIR_SERVER_SLVGLOG_FILEPATH, getpid());
-
- logFile = afs_fopen(childLog, "a");
- if (!logFile) { /* still nothing, use stdout */
+ if (asprintf(&childLog, "%s.%d",
+ AFSDIR_SERVER_SLVGLOG_FILEPATH, getpid()) < 0) {
logFile = stdout;
- ShowLog = 0;
+ } else {
+ logFile = afs_fopen(childLog, "a");
+ if (!logFile) { /* still nothing, use stdout */
+ logFile = stdout;
+ }
+ free(childLog);
}
if (node->command.sop.parent <= 0) {
SalvageLogCleanup(int pid)
{
int pidlog, len;
- char fn[AFSDIR_PATH_MAX];
+ char *fn;
static char buf[LOG_XFER_BUF_SIZE];
- snprintf(fn, sizeof(fn), "%s.%d",
- AFSDIR_SERVER_SLVGLOG_FILEPATH, pid);
-
+ if (asprintf(&fn, "%s.%d", AFSDIR_SERVER_SLVGLOG_FILEPATH, pid) < 0)
+ return 1;
pidlog = open(fn, O_RDONLY);
unlink(fn);
+ free(fn);
if (pidlog < 0)
return 1;
SalvageLogScanningThread(void * arg)
{
struct rx_queue log_watch_queue;
+ char *prefix;
+ int prefix_len;
queue_Init(&log_watch_queue);
- {
+ prefix_len = asprintf(&prefix, "%s.", AFSDIR_SLVGLOG_FILE);
+ if (prefix_len >= 0) {
DIR *dp;
struct dirent *dirp;
- char prefix[AFSDIR_PATH_MAX];
- size_t prefix_len;
-
- snprintf(prefix, sizeof(prefix), "%s.", AFSDIR_SLVGLOG_FILE);
- prefix_len = strlen(prefix);
dp = opendir(AFSDIR_LOGS_DIR);
opr_Assert(dp);
queue_Append(&log_watch_queue, cleanup);
}
-
+ free(prefix);
closedir(dp);
}