From 8cef350eb9ffa2e543a95756a8f605175380f7b0 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 16 Aug 2001 13:12:30 +0000 Subject: [PATCH] Refuse incompatible options in dump (-a and -B). --- CHANGES | 5 ++++- dump/main.c | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 204f3eb..ffbb11d 100644 --- 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 ?????????????) =================================================================== @@ -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. +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) =================================================================== diff --git a/dump/main.c b/dump/main.c index 8fcf468..8f33f95 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.58 2001/08/16 13:12:30 stelian Exp $"; #endif /* not lint */ #include @@ -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 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 +192,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; @@ -254,6 +256,7 @@ main(int argc, char *argv[]) case 'a': /* `auto-size', Write to EOM. */ unlimited = 1; + aflag = 1; break; case 'B': /* blocks per output file */ @@ -411,11 +414,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"; @@ -1184,3 +1188,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); + } +} -- 2.39.2