]> git.wh0rd.org - dump.git/commitdiff
Made dump -w|-W report all recognized filesystems...
authorStelian Pop <stelian@popies.net>
Fri, 10 Nov 2000 11:48:31 +0000 (11:48 +0000)
committerStelian Pop <stelian@popies.net>
Fri, 10 Nov 2000 11:48:31 +0000 (11:48 +0000)
CHANGES
dump/dump.8.in
dump/dump.h
dump/itime.c
dump/optr.c

diff --git a/CHANGES b/CHANGES
index 49a14da3aecab78c9254eb936ceac0048015c133..8e4d9fbfd570a90476b76f3ab4128da5fd79ae62 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.86 2000/11/10 09:35:07 stelian Exp $
+$Id: CHANGES,v 1.87 2000/11/10 11:48:31 stelian Exp $
 
 Changes between versions 0.4b19 and 0.4b20 (released ???????????????)
 =====================================================================
@@ -41,6 +41,11 @@ Changes between versions 0.4b19 and 0.4b20 (released ???????????????)
        of fstab file from the system headers. Thanks to
        Andreas Dilger <adilger@turbolinux.com> for the patch.
 
+9.     Made dump -w|-W report all recognized filesystems 
+       present in either /etc/fstab or /etc/dumpdates, and present
+       the list in the same order as in fstab file. Thanks
+       to Andreas Dilger <adilger@turbolinux.com> for the patch.
+
 Changes between versions 0.4b18 and 0.4b19 (released August 20, 2000)
 =====================================================================
 
index 54f8251c028df83231f439a29a100db00e1051f8..f81cffb908d85f55a108b8ec6524e50c6dafa537 100644 (file)
@@ -30,7 +30,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    $Id: dump.8.in,v 1.16 2000/08/19 23:48:10 stelian Exp $
+.\"    $Id: dump.8.in,v 1.17 2000/11/10 11:48:31 stelian Exp $
 .\"
 .Dd __DATE__
 .Dt DUMP 8
@@ -300,10 +300,12 @@ The
 .Fl W
 option causes
 .Nm
-to print out, for each file system in
+to print out, for all file systems in
 .Pa __DUMPDATES__ ,
+and regognized file systems in
+.Pa /etc/fstab .
 the most recent dump date and level,
-and highlights those file systems that should be dumped.
+and highlights those that should be dumped.
 If the
 .Fl W
 option is set, all other options are ignored, and
@@ -312,7 +314,9 @@ exits immediately.
 .It Fl w
 Is like
 .Fl W ,
-but prints only those filesystems which need to be dumped.
+but prints only recognized filesystems in
+.Pa /etc/fstab
+which need to be dumped.
 .El
 .Pp
 .Nm Dump
@@ -460,17 +464,6 @@ Each reel requires a new process, so parent processes for
 reels already written just hang around until the entire tape
 is written.
 .Pp
-.Nm Dump
-with the
-.Fl W
-or
-.Fl w
-option does not report filesystems that have never been recorded
-in
-.Pa __DUMPDATES__ ,
-even if listed in
-.Pa /etc/fstab .
-.Pp
 It would be nice if
 .Nm
 knew about the dump sequence,
index 3eea35a7b276796aee999bebd22972e7da81d656..80d4971d5d2dc5d36735e4955fba2782907b5ee8 100644 (file)
@@ -4,7 +4,7 @@
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
  *     Stelian Pop <pop@cybercable.fr>, 1999-2000
  *
- *     $Id: dump.h,v 1.13 2000/03/02 11:34:51 stelian Exp $
+ *     $Id: dump.h,v 1.14 2000/11/10 11:48:31 stelian Exp $
  */
 
 /*-
@@ -194,6 +194,7 @@ struct      fstab *fstabsearchdir __P((const char *key, char *dir));        /* search fs_fil
  */
 struct dumpdates {
        char    dd_name[MAXPATHLEN+3];
+       struct fstab *dd_fstab;
        char    dd_level;
        time_t  dd_ddate;
 };
index 64d7644c6f8123f4e6ec31e1fb17602b030b015c..f847a6a95fff06dcfc64ef62c9d05b9b761a495c 100644 (file)
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: itime.c,v 1.10 2000/03/01 10:16:05 stelian Exp $";
+       "$Id: itime.c,v 1.11 2000/11/10 11:48:31 stelian Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -78,10 +78,10 @@ static const char rcsid[] =
 
 #include "dump.h"
 
-struct dumpdates **ddatev = 0;
-int    nddates = 0;
-int    ddates_in = 0;
-struct dumptime *dthead = 0;
+struct dumpdates **ddatev;
+int    nddates;
+int    ddates_in;
+struct dumptime *dthead;
 
 static void dumprecout __P((FILE *, struct dumpdates *));
 static int getrecord __P((FILE *, struct dumpdates *));
@@ -317,5 +317,7 @@ makedumpdate(struct dumpdates *ddp, char *tbuf)
        ddp->dd_ddate = unctime(tbuf);
        if (ddp->dd_ddate < 0)
                return(-1);
+       /* fstab entry */
+       ddp->dd_fstab = fstabsearch(ddp->dd_name);
        return(0);
 }
index 410253762486f27aecdf72920fe6663dd115fd8d..ced42623819533dab97f7eab32f99c3bfd02b914 100644 (file)
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: optr.c,v 1.11 2000/08/19 23:15:38 stelian Exp $";
+       "$Id: optr.c,v 1.12 2000/11/10 11:48:31 stelian Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -67,11 +67,15 @@ static const char rcsid[] =
 
 #include "dump.h"
 #include "pathnames.h"
+#include "bylabel.h"
 
 static void alarmcatch __P((int));
 int    datesort __P((const void *, const void *));
 static void sendmes __P((const char *, const char *));
 
+/* List of filesystem types that we can dump (same ext2 on-disk format) */
+static char *fstypes[] = { "ext2", "ext3", "InterMezzo", NULL };
+
 /*
  *     Query the operator; This previously-fascist piece of code
  *     no longer requires an exact response.
@@ -435,6 +439,7 @@ allocfsent(struct fstab *fs)
                fs->fs_file[strlen(fs->fs_file) - 1] = '\0';
        if ((new->fs_file = strdup(fs->fs_file)) == NULL ||
            (new->fs_type = strdup(fs->fs_type)) == NULL ||
+           (new->fs_vfstype = strdup(fs->fs_vfstype)) == NULL ||
            (new->fs_spec = strdup(fs->fs_spec)) == NULL)
                quit("%s\n", strerror(errno));
        new->fs_passno = fs->fs_passno;
@@ -444,6 +449,7 @@ allocfsent(struct fstab *fs)
 
 struct pfstab {
        struct  pfstab *pf_next;
+       struct  dumpdates *pf_dd;
        struct  fstab *pf_fstab;
 };
 
@@ -452,8 +458,9 @@ static      struct pfstab *table;
 void
 getfstab(void)
 {
-       register struct fstab *fs;
-       register struct pfstab *pf;
+       struct fstab *fs;
+       struct pfstab *pf;
+       struct pfstab *pfold = NULL;
 
        if (setfsent() == 0) {
                msg("Can't open %s for dump table information: %s\n",
@@ -466,11 +473,19 @@ getfstab(void)
                    strcmp(fs->fs_type, FSTAB_RQ))
                        continue;
                fs = allocfsent(fs);
+               fs->fs_passno = 0;
                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_next = NULL;
+
+               /* keep table in /etc/fstab order for use with -w and -W */
+               if (pfold) {
+                       pfold->pf_next = pf;
+                       pfold = pf;
+               } else
+                       pfold = table = pf;
+
        }
        (void) endfsent();
 }
@@ -550,49 +565,120 @@ fstabsearchdir(const char *key, char *directory)
 }
 #endif
 
+static void
+print_wmsg(char arg, int dumpme, const char *dev, int level,
+          const char *mtpt, time_t ddate)
+{
+       char *date;
+       
+       if (ddate)
+               date = (char *)ctime(&ddate);
+       //date[16] = '\0';      /* blast away seconds and year */
+
+       if (!dumpme && arg == 'w')
+               return;
+
+       (void) printf("%c %8s\t(%6s) Last dump: ",
+                     dumpme && (arg != 'w') ? '>' : ' ',
+                     dev,
+                     mtpt ? mtpt : "");
+
+       if (ddate)
+               printf(" Level %c, Date %s\n",
+                     level, date);
+       else
+               printf(" never\n");
+}
+
 /*
  *     Tell the operator what to do
  */
 void
 lastdump(char arg) /* w ==> just what to do; W ==> most recent dumps */
 {
-       register int i;
-       register struct fstab *dt;
-       register struct dumpdates *dtwalk=NULL;
-       char *lastname, *date;
-       int dumpme;
+       struct pfstab *pf;
        time_t tnow;
 
        (void) time(&tnow);
        getfstab();             /* /etc/fstab input */
        initdumptimes(0);       /* dumpdates input */
+       if (ddatev == NULL && table == NULL) {
+               (void) printf("No %s or %s file found\n",
+                             _PATH_FSTAB, _PATH_DUMPDATES);
+               return;
+       }
+
+       if (arg == 'w')
+               (void) printf("Dump these file systems:\n");
+       else
+               (void) printf("Last dump(s) done (Dump '>' file systems):\n");
+
        if (ddatev != NULL) {
+               struct dumpdates *dtwalk = NULL;
+               int i;
+               char *lastname;
+
                qsort((char *) ddatev, nddates, sizeof(struct dumpdates *), datesort);
 
-               if (arg == 'w')
-                       (void) printf("Dump these file systems:\n");
-               else
-                       (void) printf("Last dump(s) done (Dump '>' file systems):\n");
+               lastname = "??";
+               ITITERATE(i, dtwalk) {
+                       struct fstab *dt;
+                       if (strncmp(lastname, dtwalk->dd_name,
+                               sizeof(dtwalk->dd_name)) == 0)
+                               continue;
+                       lastname = dtwalk->dd_name;
+                       if ((dt = dtwalk->dd_fstab) != NULL &&
+                           dt->fs_freq != 0) {
+                               /* Overload fs_freq as dump level and
+                                * fs_passno as date, because we can't
+                                * change struct fstab format.
+                                * A negative fs_freq means this
+                                * filesystem needs to be dumped.
+                                */
+                               dt->fs_passno = dtwalk->dd_ddate;
+                               if (dtwalk->dd_ddate <
+                                   tnow - (dt->fs_freq * 86400))
+                                       dt->fs_freq = -dtwalk->dd_level;
+                               else
+                                       dt->fs_freq = dtwalk->dd_level;
+
+                       }
+               }
+       }
+
+       /* print in /etc/fstab order only those filesystem types we can dump */
+       for (pf = table; pf != NULL; pf = pf->pf_next) {
+               struct fstab *dt = pf->pf_fstab;
+               char **type;
+
+               for (type = fstypes; *type != NULL; type++) {
+                       if (strncmp(dt->fs_vfstype, *type,
+                                   sizeof(dt->fs_vfstype)) == 0) {
+                               const char *disk = get_device_name(dt->fs_spec);
+                               print_wmsg(arg, dt->fs_freq < 0 || !dt->fs_passno,
+                                          disk ? disk : dt->fs_spec,
+                                          dt->fs_freq < 0 ? -dt->fs_freq : dt->fs_freq, 
+                                          dt->fs_file,
+                                          dt->fs_passno);
+                       }
+               }
+       }
+
+       /* print in /etc/dumpdates order if not in /etc/fstab */
+       if (ddatev != NULL) {
+               struct dumpdates *dtwalk = NULL;
+               char *lastname;
+               int i;
+
                lastname = "??";
                ITITERATE(i, dtwalk) {
                        if (strncmp(lastname, dtwalk->dd_name,
-                               sizeof(dtwalk->dd_name)) == 0)
+                               sizeof(dtwalk->dd_name)) == 0 ||
+                           dtwalk->dd_fstab != NULL)
                                continue;
-                       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 * 86400));
-                       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);
+                       print_wmsg(arg, 0, dtwalk->dd_name,
+                                  dtwalk->dd_level, NULL, dtwalk->dd_ddate);
                }
        }
 }