]> git.wh0rd.org - dump.git/blobdiff - dump/main.c
Let the user give the dumpdates path as an argument to dump (-D)
[dump.git] / dump / main.c
index d06c2fde3863fe2b1c98fe45a132835535a22e38..45e525bbd165632c3de8f9d34fcd363b0504df0c 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.74 2002/07/19 14:57:39 stelian Exp $";
+       "$Id: main.c,v 1.81 2003/01/21 10:42:27 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -49,13 +49,13 @@ static const char rcsid[] =
 #include <ctype.h>
 #include <compaterr.h>
 #include <fcntl.h>
-#include <fstab.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
+#include <mntent.h>
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -163,7 +163,7 @@ int notify = 0;     /* notify operator flag */
 int    blockswritten = 0;      /* number of blocks written on current tape */
 int    tapeno = 0;     /* current tape number */
 int    density = 0;    /* density in bytes/0.1" " <- this is for hilit19 */
-int    ntrec = NTREC;  /* # tape blocks in each tape record */
+int    ntrec = NTREC;  /* # blocks in each tape record */
 int    cartridge = 0;  /* Assume non-cartridge tape */
 #ifdef USE_QFA
 int    tapepos = 0;    /* assume no QFA tapeposition needed by user */
@@ -181,7 +181,7 @@ long        uncomprblks = 0;/* uncompressed blocks written */
 char   *__progname;
 #endif
 
-int    maxbsize = 64*1024;     /* XXX MAXBSIZE from sys/param.h */
+int    maxbsize = 1024*1024;     /* XXX MAXBSIZE from sys/param.h */
 static long numarg __P((const char *, long, long));
 static void obsolete __P((int *, char **[]));
 static void usage __P((void));
@@ -198,7 +198,7 @@ main(int argc, char *argv[])
        dump_ino_t ino;
        int dirty;
        struct dinode *dp;
-       struct  fstab *dt;
+       struct mntent *dt;
        char *map;
        int ch;
        int i, anydirskipped;
@@ -244,7 +244,7 @@ main(int argc, char *argv[])
 #endif /* USE_QFA */
 
        while ((ch = getopt(argc, argv,
-                           "0123456789A:aB:b:cd:e:E:f:F:h:I:"
+                           "0123456789A:aB:b:cd:D:e:E:f:F:h:I:"
 #ifdef HAVE_BZLIB
                            "j::"
 #endif
@@ -293,7 +293,7 @@ main(int argc, char *argv[])
 
                case 'b':               /* blocks per tape write */
                        ntrec = numarg("number of blocks per write",
-                           1L, 1000L);
+                           1L, 1048576L);
                        if (ntrec > maxbsize/1024) {
                                msg("Please choose a blocksize <= %dkB\n",
                                        maxbsize/1024);
@@ -313,6 +313,10 @@ main(int argc, char *argv[])
                        density = numarg("density", 10L, 327670L) / 10;
                        if (density >= 625 && !bflag)
                                ntrec = HIGHDENSITYTREC;
+                       break;
+
+               case 'D':               /* path of dumpdates file */
+                       dumpdates = optarg;
                        break;
                        
                                        /* 04-Feb-00 ILC */
@@ -355,7 +359,7 @@ main(int argc, char *argv[])
 
                case 'I':
                        breademax =
-                         numarg ("number of errors to ignore", 1L, 0L);
+                         numarg ("number of errors to ignore", 0L, 0L);
                        break;
 
 #ifdef KERBEROS
@@ -570,9 +574,9 @@ main(int argc, char *argv[])
                        msg("The ENTIRE dump is aborted.\n");
                        exit(X_STARTUP);
                }
-               disk = rawname(dt->fs_spec);
-               (void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
-               (void)strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
+               disk = rawname(dt->mnt_fsname);
+               (void)strncpy(spcl.c_dev, dt->mnt_fsname, NAMELEN);
+               (void)strncpy(spcl.c_filesys, dt->mnt_dir, NAMELEN);
        } else {
 #ifdef __linux__
 #ifdef HAVE_REALPATH
@@ -584,9 +588,9 @@ main(int argc, char *argv[])
                 * a filesystem specified in fstab. Search for it.
                 */
                if ((dt = fstabsearch(pathname)) != NULL) {
-                       disk = rawname(dt->fs_spec);
-                       (void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
-                       (void)strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
+                       disk = rawname(dt->mnt_fsname);
+                       (void)strncpy(spcl.c_dev, dt->mnt_fsname, NAMELEN);
+                       (void)strncpy(spcl.c_filesys, dt->mnt_dir, NAMELEN);
                } else {
                        /*
                         * The argument was not found in the fstab
@@ -595,11 +599,11 @@ main(int argc, char *argv[])
                        dt = fstabsearchdir(pathname, directory);
                        if (dt != NULL) {
                                char name[MAXPATHLEN];
-                               (void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
+                               (void)strncpy(spcl.c_dev, dt->mnt_fsname, NAMELEN);
                                (void)snprintf(name, sizeof(name), "%s (dir %s)",
-                                             dt->fs_file, directory);
+                                             dt->mnt_dir, directory);
                                (void)strncpy(spcl.c_filesys, name, NAMELEN);
-                               disk = rawname(dt->fs_spec);
+                               disk = rawname(dt->mnt_fsname);
                        } else {
                                (void)strncpy(spcl.c_dev, disk, NAMELEN);
                                (void)strncpy(spcl.c_filesys, "an unlisted file system",
@@ -750,6 +754,8 @@ main(int argc, char *argv[])
 
        if (!sizest) {
                msg("Label: %s\n", spcl.c_label);
+               
+               msg("Writing %d Kilobyte records\n", ntrec);
 
                if (compressed)
                        msg("Compressing output at compression level %d (%s)\n", 
@@ -798,14 +804,14 @@ main(int argc, char *argv[])
                /* check if file is a directory */
                if (!(statbuf.st_mode & S_IFDIR))
                        anydirskipped2 = maponefile(maxino, &tapesize, 
-                                                   p+strlen(dt->fs_file));
+                                                   p+strlen(dt->mnt_dir));
                else
                        /* read directory inodes.
                         * NOTE: nested directories are not recognized 
                         * so inodes may be umped twice!
                         */
                        anydirskipped2 = mapfilesfromdir(maxino, &tapesize, 
-                                                        p+strlen(dt->fs_file));
+                                                        p+strlen(dt->mnt_dir));
                if (!anydirskipped)
                        anydirskipped = anydirskipped2;
                argv++;
@@ -827,7 +833,7 @@ main(int argc, char *argv[])
 
        if (pipeout || unlimited) {
                tapesize += 1 + ntrec;  /* 1 map header + trailer blocks */
-               msg("estimated %ld tape blocks.\n", tapesize);
+               msg("estimated %ld blocks.\n", tapesize);
        } else {
                double fetapes;
 
@@ -867,7 +873,7 @@ main(int argc, char *argv[])
                tapesize += (etapes - 1) *
                        (howmany(mapsize * sizeof(char), TP_BSIZE) + 1);
                tapesize += etapes + ntrec;     /* headers + trailer blks */
-               msg("estimated %ld tape blocks on %3.2f tape(s).\n",
+               msg("estimated %ld blocks on %3.2f tape(s).\n",
                    tapesize, fetapes);
        }
 
@@ -976,10 +982,10 @@ main(int argc, char *argv[])
        tnow = trewind();
 
        if (pipeout || fifoout)
-               msg("%ld tape blocks (%.2fMB)\n", spcl.c_tapea,
+               msg("%ld blocks (%.2fMB)\n", spcl.c_tapea,
                        ((double)spcl.c_tapea * TP_BSIZE / 1048576));
        else
-               msg("%ld tape blocks (%.2fMB) on %d volume(s)\n",
+               msg("%ld blocks (%.2fMB) on %d volume(s)\n",
                    spcl.c_tapea, 
                    ((double)spcl.c_tapea * TP_BSIZE / 1048576),
                    spcl.c_volume);
@@ -1038,8 +1044,8 @@ usage(void)
 #endif
                "mMnqSuv"
                "] [-A file] [-B records] [-b blocksize]\n"
-               "\t%s [-d density] [-e inode#,inode#,...] [-E file] [-f file]\n"
-               "\t%s [-h level] [-I nr errors] "
+               "\t%s [-d density] [-D file] [-e inode#,inode#,...] [-E file]\n"
+               "\t%s [-f file] [-h level] [-I nr errors] "
 #ifdef HAVE_BZLIB
                "[-j zlevel] "
 #endif
@@ -1154,6 +1160,7 @@ obsolete(int *argcp, char **argvp[])
                case 'B':
                case 'b':
                case 'd':
+               case 'D':
                case 'e':
                case 'E':
                case 'f':
@@ -1227,10 +1234,10 @@ do_exclude_ino(dump_ino_t ino, const char *reason)
                        exit(X_STARTUP);
                }
                if (reason)
-                       msg("Added inode %u to exclude list (%s)\n", 
+                       msg("Excluding inode %u (%s) from dump\n", 
                            ino, reason);
                else
-                       msg("Added inode %u to exclude list\n", ino);
+                       msg("Excluding inode %u from dump\n", ino);
                iexclude_list[iexclude_num++] = ino;
        }
 }
@@ -1241,7 +1248,7 @@ do_exclude_ino_str(char * ino) {
        unsigned long inod;
 
        inod = strtoul(ino, &r, 10);
-       if (*r != '\0' || inod <= ROOTINO) {
+       if (( *r != '\0' && !isspace(*r) ) || inod <= ROOTINO) {
                msg("Invalid inode argument %s\n", ino);
                msg("The ENTIRE dump is aborted.\n");
                exit(X_STARTUP);