BSD 4_3_Net_2 release
[unix-history] / usr / src / sbin / dump / dumpoptr.c
index e3be04c..b9a0739 100644 (file)
@@ -1,29 +1,63 @@
-/*
- * Copyright (c) 1980, 1988 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1980, 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dumpoptr.c 5.3 (Berkeley) 2/15/90";
-#endif not lint
-
+static char sccsid[] = "@(#)dumpoptr.c 5.8 (Berkeley) 3/7/91";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/wait.h>
+#include <ufs/dir.h>
+#include <signal.h>
+#include <time.h>
+#include <fstab.h>
+#include <grp.h>
+#include <varargs.h>
+#include <utmp.h>
+#include <tzfile.h>
+#include <errno.h>
+#include <stdio.h>
+#ifdef __STDC__
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#endif
 #include "dump.h"
 #include "dump.h"
-#include <sys/time.h>
 #include "pathnames.h"
 
 #include "pathnames.h"
 
-/*
- *     This is from /usr/include/grp.h
- *     That defined struct group, which conflicts
- *     with the struct group defined in param.h
- */
-struct Group { /* see getgrent(3) */
-       char    *gr_name;
-       char    *gr_passwd;
-       int     gr_gid;
-       char    **gr_mem;
-};
-struct Group *getgrnam();
+static void alarmcatch();
+static void sendmes();
+
 /*
  *     Query the operator; This previously-fascist piece of code
  *     no longer requires an exact response.
 /*
  *     Query the operator; This previously-fascist piece of code
  *     no longer requires an exact response.
@@ -37,39 +71,39 @@ struct      Group *getgrnam();
  */
 int    timeout;
 char   *attnmessage;           /* attention message */
  */
 int    timeout;
 char   *attnmessage;           /* attention message */
+
+int
 query(question)
        char    *question;
 {
        char    replybuffer[64];
 query(question)
        char    *question;
 {
        char    replybuffer[64];
-       int     back;
+       int     back, errcount;
        FILE    *mytty;
 
        FILE    *mytty;
 
-       if ( (mytty = fopen(_PATH_TTY, "r")) == NULL){
-               msg("fopen on %s fails\n", _PATH_TTY);
-               abort();
-       }
+       if ((mytty = fopen(_PATH_TTY, "r")) == NULL)
+               quit("fopen on %s fails: %s\n", _PATH_TTY, strerror(errno));
        attnmessage = question;
        timeout = 0;
        alarmcatch();
        attnmessage = question;
        timeout = 0;
        alarmcatch();
-       for(;;){
-               if ( fgets(replybuffer, 63, mytty) == NULL){
-                       if (ferror(mytty)){
-                               clearerr(mytty);
-                               continue;
-                       }
+       back = -1;
+       errcount = 0;
+       do {
+               if (fgets(replybuffer, 63, mytty) == NULL) {
+                       clearerr(mytty);
+                       if (++errcount > 30)    /* XXX  ugly */
+                               quit("excessive operator query failures\n");
                } else if (replybuffer[0] == 'y' || replybuffer[0] == 'Y') {
                } else if (replybuffer[0] == 'y' || replybuffer[0] == 'Y') {
-                               back = 1;
-                               goto done;
+                       back = 1;
                } else if (replybuffer[0] == 'n' || replybuffer[0] == 'N') {
                } else if (replybuffer[0] == 'n' || replybuffer[0] == 'N') {
-                               back = 0;
-                               goto done;
+                       back = 0;
                } else {
                } else {
-                       fprintf(stderr, "  DUMP: \"Yes\" or \"No\"?\n");
-                       fprintf(stderr,"  DUMP: %s: (\"yes\" or \"no\") ",
-                           question);
+                       (void) fprintf(stderr,
+                           "  DUMP: \"Yes\" or \"No\"?\n");
+                       (void) fprintf(stderr,
+                           "  DUMP: %s: (\"yes\" or \"no\") ", question);
                }
                }
-       }
-    done:
+       } while (back < 0);
+
        /*
         *      Turn off the alarm, and reset the signal to trap out..
         */
        /*
         *      Turn off the alarm, and reset the signal to trap out..
         */
@@ -86,11 +120,13 @@ char lastmsg[100];
  *     Alert the console operator, and enable the alarm clock to
  *     sleep for 2 minutes in case nobody comes to satisfy dump
  */
  *     Alert the console operator, and enable the alarm clock to
  *     sleep for 2 minutes in case nobody comes to satisfy dump
  */
+static void
 alarmcatch()
 {
        if (notify == 0) {
                if (timeout == 0)
 alarmcatch()
 {
        if (notify == 0) {
                if (timeout == 0)
-                       fprintf(stderr,"  DUMP: %s: (\"yes\" or \"no\") ",
+                       (void) fprintf(stderr,
+                           "  DUMP: %s: (\"yes\" or \"no\") ",
                            attnmessage);
                else
                        msgtail("\7\7");
                            attnmessage);
                else
                        msgtail("\7\7");
@@ -99,16 +135,18 @@ alarmcatch()
                        msgtail("\n");
                        broadcast("");          /* just print last msg */
                }
                        msgtail("\n");
                        broadcast("");          /* just print last msg */
                }
-               fprintf(stderr,"  DUMP: %s: (\"yes\" or \"no\") ",
+               (void) fprintf(stderr,"  DUMP: %s: (\"yes\" or \"no\") ",
                    attnmessage);
        }
        signal(SIGALRM, alarmcatch);
        alarm(120);
        timeout = 1;
 }
                    attnmessage);
        }
        signal(SIGALRM, alarmcatch);
        alarm(120);
        timeout = 1;
 }
+
 /*
  *     Here if an inquisitive operator interrupts the dump program
  */
 /*
  *     Here if an inquisitive operator interrupts the dump program
  */
+void
 interrupt()
 {
        msg("Interrupt received.\n");
 interrupt()
 {
        msg("Interrupt received.\n");
@@ -121,20 +159,20 @@ interrupt()
  *     operators to the status of dump.
  *     This works much like wall(1) does.
  */
  *     operators to the status of dump.
  *     This works much like wall(1) does.
  */
-struct Group *gp;
+struct group *gp;
 
 /*
  *     Get the names from the group entry "operator" to notify.
  */    
 
 /*
  *     Get the names from the group entry "operator" to notify.
  */    
+void
 set_operators()
 {
        if (!notify)            /*not going to notify*/
                return;
        gp = getgrnam(OPGRENT);
        endgrent();
 set_operators()
 {
        if (!notify)            /*not going to notify*/
                return;
        gp = getgrnam(OPGRENT);
        endgrent();
-       if (gp == (struct Group *)0){
-               msg("No group entry for %s.\n",
-                       OPGRENT);
+       if (gp == NULL) {
+               msg("No group entry for %s.\n", OPGRENT);
                notify = 0;
                return;
        }
                notify = 0;
                return;
        }
@@ -147,6 +185,7 @@ struct tm *localclock;
  *     We fork a child to do the actual broadcasting, so
  *     that the process control groups are not messed up
  */
  *     We fork a child to do the actual broadcasting, so
  *     that the process control groups are not messed up
  */
+void
 broadcast(message)
        char    *message;
 {
 broadcast(message)
        char    *message;
 {
@@ -157,6 +196,9 @@ broadcast(message)
        char    **np;
        int     pid, s;
 
        char    **np;
        int     pid, s;
 
+       if (!notify || gp == NULL)
+               return;
+
        switch (pid = fork()) {
        case -1:
                return;
        switch (pid = fork()) {
        case -1:
                return;
@@ -168,24 +210,22 @@ broadcast(message)
                return;
        }
 
                return;
        }
 
-       if (!notify || gp == 0)
-               exit(0);
        clock = time(0);
        localclock = localtime(&clock);
 
        clock = time(0);
        localclock = localtime(&clock);
 
-       if((f_utmp = fopen(_PATH_UTMP, "r")) == NULL) {
-               msg("Cannot open %s\n", _PATH_UTMP);
+       if ((f_utmp = fopen(_PATH_UTMP, "r")) == NULL) {
+               msg("Cannot open %s: %s\n", _PATH_UTMP, strerror(errno));
                return;
        }
 
        nusers = 0;
                return;
        }
 
        nusers = 0;
-       while (!feof(f_utmp)){
+       while (!feof(f_utmp)) {
                if (fread(&utmp, sizeof (struct utmp), 1, f_utmp) != 1)
                        break;
                if (utmp.ut_name[0] == 0)
                        continue;
                nusers++;
                if (fread(&utmp, sizeof (struct utmp), 1, f_utmp) != 1)
                        break;
                if (utmp.ut_name[0] == 0)
                        continue;
                nusers++;
-               for (np = gp->gr_mem; *np; np++){
+               for (np = gp->gr_mem; *np; np++) {
                        if (strncmp(*np, utmp.ut_name, sizeof(utmp.ut_name)) != 0)
                                continue;
                        /*
                        if (strncmp(*np, utmp.ut_name, sizeof(utmp.ut_name)) != 0)
                                continue;
                        /*
@@ -194,17 +234,17 @@ broadcast(message)
                        if (strncmp(utmp.ut_line, DIALUP, strlen(DIALUP)) == 0)
                                continue;
 #ifdef DEBUG
                        if (strncmp(utmp.ut_line, DIALUP, strlen(DIALUP)) == 0)
                                continue;
 #ifdef DEBUG
-                       msg("Message to %s at %s\n",
-                               utmp.ut_name, utmp.ut_line);
-#endif DEBUG
+                       msg("Message to %s at %s\n", *np, utmp.ut_line);
+#endif
                        sendmes(utmp.ut_line, message);
                }
        }
                        sendmes(utmp.ut_line, message);
                }
        }
-       fclose(f_utmp);
+       (void) fclose(f_utmp);
        Exit(0);        /* the wait in this same routine will catch this */
        /* NOTREACHED */
 }
 
        Exit(0);        /* the wait in this same routine will catch this */
        /* NOTREACHED */
 }
 
+static void
 sendmes(tty, message)
        char *tty, *message;
 {
 sendmes(tty, message)
        char *tty, *message;
 {
@@ -213,14 +253,16 @@ sendmes(tty, message)
        int lmsg = 1;
        FILE *f_tty;
 
        int lmsg = 1;
        FILE *f_tty;
 
-       strcpy(t, _PATH_DEV);
-       strcat(t, tty);
+       (void) strcpy(t, _PATH_DEV);
+       (void) strcat(t, tty);
 
 
-       if((f_tty = fopen(t, "w")) != NULL) {
+       if ((f_tty = fopen(t, "w")) != NULL) {
                setbuf(f_tty, buf);
                setbuf(f_tty, buf);
-               fprintf(f_tty, "\n\07\07\07Message from the dump program to all operators at %d:%02d ...\r\n\n  DUMP: NEEDS ATTENTION: "
-                      ,localclock->tm_hour
-                      ,localclock->tm_min);
+               (void) fprintf(f_tty,
+                   "\n\
+\7\7\7Message from the dump program to all operators at %d:%02d ...\r\n\n\
+DUMP: NEEDS ATTENTION: ",
+                   localclock->tm_hour, localclock->tm_min);
                for (cp = lastmsg; ; cp++) {
                        if (*cp == '\0') {
                                if (lmsg) {
                for (cp = lastmsg; ; cp++) {
                        if (*cp == '\0') {
                                if (lmsg) {
@@ -232,10 +274,10 @@ sendmes(tty, message)
                                        break;
                        }
                        if (*cp == '\n')
                                        break;
                        }
                        if (*cp == '\n')
-                               putc('\r', f_tty);
-                       putc(*cp, f_tty);
+                               (void) putc('\r', f_tty);
+                       (void) putc(*cp, f_tty);
                }
                }
-               fclose(f_tty);
+               (void) fclose(f_tty);
        }
 }
 
        }
 }
 
@@ -245,63 +287,112 @@ sendmes(tty, message)
 
 time_t tschedule = 0;
 
 
 time_t tschedule = 0;
 
+void
 timeest()
 {
        time_t  tnow, deltat;
 
        time (&tnow);
 timeest()
 {
        time_t  tnow, deltat;
 
        time (&tnow);
-       if (tnow >= tschedule){
+       if (tnow >= tschedule) {
                tschedule = tnow + 300;
                if (blockswritten < 500)
                        return; 
                deltat = tstart_writing - tnow +
                tschedule = tnow + 300;
                if (blockswritten < 500)
                        return; 
                deltat = tstart_writing - tnow +
-                       (((1.0*(tnow - tstart_writing))/blockswritten) * esize);
+                       (1.0 * (tnow - tstart_writing))
+                       / blockswritten * tapesize;
                msg("%3.2f%% done, finished in %d:%02d\n",
                msg("%3.2f%% done, finished in %d:%02d\n",
-                       (blockswritten*100.0)/esize,
-                       deltat/3600, (deltat%3600)/60);
+                       (blockswritten * 100.0) / tapesize,
+                       deltat / 3600, (deltat % 3600) / 60);
        }
 }
 
        }
 }
 
-int blocksontape()
+/*
+ *     tapesize: total number of blocks estimated over all reels
+ *     blockswritten:  blocks actually written, over all reels
+ *     etapes: estimated number of tapes to write
+ *
+ *     tsize:  blocks can write on this reel
+ *     asize:  blocks written on this reel
+ *     tapeno: number of tapes written so far
+ */
+int
+blocksontape()
 {
 {
-       /*
-        *      esize: total number of blocks estimated over all reels
-        *      blockswritten:  blocks actually written, over all reels
-        *      etapes: estimated number of tapes to write
-        *
-        *      tsize:  blocks can write on this reel
-        *      asize:  blocks written on this reel
-        *      tapeno: number of tapes written so far
-        */
        if (tapeno == etapes)
        if (tapeno == etapes)
-               return(esize - (etapes - 1)*tsize);
-       return(tsize);
+               return (tapesize - (etapes - 1) * tsize);
+       return (tsize);
 }
 
 }
 
-       /* VARARGS1 */
-       /* ARGSUSED */
-msg(fmt, a1, a2, a3, a4, a5)
-       char    *fmt;
-       int     a1, a2, a3, a4, a5;
+#ifdef lint
+
+/* VARARGS1 */
+void msg(fmt) char *fmt; { strcpy(lastmsg, fmt); }
+
+/* VARARGS1 */
+void msgtail(fmt) char *fmt; { fmt = fmt; }
+
+void quit(fmt) char *fmt; { msg(fmt); dumpabort(); }
+
+#else /* lint */
+
+void
+msg(va_alist)
+       va_dcl
 {
 {
-       fprintf(stderr,"  DUMP: ");
+       va_list ap;
+       char *fmt;
+
+       (void) fprintf(stderr,"  DUMP: ");
 #ifdef TDEBUG
 #ifdef TDEBUG
-       fprintf(stderr,"pid=%d ", getpid());
+       (void) fprintf(stderr, "pid=%d ", getpid());
 #endif
 #endif
-       fprintf(stderr, fmt, a1, a2, a3, a4, a5);
-       fflush(stdout);
-       fflush(stderr);
-       sprintf(lastmsg, fmt, a1, a2, a3, a4, a5);
+       va_start(ap);
+       fmt = va_arg(ap, char *);
+       (void) vfprintf(stderr, fmt, ap);
+       va_end(ap);
+       (void) fflush(stdout);
+       (void) fflush(stderr);
+       va_start(ap);
+       fmt = va_arg(ap, char *);
+       (void) vsprintf(lastmsg, fmt, ap);
+       va_end(ap);
+}
+
+void
+msgtail(va_alist)
+       va_dcl
+{
+       va_list ap;
+       char *fmt;
+
+       va_start(ap);
+       fmt = va_arg(ap, char *);
+       (void) vfprintf(stderr, fmt, ap);
+       va_end(ap);
 }
 
 }
 
-       /* VARARGS1 */
-       /* ARGSUSED */
-msgtail(fmt, a1, a2, a3, a4, a5)
-       char    *fmt;
-       int     a1, a2, a3, a4, a5;
+void
+quit(va_alist)
+       va_dcl
 {
 {
-       fprintf(stderr, fmt, a1, a2, a3, a4, a5);
+       va_list ap;
+       char *fmt;
+
+       (void) fprintf(stderr,"  DUMP: ");
+#ifdef TDEBUG
+       (void) fprintf(stderr, "pid=%d ", getpid());
+#endif
+       va_start(ap);
+       fmt = va_arg(ap, char *);
+       vfprintf(stderr, fmt, ap);
+       va_end(ap);
+       (void) fflush(stdout);
+       (void) fflush(stderr);
+       dumpabort();
 }
 }
+
+#endif /* lint */
+
 /*
  *     Tell the operator what has to be done;
  *     we don't actually do it
 /*
  *     Tell the operator what has to be done;
  *     we don't actually do it
@@ -312,19 +403,13 @@ allocfsent(fs)
        register struct fstab *fs;
 {
        register struct fstab *new;
        register struct fstab *fs;
 {
        register struct fstab *new;
-       register char *cp;
-       char *malloc();
 
        new = (struct fstab *)malloc(sizeof (*fs));
 
        new = (struct fstab *)malloc(sizeof (*fs));
-       cp = malloc(strlen(fs->fs_file) + 1);
-       strcpy(cp, fs->fs_file);
-       new->fs_file = cp;
-       cp = malloc(strlen(fs->fs_type) + 1);
-       strcpy(cp, fs->fs_type);
-       new->fs_type = cp;
-       cp = malloc(strlen(fs->fs_spec) + 1);
-       strcpy(cp, fs->fs_spec);
-       new->fs_spec = cp;
+       if (new == NULL ||
+           (new->fs_file = strdup(fs->fs_file)) == NULL ||
+           (new->fs_type = strdup(fs->fs_type)) == NULL ||
+           (new->fs_spec = strdup(fs->fs_spec)) == NULL)
+               quit("%s\n", strerror(errno));
        new->fs_passno = fs->fs_passno;
        new->fs_freq = fs->fs_freq;
        return (new);
        new->fs_passno = fs->fs_passno;
        new->fs_freq = fs->fs_freq;
        return (new);
@@ -335,15 +420,17 @@ struct    pfstab {
        struct  fstab *pf_fstab;
 };
 
        struct  fstab *pf_fstab;
 };
 
-static struct pfstab *table = NULL;
+static struct pfstab *table;
 
 
+void
 getfstab()
 {
        register struct fstab *fs;
        register struct pfstab *pf;
 
        if (setfsent() == 0) {
 getfstab()
 {
        register struct fstab *fs;
        register struct pfstab *pf;
 
        if (setfsent() == 0) {
-               msg("Can't open %s for dump table information.\n", _PATH_FSTAB);
+               msg("Can't open %s for dump table information: %s\n",
+                   _PATH_FSTAB, strerror(errno));
                return;
        }
        while (fs = getfsent()) {
                return;
        }
        while (fs = getfsent()) {
@@ -352,7 +439,8 @@ getfstab()
                    strcmp(fs->fs_type, FSTAB_RQ))
                        continue;
                fs = allocfsent(fs);
                    strcmp(fs->fs_type, FSTAB_RQ))
                        continue;
                fs = allocfsent(fs);
-               pf = (struct pfstab *)malloc(sizeof (*pf));
+               if ((pf = (struct pfstab *)malloc(sizeof (*pf))) == NULL)
+                       quit("%s\n", strerror(errno));
                pf->pf_fstab = fs;
                pf->pf_next = table;
                table = pf;
                pf->pf_fstab = fs;
                pf->pf_next = table;
                table = pf;
@@ -379,17 +467,13 @@ fstabsearch(key)
        register struct fstab *fs;
        char *rawname();
 
        register struct fstab *fs;
        char *rawname();
 
-       if (table == NULL)
-               return ((struct fstab *)0);
-       for (pf = table; pf; pf = pf->pf_next) {
+       for (pf = table; pf != NULL; pf = pf->pf_next) {
                fs = pf->pf_fstab;
                fs = pf->pf_fstab;
-               if (strcmp(fs->fs_file, key) == 0)
-                       return (fs);
-               if (strcmp(fs->fs_spec, key) == 0)
-                       return (fs);
-               if (strcmp(rawname(fs->fs_spec), key) == 0)
+               if (strcmp(fs->fs_file, key) == 0 ||
+                   strcmp(fs->fs_spec, key) == 0 ||
+                   strcmp(rawname(fs->fs_spec), key) == 0)
                        return (fs);
                        return (fs);
-               if (key[0] != '/'){
+               if (key[0] != '/') {
                        if (*fs->fs_spec == '/' &&
                            strcmp(fs->fs_spec + 1, key) == 0)
                                return (fs);
                        if (*fs->fs_spec == '/' &&
                            strcmp(fs->fs_spec + 1, key) == 0)
                                return (fs);
@@ -398,75 +482,76 @@ fstabsearch(key)
                                return (fs);
                }
        }
                                return (fs);
                }
        }
-       return (0);
+       return (NULL);
 }
 
 /*
  *     Tell the operator what to do
  */
 }
 
 /*
  *     Tell the operator what to do
  */
+void
 lastdump(arg)
 lastdump(arg)
-       char    arg;            /* w ==> just what to do; W ==> most recent dumps */
+       char    arg;    /* w ==> just what to do; W ==> most recent dumps */
 {
 {
-                       char    *lastname;
-                       char    *date;
-       register        int     i;
-                       time_t  tnow;
-       register        struct  fstab   *dt;
-                       int     dumpme;
-       register        struct  idates  *itwalk;
-
-       int     idatesort();
+       register int i;
+       register struct fstab *dt;
+       register struct dumpdates *dtwalk;
+       char *lastname, *date;
+       int dumpme, datesort();
+       time_t tnow;
 
        time(&tnow);
        getfstab();             /* /etc/fstab input */
 
        time(&tnow);
        getfstab();             /* /etc/fstab input */
-       inititimes();           /* /etc/dumpdates input */
-       qsort(idatev, nidates, sizeof(struct idates *), idatesort);
+       initdumptimes();        /* /etc/dumpdates input */
+       qsort(ddatev, nddates, sizeof(struct dumpdates *), datesort);
 
        if (arg == 'w')
 
        if (arg == 'w')
-               fprintf(stdout, "Dump these file systems:\n");
+               (void) printf("Dump these file systems:\n");
        else
        else
-               fprintf(stdout, "Last dump(s) done (Dump '>' file systems):\n");
+               (void) printf("Last dump(s) done (Dump '>' file systems):\n");
        lastname = "??";
        lastname = "??";
-       ITITERATE(i, itwalk){
-               if (strncmp(lastname, itwalk->id_name, sizeof(itwalk->id_name)) == 0)
+       ITITERATE(i, dtwalk) {
+               if (strncmp(lastname, dtwalk->dd_name,
+                   sizeof(dtwalk->dd_name)) == 0)
                        continue;
                        continue;
-               date = (char *)ctime(&itwalk->id_ddate);
-               date[16] = '\0';                /* blast away seconds and year */
-               lastname = itwalk->id_name;
-               dt = fstabsearch(itwalk->id_name);
-               dumpme = (  (dt != 0)
-                        && (dt->fs_freq != 0)
-                        && (itwalk->id_ddate < tnow - (dt->fs_freq*DAY)));
-               if ( (arg != 'w') || dumpme)
-                 fprintf(stdout,"%c %8s\t(%6s) Last dump: Level %c, Date %s\n",
-                       dumpme && (arg != 'w') ? '>' : ' ',
-                       itwalk->id_name,
-                       dt ? dt->fs_file : "",
-                       itwalk->id_incno,
-                       date
-                   );
+               date = (char *)ctime(&dtwalk->dd_ddate);
+               date[16] = '\0';        /* blast away seconds and year */
+               lastname = dtwalk->dd_name;
+               dt = fstabsearch(dtwalk->dd_name);
+               dumpme = (dt != NULL &&
+                   dt->fs_freq != 0 &&
+                   dtwalk->dd_ddate < tnow - (dt->fs_freq * SECSPERDAY));
+               if (arg != 'w' || dumpme)
+                       (void) printf(
+                           "%c %8s\t(%6s) Last dump: Level %c, Date %s\n",
+                           dumpme && (arg != 'w') ? '>' : ' ',
+                           dtwalk->dd_name,
+                           dt ? dt->fs_file : "",
+                           dtwalk->dd_level,
+                           date);
        }
 }
 
        }
 }
 
-int    idatesort(p1, p2)
-       struct  idates  **p1, **p2;
+int
+datesort(a1, a2)
+       void *a1, *a2;
 {
 {
-       int     diff;
+       struct dumpdates *d1 = *(struct dumpdates **)a1;
+       struct dumpdates *d2 = *(struct dumpdates **)a2;
+       int diff;
 
 
-       diff = strncmp((*p1)->id_name, (*p2)->id_name, sizeof((*p1)->id_name));
+       diff = strncmp(d1->dd_name, d2->dd_name, sizeof(d1->dd_name));
        if (diff == 0)
        if (diff == 0)
-               return ((*p2)->id_ddate - (*p1)->id_ddate);
-       else
-               return (diff);
+               return (d2->dd_ddate - d1->dd_ddate);
+       return (diff);
 }
 
 }
 
-int max(a,b)
+int max(a, b)
        int a, b;
 {
        int a, b;
 {
-       return(a>b?a:b);
+       return (a > b ? a : b);
 }
 }
-int min(a,b)
+int min(a, b)
        int a, b;
 {
        int a, b;
 {
-       return(a<b?a:b);
+       return (a < b ? a : b);
 }
 }