]> git.wh0rd.org - dump.git/commitdiff
Refuse incompatible options in dump (-a and -B).
authorStelian Pop <stelian@popies.net>
Thu, 16 Aug 2001 13:12:30 +0000 (13:12 +0000)
committerStelian Pop <stelian@popies.net>
Thu, 16 Aug 2001 13:12:30 +0000 (13:12 +0000)
CHANGES
dump/main.c

diff --git a/CHANGES b/CHANGES
index 204f3ebedf1b363db91003c4e0f546ba9c3369af..ffbb11d4d51df3739fd424c2f9397ccdb1afe0bb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.132 2001/08/16 09:37:57 stelian Exp $
+$Id: CHANGES,v 1.133 2001/08/16 13:12:30 stelian Exp $
 
 Changes between versions 0.4b23 and 0.4b24 (released ?????????????)
 ===================================================================
 
 Changes between versions 0.4b23 and 0.4b24 (released ?????????????)
 ===================================================================
@@ -17,6 +17,9 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????)
        whenever it needs operator attention. It should be
        easier to use dump in scripts with this option.
 
        whenever it needs operator attention. It should be
        easier to use dump in scripts with this option.
 
+5.     Detect the use of incompatible options to dump and
+       refuse them (like -a and -B options together).
+
 Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001)
 ===================================================================
 
 Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001)
 ===================================================================
 
index 8fcf468d7b0851259628e1bb2e8f81f53c776f37..8f33f95e23847b16977f6776af732f82bb3711a7 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #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.58 2001/08/16 13:12:30 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -178,6 +178,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 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 */
 
 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 +192,8 @@ main(int argc, char *argv[])
        register struct fstab *dt;
        register char *map;
        register int ch;
        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;
        dump_ino_t maxino;
        struct STAT statbuf;
        dev_t filedev = 0;
@@ -254,6 +256,7 @@ main(int argc, char *argv[])
 
                case 'a':               /* `auto-size', Write to EOM. */
                        unlimited = 1;
 
                case 'a':               /* `auto-size', Write to EOM. */
                        unlimited = 1;
+                       aflag = 1;
                        break;
 
                case 'B':               /* blocks per output file */
                        break;
 
                case 'B':               /* blocks per output file */
@@ -411,11 +414,12 @@ main(int argc, char *argv[])
                exit(X_STARTUP);
        }
        argc--;
                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";
        if (strcmp(tapeprefix, "-") == 0) {
                pipeout++;
                tapeprefix = "standard output";
@@ -1184,3 +1188,12 @@ do_exclude_from_file(char *file) {
        }
        fclose(f);
 }
        }
        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);
+       }
+}