aboutsummaryrefslogtreecommitdiff
path: root/tar/sqfs2tar.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-03 15:22:28 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-03 15:28:40 +0200
commite981f2e460092e5ae6ad58a60869b78d7f50ec10 (patch)
tree7911d99b0ab70a1d8eb92fed244cbc8761b4bf72 /tar/sqfs2tar.c
parent70dcf39f5926a66d76eb9fde2cbaef4b6a23a9e1 (diff)
Add no-skip option to sqfs2tar
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar/sqfs2tar.c')
-rw-r--r--tar/sqfs2tar.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c
index e568bb4..76c0d74 100644
--- a/tar/sqfs2tar.c
+++ b/tar/sqfs2tar.c
@@ -17,11 +17,12 @@
#include <stdio.h>
static struct option long_opts[] = {
+ { "no-skip", no_argument, NULL, 's' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "hV";
+static const char *short_opts = "shV";
static const char *usagestr =
"Usage: sqfs2tar [OPTIONS...] <sqfsfile>\n"
@@ -31,6 +32,10 @@ static const char *usagestr =
"\n"
"Possible options:\n"
"\n"
+" --no-skip Abort if a file cannot be stored in a tar\n"
+" archive. By default, it is simply skipped\n"
+" and a warning is written to stderr."
+"\n"
" --help, -h Print help text and exit.\n"
" --version, -V Print version information and exit.\n"
"\n"
@@ -43,6 +48,7 @@ static const char *usagestr =
static const char *filename;
static unsigned int record_counter;
+static bool dont_skip = false;
static void process_args(int argc, char **argv)
{
@@ -54,6 +60,9 @@ static void process_args(int argc, char **argv)
break;
switch (i) {
+ case 's':
+ dont_skip = true;
+ break;
case 'h':
fputs(usagestr, stdout);
exit(EXIT_SUCCESS);
@@ -124,12 +133,24 @@ static int write_tree_dfs(fstree_t *fs, tree_node_t *n, data_reader_t *data)
target = S_ISLNK(sb.st_mode) ? n->data.slink_target : NULL;
ret = write_tar_header(STDOUT_FILENO, &sb, name, target,
record_counter++);
+
+ if (ret > 0) {
+ if (dont_skip) {
+ fputs("Not allowed to skip files, aborting!\n",
+ stderr);
+ ret = -1;
+ } else {
+ fprintf(stderr, "Skipping %s\n", name);
+ ret = 0;
+ }
+ free(name);
+ return ret;
+ }
+
free(name);
if (ret < 0)
return -1;
- if (ret > 0)
- return 0;
if (S_ISREG(n->mode)) {
if (data_reader_dump_file(data, n->data.file,