Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file_ext: make sure file is always initialized when running a multithreaded iterator. #300

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading