aboutsummaryrefslogtreecommitdiff
path: root/tar
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-23 00:04:45 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-23 00:06:38 +0200
commit56d5656d52e79077d67e141bb48fb433f255a81f (patch)
tree0551f2de203d476dc4675ed2c4c832d024d52909 /tar
parentaf2bf44067a0ae5025f0b7738dacc14c4c1dc09a (diff)
tar2sqfs: Add some output messages, --quiet flag and --force
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar')
-rw-r--r--tar/tar2sqfs.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index 6f6ba21..b8952a9 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -19,11 +19,13 @@
#include <fcntl.h>
static struct option long_opts[] = {
+ { "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 = "hV";
+static const char *short_opts = "fqhV";
static const char *usagestr =
"Usage: tar2sqfs [OPTIONS...] <sqfsfile>\n"
@@ -33,8 +35,10 @@ static const char *usagestr =
"\n"
"Possible options:\n"
"\n"
-" --help, -h Print help text and exit.\n"
-" --version, -V Print version information and exit.\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"
+" --version, -V Print version information and exit.\n"
"\n"
"Examples:\n"
"\n"
@@ -50,6 +54,8 @@ static uint16_t def_mode = 0755;
static uint32_t def_uid = 0;
static uint32_t def_gid = 0;
static size_t devblksize = SQFS_DEVBLK_SIZE;
+static bool quiet = false;
+static int outmode = O_WRONLY | O_CREAT | O_EXCL;
static void process_args(int argc, char **argv)
{
@@ -61,6 +67,12 @@ static void process_args(int argc, char **argv)
break;
switch (i) {
+ case 'f':
+ outmode = O_WRONLY | O_CREAT | O_TRUNC;
+ break;
+ case 'q':
+ quiet = true;
+ break;
case 'h':
fputs(usagestr, stdout);
exit(EXIT_SUCCESS);
@@ -98,6 +110,9 @@ static int create_node_and_repack_data(tar_header_decoded_t *hdr, fstree_t *fs,
if (node == NULL)
goto fail_errno;
+ if (!quiet)
+ printf("Packing %s\n", hdr->name);
+
if (S_ISREG(hdr->sb.st_mode)) {
if (write_data_from_fd(data, node->data.file,
STDIN_FILENO)) {
@@ -167,7 +182,7 @@ int main(int argc, char **argv)
process_args(argc, argv);
- outfd = open(filename, O_CREAT | O_EXCL | O_RDWR, 0644);
+ outfd = open(filename, outmode, 0644);
if (outfd < 0) {
perror(filename);
return EXIT_FAILURE;