Merge pull request #131309 from ruuda/squashfstools45
squashfsTools: 4.4 -> 4.5
This commit is contained in:
commit
a541cb388c
3 changed files with 33 additions and 113 deletions
|
@ -1,76 +0,0 @@
|
||||||
From d925c9a11ee2e88ac8aac03f51892746f2bcf8cd Mon Sep 17 00:00:00 2001
|
|
||||||
From: Phillip Lougher <phillip@squashfs.org.uk>
|
|
||||||
Date: Thu, 25 Feb 2021 23:12:10 +0000
|
|
||||||
Subject: [PATCH] Mksquashfs: add -no-hardlinks option
|
|
||||||
|
|
||||||
Normally Mksquashfs will detect hardlinks (multiple files with the
|
|
||||||
same inode) and hardlink them in the Squashfs image.
|
|
||||||
|
|
||||||
But often hardlinks are used in the original filesystem
|
|
||||||
to save space, when files are discovered to be duplicate.
|
|
||||||
In this special case the only reason the files are
|
|
||||||
hardlinked is to save space, and where the filesystem
|
|
||||||
doesn't handle duplicate files (different inode, same
|
|
||||||
data).
|
|
||||||
|
|
||||||
Squashfs does handle duplicate files, and so add
|
|
||||||
an option to ignore hardlinks and instead
|
|
||||||
store them as duplicates.
|
|
||||||
|
|
||||||
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
|
|
||||||
---
|
|
||||||
squashfs-tools/mksquashfs.c | 16 +++++++++++-----
|
|
||||||
1 file changed, 11 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
|
|
||||||
index a45b77f..d4dc359 100644
|
|
||||||
--- a/squashfs-tools/mksquashfs.c
|
|
||||||
+++ b/squashfs-tools/mksquashfs.c
|
|
||||||
@@ -312,6 +312,9 @@ struct dir_info *root_dir;
|
|
||||||
FILE *log_fd;
|
|
||||||
int logging=FALSE;
|
|
||||||
|
|
||||||
+/* Should Mksquashfs detect hardlinked files? */
|
|
||||||
+int no_hardlinks = FALSE;
|
|
||||||
+
|
|
||||||
static char *read_from_disk(long long start, unsigned int avail_bytes);
|
|
||||||
void add_old_root_entry(char *name, squashfs_inode inode, int inode_number,
|
|
||||||
int type);
|
|
||||||
@@ -3093,11 +3096,11 @@ struct inode_info *lookup_inode3(struct stat *buf, int pseudo, int id,
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Look-up inode in hash table, if it already exists we have a
|
|
||||||
- * hard-link, so increment the nlink count and return it.
|
|
||||||
- * Don't do the look-up for directories because we don't hard-link
|
|
||||||
- * directories.
|
|
||||||
+ * hardlink, so increment the nlink count and return it.
|
|
||||||
+ * Don't do the look-up for directories because Unix/Linux doesn't
|
|
||||||
+ * allow hard-links to directories.
|
|
||||||
*/
|
|
||||||
- if ((buf->st_mode & S_IFMT) != S_IFDIR) {
|
|
||||||
+ if ((buf->st_mode & S_IFMT) != S_IFDIR && !no_hardlinks) {
|
|
||||||
for(inode = inode_info[ino_hash]; inode; inode = inode->next) {
|
|
||||||
if(memcmp(buf, &inode->buf, sizeof(struct stat)) == 0) {
|
|
||||||
inode->nlink ++;
|
|
||||||
@@ -5447,7 +5450,9 @@ int main(int argc, char *argv[])
|
|
||||||
comp = lookup_compressor(COMP_DEFAULT);
|
|
||||||
|
|
||||||
for(i = source + 2; i < argc; i++) {
|
|
||||||
- if(strcmp(argv[i], "-mkfs-time") == 0 ||
|
|
||||||
+ if(strcmp(argv[i], "-no-hardlinks") == 0)
|
|
||||||
+ no_hardlinks = TRUE;
|
|
||||||
+ else if(strcmp(argv[i], "-mkfs-time") == 0 ||
|
|
||||||
strcmp(argv[i], "-fstime") == 0) {
|
|
||||||
if((++i == argc) || !parse_num_unsigned(argv[i], &mkfs_time)) {
|
|
||||||
ERROR("%s: %s missing or invalid time value\n", argv[0], argv[i - 1]);
|
|
||||||
@@ -5893,6 +5898,7 @@ printOptions:
|
|
||||||
"files larger than block size\n");
|
|
||||||
ERROR("-no-duplicates\t\tdo not perform duplicate "
|
|
||||||
"checking\n");
|
|
||||||
+ ERROR("-no-hardlinks\t\tdo not hardlink files, instead store duplicates\n");
|
|
||||||
ERROR("-all-root\t\tmake all files owned by root\n");
|
|
||||||
ERROR("-root-mode <mode>\tset root directory permissions to octal <mode>\n");
|
|
||||||
ERROR("-force-uid <uid>\tset all file uids to <uid>\n");
|
|
||||||
--
|
|
||||||
2.30.0
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
This patch has been edited to apply to squashfs 4.4, commit
|
This patch is an old patch; see below for the original message body. The patch
|
||||||
52eb4c279cd283ed9802dd1ceb686560b22ffb67. Below is the original
|
has been updated twice: Once to apply to squashfs 4.4, commit
|
||||||
message body of the patch.
|
52eb4c279cd283ed9802dd1ceb686560b22ffb67, and later to apply to squashfs 4.5,
|
||||||
|
commit 0496d7c3de3e09da37ba492081c86159806ebb07.
|
||||||
|
|
||||||
From 7bda7c75748f36b0a50f93e46144d5a4de4974ad Mon Sep 17 00:00:00 2001
|
From 7bda7c75748f36b0a50f93e46144d5a4de4974ad Mon Sep 17 00:00:00 2001
|
||||||
From: Amin Hassani <ahassani@google.com>
|
From: Amin Hassani <ahassani@google.com>
|
||||||
|
@ -20,24 +21,23 @@ increased_size = (number_of_unfragmented_files_in_image + number of fragments) *
|
||||||
|
|
||||||
The 4k alignment can be enabled by flag '-4k-align'
|
The 4k alignment can be enabled by flag '-4k-align'
|
||||||
---
|
---
|
||||||
squashfs-tools/mksquashfs.c | 16 ++++++++++++++++
|
squashfs-tools/mksquashfs.c | 17 +++++++++++++++++
|
||||||
1 file changed, 16 insertions(+)
|
1 file changed, 17 insertions(+)
|
||||||
|
|
||||||
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
|
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
|
||||||
index a45b77f..07b1c06 100644
|
index aaa4b00..eb2fb23 100644
|
||||||
--- a/squashfs-tools/mksquashfs.c
|
--- a/squashfs-tools/mksquashfs.c
|
||||||
+++ b/squashfs-tools/mksquashfs.c
|
+++ b/squashfs-tools/mksquashfs.c
|
||||||
@@ -102,7 +102,9 @@ int old_exclude = TRUE;
|
@@ -99,6 +99,8 @@ int nopad = FALSE;
|
||||||
int use_regex = FALSE;
|
|
||||||
int nopad = FALSE;
|
|
||||||
int exit_on_error = FALSE;
|
int exit_on_error = FALSE;
|
||||||
+int do_4k_align = FALSE;
|
|
||||||
long long start_offset = 0;
|
long long start_offset = 0;
|
||||||
|
int sleep_time = 0;
|
||||||
|
+int do_4k_align = FALSE;
|
||||||
+#define ALIGN_UP(bytes, size) (bytes = (bytes + size - 1) & ~(size - 1))
|
+#define ALIGN_UP(bytes, size) (bytes = (bytes + size - 1) & ~(size - 1))
|
||||||
|
|
||||||
long long global_uid = -1, global_gid = -1;
|
long long global_uid = -1, global_gid = -1;
|
||||||
|
|
||||||
@@ -1546,6 +1548,9 @@ void unlock_fragments()
|
@@ -1553,6 +1555,9 @@ static void unlock_fragments()
|
||||||
* queue at this time.
|
* queue at this time.
|
||||||
*/
|
*/
|
||||||
while(!queue_empty(locked_fragment)) {
|
while(!queue_empty(locked_fragment)) {
|
||||||
|
@ -47,7 +47,7 @@ index a45b77f..07b1c06 100644
|
||||||
write_buffer = queue_get(locked_fragment);
|
write_buffer = queue_get(locked_fragment);
|
||||||
frg = write_buffer->block;
|
frg = write_buffer->block;
|
||||||
size = SQUASHFS_COMPRESSED_SIZE_BLOCK(fragment_table[frg].size);
|
size = SQUASHFS_COMPRESSED_SIZE_BLOCK(fragment_table[frg].size);
|
||||||
@@ -2478,6 +2483,9 @@ void *frag_deflator(void *arg)
|
@@ -2460,6 +2465,9 @@ static void *frag_deflator(void *arg)
|
||||||
write_buffer->size = compressed_size;
|
write_buffer->size = compressed_size;
|
||||||
pthread_mutex_lock(&fragment_mutex);
|
pthread_mutex_lock(&fragment_mutex);
|
||||||
if(fragments_locked == FALSE) {
|
if(fragments_locked == FALSE) {
|
||||||
|
@ -57,18 +57,26 @@ index a45b77f..07b1c06 100644
|
||||||
fragment_table[file_buffer->block].size = c_byte;
|
fragment_table[file_buffer->block].size = c_byte;
|
||||||
fragment_table[file_buffer->block].start_block = bytes;
|
fragment_table[file_buffer->block].start_block = bytes;
|
||||||
write_buffer->block = bytes;
|
write_buffer->block = bytes;
|
||||||
@@ -2877,6 +2885,10 @@ int write_file_blocks(squashfs_inode *inode, struct dir_ent *dir_ent,
|
@@ -2850,6 +2858,10 @@ static struct file_info *write_file_blocks(int *status, struct dir_ent *dir_ent,
|
||||||
long long sparse = 0;
|
struct file_info *file;
|
||||||
struct file_buffer *fragment_buffer = NULL;
|
int bl_hash = 0;
|
||||||
|
|
||||||
+ // 4k align the start of each file.
|
+ // 4k align the start of each file.
|
||||||
+ if(do_4k_align)
|
+ if(do_4k_align)
|
||||||
+ ALIGN_UP(bytes, 4096);
|
+ ALIGN_UP(bytes, 4096);
|
||||||
+
|
+
|
||||||
if(pre_duplicate(read_size))
|
if(pre_duplicate(read_size, dir_ent->inode, read_buffer, &bl_hash))
|
||||||
return write_file_blocks_dup(inode, dir_ent, read_buffer, dup);
|
return write_file_blocks_dup(status, dir_ent, read_buffer, dup, bl_hash);
|
||||||
|
|
||||||
@@ -4972,6 +4984,7 @@ void write_filesystem_tables(struct squashfs_super_block *sBlk, int nopad)
|
@@ -5975,6 +5987,7 @@ static void print_options(FILE *stream, char *name, int total_mem)
|
||||||
|
fprintf(stream, "actions from <f>\n");
|
||||||
|
fprintf(stream, "-false-action-file <f>\tas -false-action, but read ");
|
||||||
|
fprintf(stream, "actions from <f>\n");
|
||||||
|
+ fprintf(stream, "-4k-align\t\tenables 4k alignment of all files\n");
|
||||||
|
fprintf(stream, "\nFilesystem filter options:\n");
|
||||||
|
fprintf(stream, "-p <pseudo-definition>\tAdd pseudo file definition\n");
|
||||||
|
fprintf(stream, "-pf <pseudo-file>\tAdd list of pseudo file definitions\n");
|
||||||
|
@@ -6198,6 +6211,7 @@ static void print_summary()
|
||||||
"compressed", no_fragments ? "no" : noF ? "uncompressed" :
|
"compressed", no_fragments ? "no" : noF ? "uncompressed" :
|
||||||
"compressed", no_xattrs ? "no" : noX ? "uncompressed" :
|
"compressed", no_xattrs ? "no" : noX ? "uncompressed" :
|
||||||
"compressed", noI || noId ? "uncompressed" : "compressed");
|
"compressed", noI || noId ? "uncompressed" : "compressed");
|
||||||
|
@ -76,23 +84,15 @@ index a45b77f..07b1c06 100644
|
||||||
printf("\tduplicates are %sremoved\n", duplicate_checking ? "" :
|
printf("\tduplicates are %sremoved\n", duplicate_checking ? "" :
|
||||||
"not ");
|
"not ");
|
||||||
printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n", bytes / 1024.0,
|
printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n", bytes / 1024.0,
|
||||||
@@ -5853,6 +5866,8 @@ print_compressor_options:
|
@@ -7499,6 +7513,9 @@ print_compressor_options:
|
||||||
root_name = argv[i];
|
root_name = argv[i];
|
||||||
} else if(strcmp(argv[i], "-version") == 0) {
|
} else if(strcmp(argv[i], "-version") == 0) {
|
||||||
VERSION();
|
print_version("mksquashfs");
|
||||||
|
+
|
||||||
+ } else if(strcmp(argv[i], "-4k-align") == 0) {
|
+ } else if(strcmp(argv[i], "-4k-align") == 0) {
|
||||||
+ do_4k_align = TRUE;
|
+ do_4k_align = TRUE;
|
||||||
} else {
|
} else {
|
||||||
ERROR("%s: invalid option\n\n", argv[0]);
|
ERROR("%s: invalid option\n\n", argv[0]);
|
||||||
printOptions:
|
print_options(stderr, argv[0], total_mem);
|
||||||
@@ -5904,6 +5919,7 @@ printOptions:
|
|
||||||
ERROR("\t\t\tdirectory containing that directory, "
|
|
||||||
"rather than the\n");
|
|
||||||
ERROR("\t\t\tcontents of the directory\n");
|
|
||||||
+ ERROR("-4k-align\t\tenables 4k alignment of all files\n");
|
|
||||||
ERROR("\nFilesystem filter options:\n");
|
|
||||||
ERROR("-p <pseudo-definition>\tAdd pseudo file "
|
|
||||||
"definition\n");
|
|
||||||
--
|
--
|
||||||
2.23.0
|
2.32.0
|
||||||
|
|
||||||
|
|
|
@ -10,23 +10,19 @@
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "squashfs";
|
pname = "squashfs";
|
||||||
version = "4.4";
|
version = "4.5";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "plougher";
|
owner = "plougher";
|
||||||
repo = "squashfs-tools";
|
repo = "squashfs-tools";
|
||||||
rev = version;
|
rev = version;
|
||||||
sha256 = "0697fv8n6739mcyn57jclzwwbbqwpvjdfkv1qh9s56lvyqnplwaw";
|
sha256 = "1nanwz5qvsakxfm37md5i7xqagv69nfik9hpj8qlp6ymw266vgxr";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# This patch adds an option to pad filesystems (increasing size) in
|
# This patch adds an option to pad filesystems (increasing size) in
|
||||||
# exchange for better chunking / binary diff calculation.
|
# exchange for better chunking / binary diff calculation.
|
||||||
./4k-align.patch
|
./4k-align.patch
|
||||||
# Add -no-hardlinks option. This is a rebased version of
|
|
||||||
# c37bb4da4a5fa8c1cf114237ba364692dd522262, can be removed
|
|
||||||
# when upgrading to the next version after 4.4
|
|
||||||
./0001-Mksquashfs-add-no-hardlinks-option.patch
|
|
||||||
] ++ lib.optional stdenv.isDarwin ./darwin.patch;
|
] ++ lib.optional stdenv.isDarwin ./darwin.patch;
|
||||||
|
|
||||||
buildInputs = [ zlib xz zstd lz4 lzo ];
|
buildInputs = [ zlib xz zstd lz4 lzo ];
|
||||||
|
|
Loading…
Reference in a new issue