aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-09-26 11:47:24 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-09-26 11:47:24 +0200
commite9d1d3dc9aa4b53be536f97f253cc908e58429ec (patch)
tree6e79c9706ef7707890d40e7f1e894bd786c8f34b
parentcd1ec786238202b987a7624e763dadc725a46a67 (diff)
Add no-pad option to gensquashfs, sqfs2tar
This works similar to the option for mksquashfs, preventing the image from being padded to device block size. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--bin/gensquashfs/gensquashfs.14
-rw-r--r--bin/gensquashfs/options.c6
-rw-r--r--bin/tar2sqfs/options.c9
-rw-r--r--bin/tar2sqfs/tar2sqfs.14
-rw-r--r--include/simple_writer.h1
-rw-r--r--lib/common/writer/finish.c8
6 files changed, 29 insertions, 3 deletions
diff --git a/bin/gensquashfs/gensquashfs.1 b/bin/gensquashfs/gensquashfs.1
index 88f58c4..48489a9 100644
--- a/bin/gensquashfs/gensquashfs.1
+++ b/bin/gensquashfs/gensquashfs.1
@@ -106,6 +106,10 @@ Generate an export table for NFS support.
Do not perform tail end packing on files that are larger than the specified
block size.
.TP
+\fB\-\-no\-pad\fR
+Do not pad the resulting image to device block size. May result in an image
+that cannot be loop mounted.
+.TP
\fB\-\-force\fR, \fB\-f\fR
Overwrite the output file if it exists.
.TP
diff --git a/bin/gensquashfs/options.c b/bin/gensquashfs/options.c
index f263bce..9bc79a6 100644
--- a/bin/gensquashfs/options.c
+++ b/bin/gensquashfs/options.c
@@ -8,10 +8,12 @@
enum {
ALL_ROOT_OPTION = 1,
+ NO_PAD_OPTION = 2,
};
static struct option long_opts[] = {
{ "all-root", no_argument, NULL, ALL_ROOT_OPTION },
+ { "no-pad", no_argument, NULL, NO_PAD_OPTION },
{ "set-uid", required_argument, NULL, 'u' },
{ "set-gid", required_argument, NULL, 'g' },
{ "compressor", required_argument, NULL, 'c' },
@@ -123,6 +125,7 @@ const char *extra_options =
" --exportable, -e Generate an export table for NFS support.\n"
" --no-tail-packing, -T Do not perform tail end packing on files that\n"
" are larger than block size.\n"
+" --no-pad Do not pad image to device block size.\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"
@@ -212,6 +215,9 @@ void process_command_line(options_t *opt, int argc, char **argv)
opt->force_uid = true;
opt->force_gid = true;
break;
+ case NO_PAD_OPTION:
+ opt->cfg.no_pad = true;
+ break;
case 'u':
opt->force_uid_value = strtol(optarg, NULL, 0);
opt->force_uid = true;
diff --git a/bin/tar2sqfs/options.c b/bin/tar2sqfs/options.c
index dd0d02f..21e5004 100644
--- a/bin/tar2sqfs/options.c
+++ b/bin/tar2sqfs/options.c
@@ -6,7 +6,12 @@
*/
#include "tar2sqfs.h"
+enum {
+ NO_PAD_OPTION = 1,
+};
+
static struct option long_opts[] = {
+ { "no-pad", no_argument, NULL, NO_PAD_OPTION },
{ "root-becomes", required_argument, NULL, 'r' },
{ "compressor", required_argument, NULL, 'c' },
{ "block-size", required_argument, NULL, 'b' },
@@ -81,6 +86,7 @@ static const char *usagestr =
" --no-tail-packing, -T Do not perform tail end packing on files that\n"
" are larger than block size.\n"
" --exclude-dir, -E <glob> Skip tar entry if glob matches.\n"
+" --no-pad Do not pad image to device block size.\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"
@@ -132,6 +138,9 @@ void process_args(int argc, char **argv)
break;
switch (i) {
+ case NO_PAD_OPTION:
+ cfg.no_pad = true;
+ break;
case 'S':
no_symlink_retarget = true;
break;
diff --git a/bin/tar2sqfs/tar2sqfs.1 b/bin/tar2sqfs/tar2sqfs.1
index 2cac9e2..b11b159 100644
--- a/bin/tar2sqfs/tar2sqfs.1
+++ b/bin/tar2sqfs/tar2sqfs.1
@@ -109,6 +109,10 @@ Generate an export table for NFS support.
Do not perform tail end packing on files that are larger than the
specified block size.
.TP
+\fB\-\-no\-pad\fR
+Do not pad the resulting image to device block size. May result in an image
+that cannot be loop mounted.
+.TP
\fB\-\-force\fR, \fB\-f\fR
Overwrite the output file if it exists.
.TP
diff --git a/include/simple_writer.h b/include/simple_writer.h
index 4885b9f..c6d2833 100644
--- a/include/simple_writer.h
+++ b/include/simple_writer.h
@@ -54,6 +54,7 @@ typedef struct {
bool exportable;
bool no_xattr;
bool quiet;
+ bool no_pad;
} sqfs_writer_cfg_t;
#ifdef __cplusplus
diff --git a/lib/common/writer/finish.c b/lib/common/writer/finish.c
index c539579..bd1e11e 100644
--- a/lib/common/writer/finish.c
+++ b/lib/common/writer/finish.c
@@ -164,9 +164,11 @@ int sqfs_writer_finish(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *cfg)
return -1;
}
- if (padd_sqfs(sqfs->outfile, sqfs->super.bytes_used,
- cfg->devblksize)) {
- return -1;
+ if (!cfg->no_pad) {
+ if (padd_sqfs(sqfs->outfile, sqfs->super.bytes_used,
+ cfg->devblksize)) {
+ return -1;
+ }
}
if (!cfg->quiet)