date and time created 89/04/02 12:30:51 by bostic
[unix-history] / usr / src / sbin / dump / main.c
index 2ff72c3..541d302 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.6 (Berkeley) %G%";
 #endif not lint
 
 #include "dump.h"
 #endif not lint
 
 #include "dump.h"
@@ -16,6 +16,7 @@ int   tapeno = 0;     /* current tape number */
 int    density = 0;    /* density in bytes/0.1" */
 int    ntrec = NTREC;  /* # tape blocks in each tape record */
 int    cartridge = 0;  /* Assume non-cartridge tape */
 int    density = 0;    /* density in bytes/0.1" */
 int    ntrec = NTREC;  /* # tape blocks in each tape record */
 int    cartridge = 0;  /* Assume non-cartridge tape */
+long   dev_bsize = 1;  /* recalculated below */
 #ifdef RDUMP
 char   *host;
 #endif
 #ifdef RDUMP
 char   *host;
 #endif
@@ -156,13 +157,14 @@ main(argc, argv)
          host = tape;
          tape = index(host, ':');
          if (tape == 0) {
          host = tape;
          tape = index(host, ':');
          if (tape == 0) {
-               msg("need keyletter ``f'' and device ``host:tape''");
+               msg("need keyletter ``f'' and device ``host:tape''\n");
                exit(1);
          }
          *tape++ = 0;
          if (rmthost(host) == 0)
                exit(X_ABORT);
        }
                exit(1);
          }
          *tape++ = 0;
          if (rmthost(host) == 0)
                exit(X_ABORT);
        }
+       setuid(getuid());       /* rmthost() is the only reason to be setuid */
 #endif
        if (signal(SIGHUP, sighup) == SIG_IGN)
                signal(SIGHUP, SIG_IGN);
 #endif
        if (signal(SIGHUP, sighup) == SIG_IGN)
                signal(SIGHUP, SIG_IGN);
@@ -190,8 +192,18 @@ main(argc, argv)
         *      the file system name with or without the leading '/'.
         */
        dt = fstabsearch(disk);
         *      the file system name with or without the leading '/'.
         */
        dt = fstabsearch(disk);
-       if (dt != 0)
+       if (dt != 0) {
                disk = rawname(dt->fs_spec);
                disk = rawname(dt->fs_spec);
+               strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
+               strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
+       } else {
+               strncpy(spcl.c_dev, disk, NAMELEN);
+               strncpy(spcl.c_filesys, "an unlisted file system", NAMELEN);
+       }
+       strcpy(spcl.c_label, "none");
+       gethostname(spcl.c_host, NAMELEN);
+       spcl.c_level = incno - '0';
+       spcl.c_type = TS_TAPE;
        getitime();             /* /etc/dumpdates snarfed */
 
        msg("Date of this level %c dump: %s\n", incno, prdate(spcl.c_date));
        getitime();             /* /etc/dumpdates snarfed */
 
        msg("Date of this level %c dump: %s\n", incno, prdate(spcl.c_date));
@@ -214,11 +226,12 @@ main(argc, argv)
        esize = 0;
        sblock = (struct fs *)buf;
        sync();
        esize = 0;
        sblock = (struct fs *)buf;
        sync();
-       bread(SBLOCK, sblock, SBSIZE);
+       bread(SBOFF, sblock, SBSIZE);
        if (sblock->fs_magic != FS_MAGIC) {
                msg("bad sblock magic number\n");
                dumpabort();
        }
        if (sblock->fs_magic != FS_MAGIC) {
                msg("bad sblock magic number\n");
                dumpabort();
        }
+       dev_bsize = sblock->fs_fsize / fsbtodb(sblock, 1);
        msiz = roundup(howmany(sblock->fs_ipg * sblock->fs_ncg, NBBY),
                TP_BSIZE);
        clrmap = (char *)calloc(msiz, sizeof(char));
        msiz = roundup(howmany(sblock->fs_ipg * sblock->fs_ncg, NBBY),
                TP_BSIZE);
        clrmap = (char *)calloc(msiz, sizeof(char));