From dae6dc6e91f34d83f60c0ee7b95e13efff1666ee Mon Sep 17 00:00:00 2001 From: Bruno Wolff III Date: Jul 26 2021 12:23:53 +0000 Subject: Include upstream fix for bug 1985561 From a comment on the bug: This is a regression caused by rewriting the duplicate checking code to be more aggressive when looking for duplicates when using tail-end packing. In particular a file doesn't now have to be the same size to be considered a (partial) duplicate. --- diff --git a/fix-sparse.patch b/fix-sparse.patch new file mode 100644 index 0000000..b6e2128 --- /dev/null +++ b/fix-sparse.patch @@ -0,0 +1,30 @@ +diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c +index aaa4b002bd87..127df00fb789 100644 +--- a/squashfs-tools/mksquashfs.c ++++ b/squashfs-tools/mksquashfs.c +@@ -2190,10 +2190,23 @@ static struct file_info *duplicate(int *dupf, int *block_dup, long long file_siz + /* Yes, the block list matches. We can use this, rather + * than writing an identical block list. + * If both it and us doesn't have a tail-end fragment, then we're +- * finished. Return the duplicate */ ++ * finished. Return the duplicate. ++ * ++ * We have to deal with the special case where the ++ * last block is a sparse block. This means the ++ * file will have matched, but, it may be a different ++ * file length (because a tail-end sparse block may be ++ * anything from 1 byte to block_size - 1 in size, but ++ * stored as zero). We can still use the block list in ++ * this case, but, we must return a new entry with the ++ * correct file size */ + if(!frag_bytes && !dupl_ptr->fragment->size) { + *dupf = *block_dup = TRUE; +- return dupl_ptr; ++ if(file_size == dupl_ptr->file_size) ++ return dupl_ptr; ++ else ++ return create_non_dup(file_size, bytes, blocks, sparse, dupl_ptr->block_list, ++ dupl_ptr->start, dupl_ptr->fragment, checksum, 0, checksum_flag, FALSE); + } + + /* We've got a tail-end fragment, and this file most likely diff --git a/squashfs-tools.spec b/squashfs-tools.spec index 32f4c44..995c6ac 100644 --- a/squashfs-tools.spec +++ b/squashfs-tools.spec @@ -2,7 +2,7 @@ Summary: Utility for the creation of squashfs filesystems %global forgeurl https://github.com/plougher/squashfs-tools Version: 4.5 Name: squashfs-tools -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: %{forgeurl}/archive/4.5.tar.gz Source: 4.5.tar.gz @@ -11,6 +11,10 @@ Source: 4.5.tar.gz # Man pages still need a lot of changes for 4.5 Source1: mksquashfs.1 Source2: unsquashfs.1 +# Mksquashfs: fix duplicate check when last file block is sparse +# git diff 19b161c1cd3e31f7a396ea92dea4390ad43f27b9^ 19b161c1cd3e31f7a396ea92dea4390ad43f27b9 > fix-sparse.patch +# https://bugzilla.gnome.org/show_bug.cgi?id=1985561 +Patch0: fix-sparse.patch BuildRequires: make BuildRequires: gcc @@ -27,6 +31,7 @@ contains the utilities for manipulating squashfs filesystems. %prep %setup -n %{name}-4.5 +%patch0 -p1 %build %set_build_flags @@ -54,6 +59,9 @@ ln -s unsquashfs %{buildroot}%{_sbindir}/sqfscat %{_sbindir}/sqfscat %changelog +* Mon Jul 26 2021 Bruno Wolff III - 4.5-2 +- Fix for sparse fragment bug 1985561 + * Fri Jul 23 2021 Bruno Wolff III - 4.5-1 - First crack at 4.5 release - Man pages still need significant work