# 2.11BSD#431 - /usr/src/old/dump/dumpmain.c

##### Functions

    deraw             X
    main              X
    rawname           X
    sigAbort          X
    sigalrm           X
    sigbus            X
    sigfpe            X
    sighup            X
    sigsegv           X
    sigterm           X
    sigtrap           X

##### Variables

    blockswritten     X
    density           X
    notify            X
    tapeno            X

       1: static  char *sccsid = "@(#)dumpmain.c	1.2 (Berkeley) 10/16/80";
       2: #include "dump.h"
       3:
       4: int notify = 0; /* notify operator flag */
       5: long    blockswritten = 0L; /* number of blocks written on current tape */
       6: int tapeno = 0; /* current tape number */
       7: int density = 160;  /* density in 0.1" units */
       8:
       9: main(argc, argv)
      10:     int argc;
      11:     char    *argv[];
      12: {
      13:     char        *arg;
      14:     register    i;
      15:     float       fetapes;
      16:     register    struct  fstab   *dt;
      17:
      18:     time(&(spcl.c_date));
      19:
      20:     tsize = 2300L*12L*10L;
      21:     tape = TAPE;
      22:     disk = DISK;
      23:     increm = NINCREM;
      24:
      25:     incno = '9';
      26:     uflag = 0;
      27:     arg = "u";
      28:     if(argc > 1) {
      29:         argv++;
      30:         argc--;
      31:         arg = *argv;
      32:         if (*arg == '-')
      33:             arg++;
      34:     }
      35:     while(*arg)
      36:     switch (*arg++) {
      37:     case 'w':
      38:         lastdump('w');      /* tell us only what has to be done */
      39:         exit(0);
      40:         break;
      41:     case 'W':           /* what to do */
      42:         lastdump('W');      /* tell us the current state of what has been done */
      43:         exit(0);        /* do nothing else */
      44:         break;
      45:
      46:     case 'J':           /* update old to new */
      47:         o_nconvert();
      48:         exit(0);        /* do nothing else */
      49:         break;
      50:
      51:     case 'f':           /* output file */
      52:         if(argc > 1) {
      53:             argv++;
      54:             argc--;
      55:             tape = *argv;
      56:         }
      57:         break;
      58:
      59:     case 'd':           /* density, in bits per inch */
      60:         if (argc > 1) {
      61:             argv++;
      62:             argc--;
      63:             density = atoi(*argv) / 10;
      64:         }
      65:         break;
      66:
      67:     case 's':           /* tape size, feet */
      68:         if(argc > 1) {
      69:             argv++;
      70:             argc--;
      71:             tsize = atol(*argv);
      72:             tsize *= 12L*10L;
      73:         }
      74:         break;
      75:
      76:     case '0':           /* dump level */
      77:     case '1':
      78:     case '2':
      79:     case '3':
      80:     case '4':
      81:     case '5':
      82:     case '6':
      83:     case '7':
      84:     case '8':
      85:     case '9':
      86:         incno = arg[-1];
      87:         break;
      88:
      89:     case 'u':           /* update /etc/dumpdates */
      90:         uflag++;
      91:         break;
      92:
      93:     case 'n':           /* notify operators */
      94:         notify++;
      95:         break;
      96:
      97:     default:
      98:         printf("bad key '%c%'\n", arg[-1]);
      99:         Exit(X_ABORT);
     100:     }
     101:     if(argc > 1) {
     102:         argv++;
     103:         argc--;
     104:         disk = *argv;
     105:     }
     106:
     107:     if (signal(SIGHUP, sighup) == SIG_IGN)
     108:         signal(SIGHUP, SIG_IGN);
     109:     if (signal(SIGTRAP, sigtrap) == SIG_IGN)
     110:         signal(SIGTRAP, SIG_IGN);
     111:     if (signal(SIGFPE, sigfpe) == SIG_IGN)
     112:         signal(SIGFPE, SIG_IGN);
     113:     if (signal(SIGBUS, sigbus) == SIG_IGN)
     114:         signal(SIGBUS, SIG_IGN);
     115:     if (signal(SIGSEGV, sigsegv) == SIG_IGN)
     116:         signal(SIGSEGV, SIG_IGN);
     117:     if (signal(SIGTERM, sigterm) == SIG_IGN)
     118:         signal(SIGTERM, SIG_IGN);
     119:
     120:
     121:     if (signal(SIGINT, interrupt) == SIG_IGN)
     122:         signal(SIGINT, SIG_IGN);
     123:
     124:     set_operators();    /* /etc/group snarfed */
     125:     /*
     126: 	 *	disk can be either the character or block special file name,
     127: 	 *	or the full file system path name.
     128: 	 */
     129:     if (dt = getfsfile(disk))
     130:         disk = rawname(dt->fs_spec);
     131:     else
     132:         if (dt = getfsspec(disk))
     133:             disk = rawname(disk);
     134:         else
     135:             dt = getfsspec(deraw(disk));
     136:
     137:     getitime();     /* /etc/dumpdates snarfed */
     138:
     139:     msg("Date of this level %c dump: %s\n", incno, prdate(spcl.c_date));
     140:     msg("Date of last level %c dump: %s\n", incno, prdate(spcl.c_ddate));
     141:     msg("Dumping %s ", disk);
     142:     if (dt != 0)
     143:         msgtail("(%s) ", dt->fs_file);
     144:     msgtail("to %s\n", tape);
     145:
     146:     fi = open(disk, 0);
     147:     if (fi < 0) {
     148:         msg("Cannot open %s\n", disk);
     149:         Exit(X_ABORT);
     150:     }
     151:     CLR(clrmap);
     152:     CLR(dirmap);
     153:     CLR(nodmap);
     154:     esize = 0;
     155:
     156:     msg("mapping (Pass I) [regular files]\n");
     157:     pass(mark, (short *)NULL);      /* mark updates esize */
     158:
     159:     do {
     160:         msg("mapping (Pass II) [directories]\n");
     161:         nadded = 0;
     162:         pass(add, dirmap);
     163:     } while(nadded);
     164:
     165:     bmapest(clrmap);
     166:     bmapest(nodmap);
     167:
     168:     fetapes =
     169:         (    esize      /* blocks */
     170:             *DEV_BSIZE  /* bytes / block */
     171:             *(1.0/density)  /* 0.1" / byte */
     172:           +
     173:              esize      /* blocks */
     174:             *(1.0/NTREC)    /* IRG's / block */
     175:             *7      /* 0.1" / IRG */
     176:         ) * (1.0 / tsize )  /* tape / 0.1" */
     177:     ;
     178:     etapes = fetapes;       /* truncating assignment */
     179:     etapes++;
     180:     /*
     181: 	 *	esize is typically about 5% too low; we frob it here
     182: 	 */
     183:     esize += ((5*esize)/100);
     184:     msg("estimated %ld tape blocks on %3.2f tape(s).\n", esize, fetapes);
     185:
     186:     otape();            /* bitmap is the first to tape write */
     187:     time(&(tstart_writing));
     188:     bitmap(clrmap, TS_CLRI);
     189:
     190:     msg("dumping (Pass III) [directories]\n");
     191:     pass(dump, dirmap);
     192:
     193:     msg("dumping (Pass IV) [regular files]\n");
     194:     pass(dump, nodmap);
     195:
     196:     spcl.c_type = TS_END;
     197:     for(i=0; i<NTREC; i++)
     198:         spclrec();
     199:     msg("DUMP: %ld tape blocks on %d tape(s)\n",spcl.c_tapea,spcl.c_volume);
     200:     msg("DUMP IS DONE\n");
     201:
     202:     putitime();
     203:     close(to);
     204:     rewind();
     205:     broadcast("DUMP IS DONE!\7\7\n");
     206:     Exit(X_FINOK);
     207: }
     208:
     209: int sighup(){   msg("SIGHUP()  try rewriting\n"); sigAbort();}
     210: int sigtrap(){  msg("SIGTRAP()  try rewriting\n"); sigAbort();}
     211: int sigfpe(){   msg("SIGFPE()  try rewriting\n"); sigAbort();}
     212: int sigbus(){   msg("SIGBUS()  try rewriting\n"); sigAbort();}
     213: int sigsegv(){  msg("SIGSEGV()  ABORTING!\n"); abort();}
     214: int sigalrm(){  msg("SIGALRM()  try rewriting\n"); sigAbort();}
     215: int sigterm(){  msg("SIGTERM()  try rewriting\n"); sigAbort();}
     216:
     217: sigAbort()
     218: {
     219:     msg("Rewriting attempted as response to unknown signal.\n");
     220:     fflush(stderr);
     221:     fflush(stdout);
     222:     close_rewind();
     223:     exit(X_REWRITE);
     224: }
     225:
     226: char *rawname(cp)
     227:     char *cp;
     228: {
     229:     static char rawbuf[MAXPATHLEN];
     230:     char *dp = rindex(cp, '/');
     231:
     232:     if (dp == 0)
     233:         return ((char *) 0);
     234:     *dp = '\0';
     235:     strcpy(rawbuf, cp);
     236:     *dp++ = '/';
     237:     strcat(rawbuf, "/r");
     238:     strcat(rawbuf, dp);
     239:     return (rawbuf);
     240: }
     241:
     242: char *deraw(cp)
     243:     char *cp;
     244: {
     245:     static char rawbuf[MAXPATHLEN];
     246:     register char *dp;
     247:     register char *tp;
     248:
     249:     strcpy(rawbuf, cp);
     250:
     251:     dp = rindex(rawbuf, '/');
     252:     if (dp++ == 0)
     253:         return((char *) 0);
     254:
     255:     tp = dp++;
     256:     while (*tp++ = *dp++);
     257:     return(rawbuf);
     258: }

#### Defined functions

deraw defined in line 242; used 2 times

- in line 135
- in /usr/src/old/dump/dumpoptr.c line 303

main defined in line 9; never used
rawname defined in line 226; used 3 times

- in line 130-133(2)
- in /usr/src/old/dump/dump.h line 77

sigAbort defined in line 217; used 6 times

- in line 209-215(6)

sigalrm defined in line 214; used 1 times

- in /usr/src/old/dump/dump.h line 131

sigbus defined in line 212; used 2 times

- in line 113
- in /usr/src/old/dump/dump.h line 128

sigfpe defined in line 211; used 2 times

- in line 111
- in /usr/src/old/dump/dump.h line 126

sighup defined in line 209; used 2 times

- in line 107
- in /usr/src/old/dump/dump.h line 122

sigsegv defined in line 213; used 2 times

- in line 115
- in /usr/src/old/dump/dump.h line 129

sigterm defined in line 215; used 2 times

- in line 117
- in /usr/src/old/dump/dump.h line 132

sigtrap defined in line 210; used 2 times

- in line 109
- in /usr/src/old/dump/dump.h line 125

#### Defined variables

blockswritten defined in line 5; never used
density defined in line 7; used 2 times

- in line 63, 171

notify defined in line 4; used 1 times

- in line 94

sccsid defined in line 1; never used
tapeno defined in line 6; never used

Last modified: 1988-12-25 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1725 |