optr.c revision 50476
11558Srgrimes/*- 21558Srgrimes * Copyright (c) 1980, 1988, 1993 31558Srgrimes * The Regents of the University of California. All rights reserved. 41558Srgrimes * 51558Srgrimes * Redistribution and use in source and binary forms, with or without 61558Srgrimes * modification, are permitted provided that the following conditions 71558Srgrimes * are met: 81558Srgrimes * 1. Redistributions of source code must retain the above copyright 91558Srgrimes * notice, this list of conditions and the following disclaimer. 101558Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111558Srgrimes * notice, this list of conditions and the following disclaimer in the 121558Srgrimes * documentation and/or other materials provided with the distribution. 131558Srgrimes * 3. All advertising materials mentioning features or use of this software 141558Srgrimes * must display the following acknowledgement: 151558Srgrimes * This product includes software developed by the University of 161558Srgrimes * California, Berkeley and its contributors. 171558Srgrimes * 4. Neither the name of the University nor the names of its contributors 181558Srgrimes * may be used to endorse or promote products derived from this software 191558Srgrimes * without specific prior written permission. 201558Srgrimes * 211558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221558Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241558Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251558Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261558Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271558Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281558Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291558Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301558Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311558Srgrimes * SUCH DAMAGE. 321558Srgrimes */ 331558Srgrimes 341558Srgrimes#ifndef lint 3536997Scharnier#if 0 361558Srgrimesstatic char sccsid[] = "@(#)optr.c 8.2 (Berkeley) 1/6/94"; 3736997Scharnier#endif 3836997Scharnierstatic const char rcsid[] = 3950476Speter "$FreeBSD: head/sbin/dump/optr.c 50476 1999-08-28 00:22:10Z peter $"; 401558Srgrimes#endif /* not lint */ 411558Srgrimes 421558Srgrimes#include <sys/param.h> 431558Srgrimes#include <sys/wait.h> 441558Srgrimes#include <sys/time.h> 451558Srgrimes 461558Srgrimes#include <errno.h> 471558Srgrimes#include <fstab.h> 481558Srgrimes#include <grp.h> 491558Srgrimes#include <stdio.h> 501558Srgrimes#include <stdlib.h> 511558Srgrimes#include <string.h> 521558Srgrimes#include <stdarg.h> 531558Srgrimes#include <unistd.h> 541558Srgrimes#include <utmp.h> 551558Srgrimes 561558Srgrimes#include "dump.h" 571558Srgrimes#include "pathnames.h" 581558Srgrimes 591558Srgrimesvoid alarmcatch __P((/* int, int */)); 601558Srgrimesint datesort __P((const void *, const void *)); 611558Srgrimesstatic void sendmes __P((char *, char *)); 621558Srgrimes 631558Srgrimes/* 641558Srgrimes * Query the operator; This previously-fascist piece of code 651558Srgrimes * no longer requires an exact response. 661558Srgrimes * It is intended to protect dump aborting by inquisitive 671558Srgrimes * people banging on the console terminal to see what is 681558Srgrimes * happening which might cause dump to croak, destroying 691558Srgrimes * a large number of hours of work. 701558Srgrimes * 711558Srgrimes * Every 2 minutes we reprint the message, alerting others 721558Srgrimes * that dump needs attention. 731558Srgrimes */ 741558Srgrimesstatic int timeout; 751558Srgrimesstatic char *attnmessage; /* attention message */ 761558Srgrimes 771558Srgrimesint 781558Srgrimesquery(question) 791558Srgrimes char *question; 801558Srgrimes{ 811558Srgrimes char replybuffer[64]; 821558Srgrimes int back, errcount; 831558Srgrimes FILE *mytty; 841558Srgrimes 851558Srgrimes if ((mytty = fopen(_PATH_TTY, "r")) == NULL) 861558Srgrimes quit("fopen on %s fails: %s\n", _PATH_TTY, strerror(errno)); 871558Srgrimes attnmessage = question; 881558Srgrimes timeout = 0; 891558Srgrimes alarmcatch(); 901558Srgrimes back = -1; 911558Srgrimes errcount = 0; 921558Srgrimes do { 931558Srgrimes if (fgets(replybuffer, 63, mytty) == NULL) { 941558Srgrimes clearerr(mytty); 951558Srgrimes if (++errcount > 30) /* XXX ugly */ 961558Srgrimes quit("excessive operator query failures\n"); 971558Srgrimes } else if (replybuffer[0] == 'y' || replybuffer[0] == 'Y') { 981558Srgrimes back = 1; 991558Srgrimes } else if (replybuffer[0] == 'n' || replybuffer[0] == 'N') { 1001558Srgrimes back = 0; 1011558Srgrimes } else { 1021558Srgrimes (void) fprintf(stderr, 1031558Srgrimes " DUMP: \"Yes\" or \"No\"?\n"); 1041558Srgrimes (void) fprintf(stderr, 1051558Srgrimes " DUMP: %s: (\"yes\" or \"no\") ", question); 1061558Srgrimes } 1071558Srgrimes } while (back < 0); 1081558Srgrimes 1091558Srgrimes /* 1101558Srgrimes * Turn off the alarm, and reset the signal to trap out.. 1111558Srgrimes */ 1121558Srgrimes (void) alarm(0); 1131558Srgrimes if (signal(SIGALRM, sig) == SIG_IGN) 1141558Srgrimes signal(SIGALRM, SIG_IGN); 1151558Srgrimes (void) fclose(mytty); 1161558Srgrimes return(back); 1171558Srgrimes} 1181558Srgrimes 1191558Srgrimeschar lastmsg[100]; 1201558Srgrimes 1211558Srgrimes/* 1221558Srgrimes * Alert the console operator, and enable the alarm clock to 1231558Srgrimes * sleep for 2 minutes in case nobody comes to satisfy dump 1241558Srgrimes */ 1251558Srgrimesvoid 1261558Srgrimesalarmcatch() 1271558Srgrimes{ 1281558Srgrimes if (notify == 0) { 1291558Srgrimes if (timeout == 0) 1301558Srgrimes (void) fprintf(stderr, 1311558Srgrimes " DUMP: %s: (\"yes\" or \"no\") ", 1321558Srgrimes attnmessage); 1331558Srgrimes else 1341558Srgrimes msgtail("\7\7"); 1351558Srgrimes } else { 1361558Srgrimes if (timeout) { 1371558Srgrimes msgtail("\n"); 1381558Srgrimes broadcast(""); /* just print last msg */ 1391558Srgrimes } 1401558Srgrimes (void) fprintf(stderr," DUMP: %s: (\"yes\" or \"no\") ", 1411558Srgrimes attnmessage); 1421558Srgrimes } 1431558Srgrimes signal(SIGALRM, alarmcatch); 1441558Srgrimes (void) alarm(120); 1451558Srgrimes timeout = 1; 1461558Srgrimes} 1471558Srgrimes 1481558Srgrimes/* 1491558Srgrimes * Here if an inquisitive operator interrupts the dump program 1501558Srgrimes */ 1511558Srgrimesvoid 1521558Srgrimesinterrupt(signo) 1531558Srgrimes int signo; 1541558Srgrimes{ 1551558Srgrimes msg("Interrupt received.\n"); 1561558Srgrimes if (query("Do you want to abort dump?")) 1571558Srgrimes dumpabort(0); 1581558Srgrimes} 1591558Srgrimes 1601558Srgrimes/* 1611558Srgrimes * The following variables and routines manage alerting 1621558Srgrimes * operators to the status of dump. 1631558Srgrimes * This works much like wall(1) does. 1641558Srgrimes */ 1651558Srgrimesstruct group *gp; 1661558Srgrimes 1671558Srgrimes/* 1681558Srgrimes * Get the names from the group entry "operator" to notify. 1698871Srgrimes */ 1701558Srgrimesvoid 1711558Srgrimesset_operators() 1721558Srgrimes{ 1731558Srgrimes if (!notify) /*not going to notify*/ 1741558Srgrimes return; 1751558Srgrimes gp = getgrnam(OPGRENT); 1761558Srgrimes (void) endgrent(); 1771558Srgrimes if (gp == NULL) { 1781558Srgrimes msg("No group entry for %s.\n", OPGRENT); 1791558Srgrimes notify = 0; 1801558Srgrimes return; 1811558Srgrimes } 1821558Srgrimes} 1831558Srgrimes 1841558Srgrimesstruct tm *localclock; 1851558Srgrimes 1861558Srgrimes/* 1871558Srgrimes * We fork a child to do the actual broadcasting, so 1881558Srgrimes * that the process control groups are not messed up 1891558Srgrimes */ 1901558Srgrimesvoid 1911558Srgrimesbroadcast(message) 1921558Srgrimes char *message; 1931558Srgrimes{ 1941558Srgrimes time_t clock; 1951558Srgrimes FILE *f_utmp; 1961558Srgrimes struct utmp utmp; 1971558Srgrimes char **np; 1981558Srgrimes int pid, s; 1991558Srgrimes 2001558Srgrimes if (!notify || gp == NULL) 2011558Srgrimes return; 2021558Srgrimes 2031558Srgrimes switch (pid = fork()) { 2041558Srgrimes case -1: 2051558Srgrimes return; 2061558Srgrimes case 0: 2071558Srgrimes break; 2081558Srgrimes default: 2091558Srgrimes while (wait(&s) != pid) 2101558Srgrimes continue; 2111558Srgrimes return; 2121558Srgrimes } 2131558Srgrimes 2141558Srgrimes clock = time((time_t *)0); 2151558Srgrimes localclock = localtime(&clock); 2161558Srgrimes 2171558Srgrimes if ((f_utmp = fopen(_PATH_UTMP, "r")) == NULL) { 2181558Srgrimes msg("Cannot open %s: %s\n", _PATH_UTMP, strerror(errno)); 2191558Srgrimes return; 2201558Srgrimes } 2211558Srgrimes 2221558Srgrimes while (!feof(f_utmp)) { 2231558Srgrimes if (fread((char *) &utmp, sizeof (struct utmp), 1, f_utmp) != 1) 2241558Srgrimes break; 2251558Srgrimes if (utmp.ut_name[0] == 0) 2261558Srgrimes continue; 2271558Srgrimes for (np = gp->gr_mem; *np; np++) { 2281558Srgrimes if (strncmp(*np, utmp.ut_name, sizeof(utmp.ut_name)) != 0) 2291558Srgrimes continue; 2301558Srgrimes /* 2311558Srgrimes * Do not send messages to operators on dialups 2321558Srgrimes */ 2331558Srgrimes if (strncmp(utmp.ut_line, DIALUP, strlen(DIALUP)) == 0) 2341558Srgrimes continue; 2351558Srgrimes#ifdef DEBUG 2361558Srgrimes msg("Message to %s at %s\n", *np, utmp.ut_line); 2371558Srgrimes#endif 2381558Srgrimes sendmes(utmp.ut_line, message); 2391558Srgrimes } 2401558Srgrimes } 2411558Srgrimes (void) fclose(f_utmp); 2421558Srgrimes Exit(0); /* the wait in this same routine will catch this */ 2431558Srgrimes /* NOTREACHED */ 2441558Srgrimes} 2451558Srgrimes 2461558Srgrimesstatic void 2471558Srgrimessendmes(tty, message) 2481558Srgrimes char *tty, *message; 2491558Srgrimes{ 25021409Simp char t[MAXPATHLEN], buf[BUFSIZ]; 2511558Srgrimes register char *cp; 2521558Srgrimes int lmsg = 1; 2531558Srgrimes FILE *f_tty; 2541558Srgrimes 2551558Srgrimes (void) strcpy(t, _PATH_DEV); 25621409Simp (void) strncat(t, tty, sizeof t - strlen(_PATH_DEV) - 1); 2571558Srgrimes 2581558Srgrimes if ((f_tty = fopen(t, "w")) != NULL) { 2591558Srgrimes setbuf(f_tty, buf); 2601558Srgrimes (void) fprintf(f_tty, 2611558Srgrimes "\n\ 2621558Srgrimes\7\7\7Message from the dump program to all operators at %d:%02d ...\r\n\n\ 2631558SrgrimesDUMP: NEEDS ATTENTION: ", 2641558Srgrimes localclock->tm_hour, localclock->tm_min); 2651558Srgrimes for (cp = lastmsg; ; cp++) { 2661558Srgrimes if (*cp == '\0') { 2671558Srgrimes if (lmsg) { 2681558Srgrimes cp = message; 2691558Srgrimes if (*cp == '\0') 2701558Srgrimes break; 2711558Srgrimes lmsg = 0; 2721558Srgrimes } else 2731558Srgrimes break; 2741558Srgrimes } 2751558Srgrimes if (*cp == '\n') 2761558Srgrimes (void) putc('\r', f_tty); 2771558Srgrimes (void) putc(*cp, f_tty); 2781558Srgrimes } 2791558Srgrimes (void) fclose(f_tty); 2801558Srgrimes } 2811558Srgrimes} 2821558Srgrimes 2831558Srgrimes/* 2841558Srgrimes * print out an estimate of the amount of time left to do the dump 2851558Srgrimes */ 2861558Srgrimes 2871558Srgrimestime_t tschedule = 0; 2881558Srgrimes 2891558Srgrimesvoid 2901558Srgrimestimeest() 2911558Srgrimes{ 2921558Srgrimes time_t tnow, deltat; 2931558Srgrimes 2941558Srgrimes (void) time((time_t *) &tnow); 2951558Srgrimes if (tnow >= tschedule) { 2961558Srgrimes tschedule = tnow + 300; 2971558Srgrimes if (blockswritten < 500) 2988871Srgrimes return; 2991558Srgrimes deltat = tstart_writing - tnow + 3001558Srgrimes (1.0 * (tnow - tstart_writing)) 3011558Srgrimes / blockswritten * tapesize; 3021558Srgrimes msg("%3.2f%% done, finished in %d:%02d\n", 3031558Srgrimes (blockswritten * 100.0) / tapesize, 3041558Srgrimes deltat / 3600, (deltat % 3600) / 60); 3051558Srgrimes } 3061558Srgrimes} 3071558Srgrimes 3081558Srgrimesvoid 3091558Srgrimes#if __STDC__ 3101558Srgrimesmsg(const char *fmt, ...) 3111558Srgrimes#else 3121558Srgrimesmsg(fmt, va_alist) 3131558Srgrimes char *fmt; 3141558Srgrimes va_dcl 3151558Srgrimes#endif 3161558Srgrimes{ 3171558Srgrimes va_list ap; 3181558Srgrimes 3191558Srgrimes (void) fprintf(stderr," DUMP: "); 3201558Srgrimes#ifdef TDEBUG 3211558Srgrimes (void) fprintf(stderr, "pid=%d ", getpid()); 3221558Srgrimes#endif 3231558Srgrimes#if __STDC__ 3241558Srgrimes va_start(ap, fmt); 3251558Srgrimes#else 3261558Srgrimes va_start(ap); 3271558Srgrimes#endif 3281558Srgrimes (void) vfprintf(stderr, fmt, ap); 3291558Srgrimes (void) fflush(stdout); 3301558Srgrimes (void) fflush(stderr); 3311558Srgrimes (void) vsprintf(lastmsg, fmt, ap); 3321558Srgrimes va_end(ap); 3331558Srgrimes} 3341558Srgrimes 3351558Srgrimesvoid 3361558Srgrimes#if __STDC__ 3371558Srgrimesmsgtail(const char *fmt, ...) 3381558Srgrimes#else 3391558Srgrimesmsgtail(fmt, va_alist) 3401558Srgrimes char *fmt; 3411558Srgrimes va_dcl 3421558Srgrimes#endif 3431558Srgrimes{ 3441558Srgrimes va_list ap; 3451558Srgrimes#if __STDC__ 3461558Srgrimes va_start(ap, fmt); 3471558Srgrimes#else 3481558Srgrimes va_start(ap); 3491558Srgrimes#endif 3501558Srgrimes (void) vfprintf(stderr, fmt, ap); 3511558Srgrimes va_end(ap); 3521558Srgrimes} 3531558Srgrimes 3541558Srgrimesvoid 3551558Srgrimes#if __STDC__ 3561558Srgrimesquit(const char *fmt, ...) 3571558Srgrimes#else 3581558Srgrimesquit(fmt, va_alist) 3591558Srgrimes char *fmt; 3601558Srgrimes va_dcl 3611558Srgrimes#endif 3621558Srgrimes{ 3631558Srgrimes va_list ap; 3641558Srgrimes 3651558Srgrimes (void) fprintf(stderr," DUMP: "); 3661558Srgrimes#ifdef TDEBUG 3671558Srgrimes (void) fprintf(stderr, "pid=%d ", getpid()); 3681558Srgrimes#endif 3691558Srgrimes#if __STDC__ 3701558Srgrimes va_start(ap, fmt); 3711558Srgrimes#else 3721558Srgrimes va_start(ap); 3731558Srgrimes#endif 3741558Srgrimes (void) vfprintf(stderr, fmt, ap); 3751558Srgrimes va_end(ap); 3761558Srgrimes (void) fflush(stdout); 3771558Srgrimes (void) fflush(stderr); 3781558Srgrimes dumpabort(0); 3791558Srgrimes} 3801558Srgrimes 3811558Srgrimes/* 3821558Srgrimes * Tell the operator what has to be done; 3831558Srgrimes * we don't actually do it 3841558Srgrimes */ 3851558Srgrimes 3861558Srgrimesstruct fstab * 3871558Srgrimesallocfsent(fs) 3881558Srgrimes register struct fstab *fs; 3891558Srgrimes{ 3901558Srgrimes register struct fstab *new; 3911558Srgrimes 3921558Srgrimes new = (struct fstab *)malloc(sizeof (*fs)); 3931558Srgrimes if (new == NULL || 3941558Srgrimes (new->fs_file = strdup(fs->fs_file)) == NULL || 3951558Srgrimes (new->fs_type = strdup(fs->fs_type)) == NULL || 3961558Srgrimes (new->fs_spec = strdup(fs->fs_spec)) == NULL) 3971558Srgrimes quit("%s\n", strerror(errno)); 3981558Srgrimes new->fs_passno = fs->fs_passno; 3991558Srgrimes new->fs_freq = fs->fs_freq; 4001558Srgrimes return (new); 4011558Srgrimes} 4021558Srgrimes 4031558Srgrimesstruct pfstab { 4041558Srgrimes struct pfstab *pf_next; 4051558Srgrimes struct fstab *pf_fstab; 4061558Srgrimes}; 4071558Srgrimes 4081558Srgrimesstatic struct pfstab *table; 4091558Srgrimes 4101558Srgrimesvoid 4111558Srgrimesgetfstab() 4121558Srgrimes{ 4131558Srgrimes register struct fstab *fs; 4141558Srgrimes register struct pfstab *pf; 4151558Srgrimes 4161558Srgrimes if (setfsent() == 0) { 4171558Srgrimes msg("Can't open %s for dump table information: %s\n", 4181558Srgrimes _PATH_FSTAB, strerror(errno)); 4191558Srgrimes return; 4201558Srgrimes } 4211558Srgrimes while ((fs = getfsent()) != NULL) { 4221558Srgrimes if (strcmp(fs->fs_type, FSTAB_RW) && 4231558Srgrimes strcmp(fs->fs_type, FSTAB_RO) && 4241558Srgrimes strcmp(fs->fs_type, FSTAB_RQ)) 4251558Srgrimes continue; 4261558Srgrimes fs = allocfsent(fs); 4271558Srgrimes if ((pf = (struct pfstab *)malloc(sizeof (*pf))) == NULL) 4281558Srgrimes quit("%s\n", strerror(errno)); 4291558Srgrimes pf->pf_fstab = fs; 4301558Srgrimes pf->pf_next = table; 4311558Srgrimes table = pf; 4321558Srgrimes } 4331558Srgrimes (void) endfsent(); 4341558Srgrimes} 4351558Srgrimes 4361558Srgrimes/* 4371558Srgrimes * Search in the fstab for a file name. 4381558Srgrimes * This file name can be either the special or the path file name. 4391558Srgrimes * 4401558Srgrimes * The entries in the fstab are the BLOCK special names, not the 4411558Srgrimes * character special names. 4421558Srgrimes * The caller of fstabsearch assures that the character device 4431558Srgrimes * is dumped (that is much faster) 4441558Srgrimes * 4451558Srgrimes * The file name can omit the leading '/'. 4461558Srgrimes */ 4471558Srgrimesstruct fstab * 4481558Srgrimesfstabsearch(key) 4491558Srgrimes char *key; 4501558Srgrimes{ 4511558Srgrimes register struct pfstab *pf; 4521558Srgrimes register struct fstab *fs; 4531558Srgrimes char *rn; 4541558Srgrimes 4551558Srgrimes for (pf = table; pf != NULL; pf = pf->pf_next) { 4561558Srgrimes fs = pf->pf_fstab; 4571558Srgrimes if (strcmp(fs->fs_file, key) == 0 || 4581558Srgrimes strcmp(fs->fs_spec, key) == 0) 4591558Srgrimes return (fs); 4601558Srgrimes rn = rawname(fs->fs_spec); 4611558Srgrimes if (rn != NULL && strcmp(rn, key) == 0) 4621558Srgrimes return (fs); 4631558Srgrimes if (key[0] != '/') { 4641558Srgrimes if (*fs->fs_spec == '/' && 4651558Srgrimes strcmp(fs->fs_spec + 1, key) == 0) 4661558Srgrimes return (fs); 4671558Srgrimes if (*fs->fs_file == '/' && 4681558Srgrimes strcmp(fs->fs_file + 1, key) == 0) 4691558Srgrimes return (fs); 4701558Srgrimes } 4711558Srgrimes } 4721558Srgrimes return (NULL); 4731558Srgrimes} 4741558Srgrimes 4751558Srgrimes/* 4761558Srgrimes * Tell the operator what to do 4771558Srgrimes */ 4781558Srgrimesvoid 4791558Srgrimeslastdump(arg) 4801558Srgrimes char arg; /* w ==> just what to do; W ==> most recent dumps */ 4811558Srgrimes{ 4821558Srgrimes register int i; 4831558Srgrimes register struct fstab *dt; 4841558Srgrimes register struct dumpdates *dtwalk; 4851558Srgrimes char *lastname, *date; 4861558Srgrimes int dumpme; 48748447Sjkh time_t tnow; 48848447Sjkh struct tm *tlast; 4891558Srgrimes 4901558Srgrimes (void) time(&tnow); 4911558Srgrimes getfstab(); /* /etc/fstab input */ 4921558Srgrimes initdumptimes(); /* /etc/dumpdates input */ 4931558Srgrimes qsort((char *) ddatev, nddates, sizeof(struct dumpdates *), datesort); 4941558Srgrimes 4951558Srgrimes if (arg == 'w') 4961558Srgrimes (void) printf("Dump these file systems:\n"); 4971558Srgrimes else 4981558Srgrimes (void) printf("Last dump(s) done (Dump '>' file systems):\n"); 4991558Srgrimes lastname = "??"; 5001558Srgrimes ITITERATE(i, dtwalk) { 5011558Srgrimes if (strncmp(lastname, dtwalk->dd_name, 5021558Srgrimes sizeof(dtwalk->dd_name)) == 0) 5031558Srgrimes continue; 50448447Sjkh date = (char *)ctime(&dtwalk->dd_ddate); 5051558Srgrimes date[16] = '\0'; /* blast away seconds and year */ 5061558Srgrimes lastname = dtwalk->dd_name; 5071558Srgrimes dt = fstabsearch(dtwalk->dd_name); 50848447Sjkh dumpme = (dt != NULL && dt->fs_freq != 0); 50948447Sjkh if (dumpme) { 51048447Sjkh tlast = localtime(&dtwalk->dd_ddate); 51148447Sjkh dumpme = tnow > (dtwalk->dd_ddate - (tlast->tm_hour * 3600) 51248447Sjkh - (tlast->tm_min * 60) - tlast->tm_sec 51348447Sjkh + (dt->fs_freq * 86400)); 51448447Sjkh }; 5151558Srgrimes if (arg != 'w' || dumpme) 5161558Srgrimes (void) printf( 5171558Srgrimes "%c %8s\t(%6s) Last dump: Level %c, Date %s\n", 5181558Srgrimes dumpme && (arg != 'w') ? '>' : ' ', 5191558Srgrimes dtwalk->dd_name, 5201558Srgrimes dt ? dt->fs_file : "", 5211558Srgrimes dtwalk->dd_level, 5221558Srgrimes date); 5231558Srgrimes } 5241558Srgrimes} 5251558Srgrimes 5261558Srgrimesint 5271558Srgrimesdatesort(a1, a2) 5281558Srgrimes const void *a1, *a2; 5291558Srgrimes{ 5301558Srgrimes struct dumpdates *d1 = *(struct dumpdates **)a1; 5311558Srgrimes struct dumpdates *d2 = *(struct dumpdates **)a2; 5321558Srgrimes int diff; 5331558Srgrimes 5341558Srgrimes diff = strncmp(d1->dd_name, d2->dd_name, sizeof(d1->dd_name)); 5351558Srgrimes if (diff == 0) 5361558Srgrimes return (d2->dd_ddate - d1->dd_ddate); 5371558Srgrimes return (diff); 5381558Srgrimes} 539