summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/tar2sqfs.16
-rw-r--r--tar/tar2sqfs.c23
2 files changed, 25 insertions, 4 deletions
diff --git a/doc/tar2sqfs.1 b/doc/tar2sqfs.1
index c546935..d2688a6 100644
--- a/doc/tar2sqfs.1
+++ b/doc/tar2sqfs.1
@@ -14,6 +14,12 @@ squashfs.
.PP
Possible options:
.TP
+\fB\-\-force\fR, \fB\-f\fR
+Overwrite the output file if it exists.
+.TP
+\fB\-\-quiet\fR, \fB\-q\fR
+Do not print out progress reports.
+.TP
\fB\-\-help\fR, \fB\-h\fR
Print help text and exit.
.TP
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;