X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Fmain.c;h=722ca71e1764bb5fd381818210011d26155fa5ca;hp=8fcf468d7b0851259628e1bb2e8f81f53c776f37;hb=103245b6fea8e7d77722e85ccb404ac1d928987d;hpb=e084ba00f03da98a6d260b0b3856aee2dfbb4c58 diff --git a/dump/main.c b/dump/main.c index 8fcf468..722ca71 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.57 2001/08/16 09:37:59 stelian Exp $"; + "$Id: main.c,v 1.60 2001/09/06 09:00:32 stelian Exp $"; #endif /* not lint */ #include @@ -60,6 +60,7 @@ static const char rcsid[] = #include #include #ifdef __linux__ +#include #ifdef HAVE_EXT2FS_EXT2_FS_H #include #else @@ -102,6 +103,7 @@ char *tapeprefix; /* prefix of the tape file */ 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 uflag; /* update flag */ int Mflag; /* multi-volume flag */ int qflag; /* quit on errors flag */ @@ -178,6 +180,7 @@ static void obsolete __P((int *, char **[])); static void usage __P((void)); static void do_exclude_from_file __P((char *)); static void do_exclude_ino_str __P((char *)); +static void incompat_flags __P((int, char, char)); static dump_ino_t iexclude_list[IEXCLUDE_MAXNUM];/* the inode exclude list */ static int iexclude_num = 0; /* number of elements in the list */ @@ -191,7 +194,8 @@ main(int argc, char *argv[]) register struct fstab *dt; register char *map; register int ch; - int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1; + int i, anydirskipped; + int aflag = 0, bflag = 0, Tflag = 0, honorlevel = 1; dump_ino_t maxino; struct STAT statbuf; dev_t filedev = 0; @@ -232,7 +236,11 @@ main(int argc, char *argv[]) #endif /* USE_QFA */ while ((ch = getopt(argc, argv, - "0123456789aB:b:cd:e:E:f:F:h:L:" + "0123456789aB:b:cd:e:E:f:F:h:" +#ifdef HAVE_BZLIB + "j::" +#endif + "L:" #ifdef KERBEROS "k" #endif @@ -254,6 +262,7 @@ main(int argc, char *argv[]) case 'a': /* `auto-size', Write to EOM. */ unlimited = 1; + aflag = 1; break; case 'B': /* blocks per output file */ @@ -315,6 +324,15 @@ main(int argc, char *argv[]) honorlevel = numarg("honor level", 0L, 10L); break; +#ifdef HAVE_BZLIB + case 'j': + compressed = 2; + bzipflag = 1; + if (optarg) + compressed = numarg("compress level", 1L, 9L); + break; +#endif /* HAVE_BZLIB */ + #ifdef KERBEROS case 'k': dokerberos = 1; @@ -411,11 +429,12 @@ main(int argc, char *argv[]) exit(X_STARTUP); } argc--; - if (Tflag && uflag) { - msg("You cannot use the T and u flags together.\n"); - msg("The ENTIRE dump is aborted.\n"); - exit(X_STARTUP); - } + incompat_flags(Tflag && uflag, 'T', 'u'); + incompat_flags(aflag && blocksperfile, 'a', 'B'); + incompat_flags(aflag && cartridge, 'a', 'c'); + incompat_flags(aflag && density, 'a', 'd'); + incompat_flags(aflag && tsize, 'a', 's'); + if (strcmp(tapeprefix, "-") == 0) { pipeout++; tapeprefix = "standard output"; @@ -610,6 +629,14 @@ main(int argc, char *argv[]) } /* end of size estimate */ #ifdef __linux__ + if ((diskfd = OPEN(disk, O_RDONLY)) < 0) { + msg("Cannot open %s\n", disk); + msg("The ENTIRE dump is aborted.\n"); + exit(X_STARTUP); + } +#ifdef BLKFLSBUF + (void)ioctl(diskfd, BLKFLSBUF); +#endif retval = dump_fs_open(disk, &fs); if (retval) { com_err(disk, retval, "while opening filesystem"); @@ -624,11 +651,6 @@ main(int argc, char *argv[]) msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); } - if ((diskfd = OPEN(disk, O_RDONLY)) < 0) { - msg("Cannot open %s\n", disk); - msg("The ENTIRE dump is aborted.\n"); - exit(X_STARTUP); - } /* if no user label specified, use ext2 filesystem label if available */ if (spcl.c_label[0] == '\0') { const char *lbl; @@ -689,8 +711,8 @@ main(int argc, char *argv[]) msg("Label: %s\n", spcl.c_label); if (compressed) - msg("Compressing output at compression level %d\n", - compressed); + msg("Compressing output at compression level %d (%s)\n", + compressed, bzipflag ? "bzlib" : "zlib"); } #if defined(SIGINFO) @@ -957,10 +979,14 @@ usage(void) "MnqSu" "] [-B records] [-b blocksize] [-d density]\n" "\t%s [-e inode#,inode#,...] [-E file] [-f file] [-h level] " +#ifdef HAVE_BZLIB + "[-j zlevel] " +#endif + "\n\t%s " #ifdef USE_QFA "[-Q file] " #endif - "\n\t%s [-s feet] [-T date] " + "[-s feet] [-T date] " #ifdef HAVE_ZLIB "[-z zlevel] " #endif @@ -1184,3 +1210,12 @@ do_exclude_from_file(char *file) { } fclose(f); } + +static void incompat_flags(int cond, char flag1, char flag2) { + if (cond) { + msg("You cannot use the %c and %c flags together.\n", + flag1, flag2); + msg("The ENTIRE dump is aborted.\n"); + exit(X_STARTUP); + } +}