X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Fmain.c;h=c7affa8413cd586fa54d2c46ac3289e963404a65;hp=64246743b14f73e8559f1ed2d75f93fdeb371a54;hb=e1abc9ce25132eef1239047a071c2c1d4822dd9f;hpb=1a886de8480fc5d0b842613f2cf375415d94bbb7 diff --git a/dump/main.c b/dump/main.c index 6424674..c7affa8 100644 --- a/dump/main.c +++ b/dump/main.c @@ -18,11 +18,7 @@ * 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 + * 3. 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. * @@ -41,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.78 2002/12/12 11:49:35 stelian Exp $"; + "$Id: main.c,v 1.84 2003/03/30 15:40:36 stelian Exp $"; #endif /* not lint */ #include @@ -106,7 +102,8 @@ char *dumpdates; /* name of the file containing dump date information*/ char lastlevel; /* dump level of previous dump */ char level; /* dump level of this dump */ int bzipflag; /* compression is done using bzlib */ -int Afile = 0; /* archive file descriptor */ +int Afile = -1; /* archive file descriptor */ +int AfileActive = 1;/* Afile flag */ int uflag; /* update flag */ int mflag; /* dump metadata only if possible */ int Mflag; /* multi-volume flag */ @@ -163,7 +160,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 */ @@ -244,7 +241,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 @@ -270,14 +267,6 @@ main(int argc, char *argv[]) case 'A': /* archive file */ Apath = optarg; - if ((Afile = open(Apath, O_RDWR|O_CREAT|O_TRUNC, - S_IRUSR | S_IWUSR)) < 0) { - msg("Cannot open %s for writing: %s\n", - optarg, strerror(errno)); - msg("The ENTIRE dump is aborted.\n"); - exit(X_STARTUP); - } - memset(volinfo, 0, TP_NINOS * sizeof(dump_ino_t)); break; case 'a': /* `auto-size', Write to EOM. */ @@ -313,6 +302,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 +348,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 @@ -511,6 +504,14 @@ main(int argc, char *argv[]) #endif } (void)setuid(getuid()); /* rmthost() is the only reason to be setuid */ + if (Apath && (Afile = open(Apath, O_WRONLY|O_CREAT|O_TRUNC, + S_IRUSR | S_IWUSR | S_IRGRP | + S_IWGRP | S_IROTH | S_IWOTH)) < 0) { + msg("Cannot open %s for writing: %s\n", + optarg, strerror(errno)); + msg("The ENTIRE dump is aborted.\n"); + exit(X_STARTUP); + } if (signal(SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, sig); @@ -750,6 +751,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", @@ -766,7 +769,7 @@ main(int argc, char *argv[]) if (directory[0] == 0) anydirskipped = mapfiles(maxino, &tapesize); else { - if (STAT(pathname, &statbuf) == -1) { + if (LSTAT(pathname, &statbuf) == -1) { msg("File cannot be accessed (%s).\n", pathname); msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); @@ -783,7 +786,7 @@ main(int argc, char *argv[]) int anydirskipped2; char *p = *argv; /* check if file is available */ - if (STAT(p, &statbuf) == -1) { + if (LSTAT(p, &statbuf) == -1) { msg("File cannot be accessed (%s).\n", p); msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); @@ -827,7 +830,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,14 +870,17 @@ 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); } #ifdef USE_QFA if (tapepos) { msg("writing QFA positions to %s\n", gTapeposfile); - if ((gTapeposfd = open(gTapeposfile, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR)) < 0) + if ((gTapeposfd = open(gTapeposfile, + O_WRONLY|O_CREAT|O_TRUNC, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP + | S_IROTH | S_IWOTH)) < 0) quit("can't open tapeposfile\n"); /* print QFA-file header */ snprintf(gTps, sizeof(gTps), "%s\n%s\n%ld\n\n", QFA_MAGIC, QFA_VERSION, (unsigned long)spcl.c_date); @@ -959,7 +965,7 @@ main(int argc, char *argv[]) tend_writing = time(NULL); spcl.c_type = TS_END; - if (Afile) { + if (Afile >= 0) { volinfo[1] = ROOTINO; memcpy(spcl.c_inos, volinfo, TP_NINOS * sizeof(dump_ino_t)); spcl.c_flags |= DR_INODEINFO; @@ -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); @@ -1005,7 +1011,7 @@ main(int argc, char *argv[]) spcl.c_tapea, tapekb, rate); } - if (Afile) + if (Afile >= 0) msg("Archiving dump to %s\n", Apath); broadcast("DUMP IS DONE!\7\7\n"); @@ -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':