From 74f25ae0f3ebc1cd435f29c21ab164a9028af980 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 13 Dec 2019 01:19:27 +0100 Subject: Add --no-tail-packing option to gensquashfs, tar2sqfs Signed-off-by: David Oberhollenzer --- mkfs/mkfs.c | 8 +++++++- mkfs/mkfs.h | 1 + mkfs/options.c | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'mkfs') diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index 6ddcdb0..ea01452 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -51,6 +51,7 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs, char *node_path; file_info_t *fi; size_t size; + int flags; int ret; if (set_working_dir(opt)) @@ -115,7 +116,12 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs, fi->user_ptr = inode; - ret = write_data_from_file(path, data, inode, file, 0); + flags = 0; + + if (opt->no_tail_packing && filesize > opt->cfg.block_size) + flags |= SQFS_BLK_DONT_FRAGMENT; + + ret = write_data_from_file(path, data, inode, file, flags); file->destroy(file); free(node_path); diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h index 57bc39f..21e1715 100644 --- a/mkfs/mkfs.h +++ b/mkfs/mkfs.h @@ -37,6 +37,7 @@ typedef struct { const char *infile; const char *packdir; const char *selinux; + bool no_tail_packing; } options_t; enum { diff --git a/mkfs/options.c b/mkfs/options.c index 4dce84e..94707cb 100644 --- a/mkfs/options.c +++ b/mkfs/options.c @@ -22,6 +22,7 @@ static struct option long_opts[] = { #endif { "one-file-system", no_argument, NULL, 'o' }, { "exportable", no_argument, NULL, 'e' }, + { "no-tail-packing", no_argument, NULL, 'T' }, { "force", no_argument, NULL, 'f' }, { "quiet", no_argument, NULL, 'q' }, #ifdef WITH_SELINUX @@ -31,7 +32,7 @@ static struct option long_opts[] = { { "help", no_argument, NULL, 'h' }, }; -static const char *short_opts = "F:D:X:c:b:B:d:j:Q:kxoefqhV" +static const char *short_opts = "F:D:X:c:b:B:d:j:Q:kxoefqThV" #ifdef WITH_SELINUX "s:" #endif @@ -93,6 +94,8 @@ static const char *help_string = " --one-file-system, -o When using --pack-dir only, stay in local file\n" " system and do not cross mount points.\n" " --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" " --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" @@ -157,6 +160,9 @@ void process_command_line(options_t *opt, int argc, char **argv) break; switch (i) { + case 'T': + opt->no_tail_packing = true; + break; case 'c': have_compressor = true; ret = sqfs_compressor_id_from_name(optarg); -- cgit v1.2.3