/*
* Copyright (c) 1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#include "dump.h"
#ifdef __STDC__
static void alarmcatch();
static int idatesort(const void *, const void *);
#else /* !__STDC__ */
static void alarmcatch();
static int idatesort();
#endif
#ifdef DEBUG
extern int xflag;
#endif
/*
* Query the operator; This fascist piece of code requires
* an exact response.
* It is intended to protect dump aborting by inquisitive
* people banging on the console terminal to see what is
* happening which might cause dump to croak, destroying
* a large number of hours of work.
*
* Every time += 2 minutes we reprint the message, alerting others
* that dump needs attention.
*/
int
char *question;
{
while (def == -1)
return (def);
}
static int in_query_once;
/* real simple check-sum */
static int
addem(s)
char *s;
{
int total = 0;
if (s == (char *)NULL)
return (total);
while (*s)
total += *s++;
return (total);
}
int
char *question;
int def;
{
static char *lastmsg;
static int lastmsgsum;
int msgsum;
int back;
/* special hook to flush timeout cache */
lastmsgsum = 0;
return (0);
}
/*
* Only reset the state if the message changed somehow
*/
timeout = 0;
if (telapsed && tstart_writing)
lastmsgsum = msgsum;
}
if (setjmp(sjalarmbuf) != 0) {
if (def != -1) {
if (def)
else
}
goto done;
}
alarmcatch();
in_query_once = 1;
} else {
dumpabort();
/*NOTREACHED*/
}
for (;;) {
continue;
perror("poll(stdin)");
dumpabort();
/*NOTREACHED*/
}
continue; /* sanity check */
continue;
} else {
dumpabort();
/*NOTREACHED*/
}
}
timeout = 0;
back = 1;
lastmsgsum = 0;
goto done;
back = 0;
lastmsgsum = 0;
goto done;
} else {
in_query_once = 0;
alarmcatch();
in_query_once = 1;
}
}
done:
/*
* Turn off the alarm, and reset the signal to trap out..
*/
(void) alarm(0);
attnmessage = NULL;
if (tstart_writing)
(void) time(tstart_writing);
(void) timeclock(timeclockstate);
in_query_once = 0;
return (back);
}
/*
* Alert the console operator, and enable the alarm clock to
* sleep for time += 2 minutes in case nobody comes to satisfy dump
* If the alarm goes off while in the query_once for loop, we just
* longjmp back there and return the default answer.
*/
static void
#ifdef __STDC__
alarmcatch(void)
#else
#endif
{
if (in_query_once) {
}
if (timeout) {
msgtail("\n");
}
timeout += 120;
}
/*
* Here if an inquisitive operator interrupts the dump program
*/
/*ARGSUSED*/
void
int sig;
{
if (!saveattn) {
}
"Do you want to abort dump?: (\"yes\" or \"no\") "))) {
dumpabort();
/*NOTREACHED*/
}
if (saveattn) {
alarmcatch();
}
}
/*
* We use wall(1) to do the actual broadcasting, so
* that we don't have to worry about duplicated code
* only getting fixed in one place. This also saves
* us from having to worry about process groups,
* controlling terminals, and the like.
*/
void
char *message;
{
int saverr;
if (!notify)
return;
return;
}
case -1:
return;
case 0:
exit(1);
}
exit(1);
default:
break; /* parent */
}
return;
}
"\n\007\007\007Message from the dump program to all operators at \
%d:%02d ...\n\n%s"),
continue;
/*LINTED [empty loop body]*/
}
}
/*
* print out an estimate of the amount of time left to do the dump
*/
void
int force;
int blkswritten;
{
char *msgp;
return;
if (*tschedule == 0)
return;
}
}
#include <stdarg.h>
/* VARARGS1 */
void
{
#ifdef TDEBUG
#endif
/* don't need -1, vsnprintf does it right */
/* LINTED pointer arithmetic result fits in size_t */
}
/* VARARGS1 */
void
{
}
/*
* Tell the operator what has to be done;
* we don't actually do it
*/
void
int arg;
{
char *lastname;
char *date;
int i;
int dumpme = 0;
mnttabread(); /* /etc/fstab input */
inititimes(); /* /etc/dumpdates input */
/* Don't use msg(), this isn't a tell-the-world kind of thing */
if (arg == 'w')
else
"Last dump(s) done (Dump '>' file systems):\n"));
lastname = "??";
continue;
/* must be ctime(), per ufsdump(4) */
dumpme = 1;
}
/*
* Handle the w option: print out file systems
* which haven't been backed up within a day.
*/
}
if (arg == 'W') {
/*
* Handle the W option: print out ALL
* filesystems including recent dump dates and
* dump levels. Mark the backup-needing
* filesystems with a >.
*/
"%c %8s\t(%6s) Last dump: Level %c, Date %s\n"),
date);
}
dumpme = 0;
}
}
}
static int
#ifdef __STDC__
const void *v1;
const void *v2;
#else
void *v1;
void *v2;
#endif
{
int diff;
if (diff == 0) {
/*
* Time may eventually become unsigned, so can't
* rely on subtraction to give a useful result.
* Note that we are sorting dates into reverse
* order, so that we will report based on the
* most-recent record for a particular filesystem.
*/
diff = -1;
diff = 1;
}
return (diff);
}