aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-03 12:28:37 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-03 12:28:37 +0200
commitb51a3ab10fad0d00c6fe2aa4d4c1afc6cfcf371f (patch)
tree323767920e7518c0509757f1a83c57d56daf0338
parentc25949ab28b916c89d719d3a011df5ae36b9087f (diff)
Add no-skip option to tar2sqfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--doc/tar2sqfs.18
-rw-r--r--tar/tar2sqfs.c16
2 files changed, 18 insertions, 6 deletions
diff --git a/doc/tar2sqfs.1 b/doc/tar2sqfs.1
index c43e412..c1cb619 100644
--- a/doc/tar2sqfs.1
+++ b/doc/tar2sqfs.1
@@ -51,6 +51,9 @@ mtime=<value>;0
.TE
.TP
.TP
+\fB\-\-no\-skip\fR, \fB\-s\fR
+Abort if a tar record cannot be read instead of skipping it.
+.TP
\fB\-\-force\fR, \fB\-f\fR
Overwrite the output file if it exists.
.TP
@@ -73,8 +76,9 @@ older, legacy headers are not supported) and extensions like sparse files.
Hard links are currently not supported and silently converted to symlinks.
Furthermore, none of the various xattr extensions are currently implemented.
-If any unsupported section is encountered in an archive, the section is skipped
-and a warning message is written to stderr.
+If any unsupported section is encountered in an archive a warning message is
+written to stderr. If the \fB\-\-no\-skip\fR option is set, processing aborts.
+By default, the unknown section is simply skipped after issuing a warning.
.SH EXAMPLES
.TP
Turn an uncompressed tar archive into a squashfs image:
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index dec717b..e239acd 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -24,13 +24,14 @@ static struct option long_opts[] = {
{ "dev-block-size", required_argument, NULL, 'B' },
{ "defaults", required_argument, NULL, 'd' },
{ "comp-extra", required_argument, NULL, 'X' },
+ { "no-skip", no_argument, NULL, 's' },
{ "force", no_argument, NULL, 'f' },
{ "quiet", no_argument, NULL, 'q' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "c:b:B:d:X:fqhV";
+static const char *short_opts = "c:b:B:d:X:sfqhV";
static const char *usagestr =
"Usage: tar2sqfs [OPTIONS...] <sqfsfile>\n"
@@ -58,6 +59,8 @@ static const char *usagestr =
" mode=<value> 0755 if not set.\n"
" mtime=<value> 0 if not set.\n"
"\n"
+" --no-skip, -s Abort if a tar record cannot be read instead\n"
+" of skipping it.\n"
" --force, -f Overwrite the output file if it exists.\n"
" --quiet, -q Do not print out progress reports.\n"
" --help, -h Print help text and exit.\n"
@@ -78,6 +81,7 @@ static int outmode = O_WRONLY | O_CREAT | O_EXCL;
static E_SQFS_COMPRESSOR comp_id;
static char *comp_extra = NULL;
static char *fs_defaults = NULL;
+static bool dont_skip = false;
static void process_args(int argc, char **argv)
{
@@ -124,6 +128,9 @@ static void process_args(int argc, char **argv)
case 'd':
fs_defaults = optarg;
break;
+ case 's':
+ dont_skip = true;
+ break;
case 'f':
outmode = O_WRONLY | O_CREAT | O_TRUNC;
break;
@@ -224,8 +231,7 @@ static int process_tar_ball(fstree_t *fs, data_writer_t *data)
skip = false;
if (hdr.unknown_record) {
- fprintf(stderr, "skipping '%s' (unknown entry type)\n",
- hdr.name);
+ fprintf(stderr, "%s: unknown entry type\n", hdr.name);
skip = true;
}
@@ -246,12 +252,14 @@ static int process_tar_ball(fstree_t *fs, data_writer_t *data)
skip = true;
if (skip) {
- fprintf(stderr, "skipping '%s' (broken sparse "
+ fprintf(stderr, "%s: broken sparse "
"file layout)\n", hdr.name);
}
}
if (skip) {
+ if (dont_skip)
+ goto fail;
if (skip_entry(STDIN_FILENO, hdr.sb.st_size))
goto fail;
continue;