Skip to content

Commit

Permalink
Merge pull request #300 from Gottox/fix/unpack-empty-files
Browse files Browse the repository at this point in the history
file_ext: make sure file is always initialized when running a multithreaded iterator.
  • Loading branch information
Gottox committed Dec 8, 2024
1 parent 48755d5 commit a78e3e6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libsqsh/src/posix/file_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ file_iterator_mt(
atomic_init(&mt->remaining_blocks, (size_t)block_count);
atomic_init(&mt->rv, 0);

if (block_count == 0) {
rv = sqsh__file_init(&mt->file, file->archive, inode_ref);
if (rv < 0) {
goto out;
}

rv = sqsh__file_init(&mt->file, file->archive, inode_ref);
if (rv < 0) {
if (block_count == 0) {
goto out;
}

Expand Down
1 change: 1 addition & 0 deletions test/tools/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sqsh_extended_test = [
'cat/large-file-uncompressed.sh',
'read-chunk/tail.sh',
'unpack/repack.sh',
'unpack/empty_file.sh',
'unpack/pathtraversal/pathtraversal.sh',
'ls/large-tree.sh',
'ls/large-tree-lookup.sh',
Expand Down
30 changes: 30 additions & 0 deletions test/tools/unpack/empty_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh -ex

######################################################################
# @author Enno Boland ([email protected])
# @file repack.sh
# @created Friday Mar 17, 2023 15:11:09 CET
#
# @description This script creates a squashfs image, mounts it, and
# repacks it from the mounted path.
######################################################################

: "${BUILD_DIR:?BUILD_DIR is not set}"
: "${MKSQUASHFS:?MKSQUASHFS is not set}"
: "${SQSH_UNPACK:?SQSH_UNPACK is not set}"

MKSQUASHFS_OPTS="-no-xattrs -noappend -all-root -mkfs-time 0"

WORK_DIR="$BUILD_DIR/unpack-empty_file"

mkdir -p "$WORK_DIR"
cd "$WORK_DIR"

mkdir -p root unpack

touch root/empty_file

# shellcheck disable=SC2086
$MKSQUASHFS "root" "empty_file.squashfs" $MKSQUASHFS_OPTS

$SQSH_UNPACK -Ve "$PWD/empty_file.squashfs" / "$PWD/unpack"

0 comments on commit a78e3e6

Please sign in to comment.