summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-03-18 22:16:46 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-03-18 22:16:46 +0200
commitec72abd9dd63bbff4534ec77e97b1a6cadfc3cf8 (patch)
tree88cec8c9a7804568b43fdaa1d3c764fc591a910e
parent58b8ac114790e2de7992db1a387ec14238783f39 (diff)
downloadpaxutils-ec72abd9dd63bbff4534ec77e97b1a6cadfc3cf8.tar.gz
genfile: new option --quiet
* tests/genfile.c: New option --quite: suppress error exit if the created file is not sparse. * doc/genfile.texi: Document --quiet.
-rw-r--r--doc/genfile.texi10
-rw-r--r--tests/genfile.c16
2 files changed, 20 insertions, 6 deletions
diff --git a/doc/genfile.texi b/doc/genfile.texi
index bd2e505..e35f34b 100644
--- a/doc/genfile.texi
+++ b/doc/genfile.texi
@@ -181,8 +181,14 @@ letters @samp{A}, @samp{B}, @samp{C} and @samp{D}.
@item 1053184 @tab 2048000 @tab Zero bytes
@end multitable
- The exit code of @command{genfile --status} command is @code{0}
-only if created file is actually sparse.
+@cindex --quite, option
+ The exit code of @command{genfile --sparse} command is @code{0}
+only if created file is actually sparse. If it is not, the
+appropriate error message is displayed and the command exists with
+code @code{1}. The @option{--quite} (@option{-q}) option suppresses
+this behavior. If @option{--quite} is given, @command{genfile
+--sparse} exits with code @code{0} if it was able to create the file,
+whether the resulting file is sparse or not.
@node Status Mode
@appendixsec Status Mode
diff --git a/tests/genfile.c b/tests/genfile.c
index 4699d21..336788f 100644
--- a/tests/genfile.c
+++ b/tests/genfile.c
@@ -107,6 +107,9 @@ struct timespec touch_time;
/* Verbose mode */
int verbose;
+/* Quiet mode */
+int quiet;
+
const char *argp_program_version = "genfile (" PACKAGE ") " VERSION;
const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
static char doc[] = N_("genfile manipulates data files for GNU paxutils test suite.\n"
@@ -145,7 +148,8 @@ static struct argp_option options[] = {
{"seek", OPT_SEEK, N_("OFFSET"), 0,
N_("Seek to the given offset before writing data"),
GRP+1 },
-
+ {"quiet", 'q', NULL, 0,
+ N_("Suppress non-fatal diagnostic messages") },
#undef GRP
#define GRP 10
{NULL, 0, NULL, 0,
@@ -266,11 +270,11 @@ verify_file (char *file_name)
error (0, errno, _("stat(%s) failed"), file_name);
if (st.st_size != file_length + seek_offset)
- error (1, 0, _("requested file length %lu, actual %lu"),
+ error (EXIT_FAILURE, 0, _("requested file length %lu, actual %lu"),
(unsigned long)st.st_size, (unsigned long)file_length);
- if (mode == mode_sparse && !ST_IS_SPARSE (st))
- error (1, 0, _("created file is not sparse"));
+ if (!quiet && mode == mode_sparse && !ST_IS_SPARSE (st))
+ error (EXIT_FAILURE, 0, _("created file is not sparse"));
}
}
@@ -326,6 +330,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
block_size = get_size (arg, 0);
break;
+ case 'q':
+ quiet = 1;
+ break;
+
case 's':
mode = mode_sparse;
break;