aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-04 23:30:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-05 00:10:28 +0200
commitda5656a8a696863e0d9941091c09c75b03a6070b (patch)
tree175f713894fda83722be311e6b66bb957da11eaa
parenta2750dee0e4c374ae51f83eead7eb7df3c018d95 (diff)
Print out what we are doing on the way and options to keep quiet
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--mkfs/block.c26
-rw-r--r--mkfs/mkfs.h1
-rw-r--r--mkfs/options.c7
-rw-r--r--unpack/rdsquashfs.c9
-rw-r--r--unpack/rdsquashfs.h1
-rw-r--r--unpack/restore_fstree.c16
6 files changed, 53 insertions, 7 deletions
diff --git a/mkfs/block.c b/mkfs/block.c
index 76b261d..545df53 100644
--- a/mkfs/block.c
+++ b/mkfs/block.c
@@ -175,18 +175,36 @@ fail_trunc:
goto fail;
}
-static int find_and_process_files(sqfs_info_t *info, tree_node_t *n)
+static void print_name(tree_node_t *n)
+{
+ if (n->parent != NULL) {
+ print_name(n->parent);
+ fputc('/', stdout);
+ }
+
+ fputs(n->name, stdout);
+}
+
+static int find_and_process_files(sqfs_info_t *info, tree_node_t *n,
+ bool quiet)
{
if (S_ISDIR(n->mode)) {
for (n = n->data.dir->children; n != NULL; n = n->next) {
- if (find_and_process_files(info, n))
+ if (find_and_process_files(info, n, quiet))
return -1;
}
return 0;
}
- if (S_ISREG(n->mode))
+ if (S_ISREG(n->mode)) {
+ if (!quiet) {
+ fputs("packing ", stdout);
+ print_name(n);
+ fputc('\n', stdout);
+ }
+
return process_file(info, n->data.file);
+ }
return 0;
}
@@ -218,7 +236,7 @@ int write_data_to_image(sqfs_info_t *info)
return -1;
}
- ret = find_and_process_files(info, info->fs.root);
+ ret = find_and_process_files(info, info->fs.root, info->opt.quiet);
free(info->block);
free(info->fragment);
diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h
index 8a867f2..c689848 100644
--- a/mkfs/mkfs.h
+++ b/mkfs/mkfs.h
@@ -25,6 +25,7 @@ typedef struct {
int compressor;
int blksz;
int devblksz;
+ bool quiet;
const char *infile;
const char *outfile;
} options_t;
diff --git a/mkfs/options.c b/mkfs/options.c
index 4d49a9b..0a556eb 100644
--- a/mkfs/options.c
+++ b/mkfs/options.c
@@ -17,11 +17,12 @@ static struct option long_opts[] = {
{ "dev-block-size", required_argument, NULL, 'B' },
{ "defaults", required_argument, NULL, 'd' },
{ "force", no_argument, NULL, 'f' },
+ { "quiet", no_argument, NULL, 'q' },
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
};
-static const char *short_opts = "c:b:B:d:fhV";
+static const char *short_opts = "c:b:B:d:fqhV";
enum {
DEF_UID = 0,
@@ -97,6 +98,7 @@ static const char *help_string =
" mtime=<value> 0 if not set.\n"
"\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";
@@ -260,6 +262,9 @@ void process_command_line(options_t *opt, int argc, char **argv)
case 'f':
opt->outmode = O_WRONLY | O_CREAT | O_TRUNC;
break;
+ case 'q':
+ opt->quiet = true;
+ break;
case 'h':
printf(help_string, __progname,
SQFS_DEFAULT_BLOCK_SIZE, SQFS_DEVBLK_SIZE);
diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c
index c286a78..f09847d 100644
--- a/unpack/rdsquashfs.c
+++ b/unpack/rdsquashfs.c
@@ -20,11 +20,12 @@ static struct option long_opts[] = {
{ "no-empty-dir", no_argument, NULL, 'E' },
{ "chmod", no_argument, NULL, 'C' },
{ "chown", no_argument, NULL, 'O' },
+ { "quiet", no_argument, NULL, 'q' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "l:c:u:p:DSFLCOEhV";
+static const char *short_opts = "l:c:u:p:DSFLCOEqhV";
static const char *help_string =
"Usage: %s [OPTIONS] <squashfs-file>\n"
@@ -48,7 +49,8 @@ static const char *help_string =
" --chmod, -C Change permission flags of unpacked files to those\n"
" store in the squashfs image.\n"
" --chown, -O Change ownership of unpacked files to the UID/GID\n"
-" set in the squashfs iamge.\n"
+" set in the squashfs image.\n"
+" --quiet, -q Do not print out progress while unpacking.\n"
"\n"
" --help, -h Print help text and exit.\n"
" --version, -V Print version information and exit.\n"
@@ -201,6 +203,9 @@ int main(int argc, char **argv)
case 'p':
cmdpath = get_path(cmdpath, optarg);
break;
+ case 'q':
+ info.flags |= UNPACK_QUIET;
+ break;
case 'h':
printf(help_string, __progname);
status = EXIT_SUCCESS;
diff --git a/unpack/rdsquashfs.h b/unpack/rdsquashfs.h
index c06afb2..a9d5bdf 100644
--- a/unpack/rdsquashfs.h
+++ b/unpack/rdsquashfs.h
@@ -27,6 +27,7 @@ enum UNPACK_FLAGS {
UNPACK_NO_EMPTY = 0x10,
UNPACK_CHMOD = 0x20,
UNPACK_CHOWN = 0x40,
+ UNPACK_QUIET = 0x80,
};
typedef struct {
diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c
index c06cd2b..c1320ea 100644
--- a/unpack/restore_fstree.c
+++ b/unpack/restore_fstree.c
@@ -1,10 +1,26 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
#include "rdsquashfs.h"
+static void print_name(tree_node_t *n)
+{
+ if (n->parent != NULL) {
+ print_name(n->parent);
+ fputc('/', stdout);
+ }
+
+ fputs(n->name, stdout);
+}
+
static int create_node(int dirfd, tree_node_t *n, unsqfs_info_t *info)
{
int fd;
+ if (!(info->flags & UNPACK_QUIET)) {
+ fputs("unpacking ", stdout);
+ print_name(n);
+ fputc('\n', stdout);
+ }
+
switch (n->mode & S_IFMT) {
case S_IFDIR:
if (mkdirat(dirfd, n->name, 0755) && errno != EEXIST) {