Use a temporary directory under GNUPGHOME to prevent contaminating or
relying on the host's global keyring during integration testing. Ensure
the background gpg-agent is terminated and the directory is cleaned up
afterwards.
Isolate original path tracking to the archive currently being loaded.
This prevents hardlinks in one archive from accidentally resolving to
nodes in another archive when their original paths collide before
renaming.
Also optimize memory by explicitly swapping out temporary tracking
structures after the loading phase is complete.
Instead of overwriting PATH with a hardcoded list, iterate through the
existing PATH and keep only recognized safe system locations. This
provides more flexibility while maintaining security for external
filters.
Also add -o unsafe_path to allow non-standard filter locations.
When name collisions occur within an archive, fuse-archive renames the
offending nodes to ensure VFS integrity. However, this previously broke
hardlink resolution for any link pointing to a renamed target, as the
target's path in the Tree index no longer matched the path stored in the
hardlink metadata.
This change introduces an auxiliary index, `nodes_by_original_path_`,
which tracks nodes that have undergone renaming.
Key changes:
- Add `renamed` flag to `Node` struct.
- Implement `FindNodeByOriginalPath` which performs a transparent lookup
in the original path index.
- Update `ResolveHardlinks` to use the original path for target lookups.
- Implement recursive path verification in `OriginalName::HasPath` to
ensure correct parent hierarchy matching.
- Clear the auxiliary index after hardlink resolution to minimize memory
footprint during the FUSE session.
This ensures that hardlinks are correctly resolved even in complex
archives with numerous name collisions.
- Improve clarity of the option name: 'default_permissions' is a
misnomer as it must be explicitly requested and actually signals that
the kernel should enforce standard UNIX permissions.
- Maintain 'default_permissions' as a hidden alias for backward
compatibility.
- Update documentation and integration tests.
- Align internal variable names for consistency.
- Prevent local code execution via PATH poisoning by hardcoding a safe
system PATH (/usr/bin:/bin:/usr/local/bin) when external filters are
enabled.
- Include Homebrew and MacPorts paths in sanitized PATH on macOS.
- External filters remain enabled by default for parity with standard
tools like bsdcat, but are now isolated from the ambient environment.
- Add integration test to verify that parasitic programs in the caller's
PATH are ignored.
- Update documentation to accurately reflect PATH sanitization.
- Introduce the 'noexternal' mount option which clears the PATH
environment variable. This prevents libarchive from finding and
executing external programs (like gzip, xz, etc.) for decompression.
- Update PrintUsage() and README.md to document the new option.
- Add integration test case in tests/test.py to verify environmental
isolation.
- Add error handling to GetTree when scanning directories. This allows
capturing and verifying OSErrors (stored as 'errno' in the tree)
instead of crashing the test runner.
- Align GetTree logic with mount-zip for better project consistency.
- Reformat long lines and remove redundant whitespace for PEP 8
compliance.
- Improve logging messages in TestBigArchiveStreamed.
- Test both SEEK_DATA and SEEK_HOLE for out-of-bounds errors.
- Use actual file size (st.st_size) instead of a hardcoded offset.
- Fix platform-specific errno verification to correctly use want_errno
(EINVAL on macOS, ENXIO on Linux).
On macOS, the default TMPDIR resolves to /var/folders/... which is
monitored by Finder and FSEvents. Creating FUSE mount points there
causes Finder to poll and index them aggressively, leading to high
CPU usage during tests.
- Introduce tmp_dir_base = '/tmp' on macOS, None elsewhere.
- Pass dir=tmp_dir_base to all TemporaryDirectory() calls that create
mount points, so macFUSE always mounts under /tmp on macOS.
- macFUSE does not forward SEEK_DATA/SEEK_HOLE through the kernel lseek
interface, causing EINVAL
- Skip TestSeek entirely on darwin for now
Ref: https://github.com/macfuse/macfuse/issues/1121
- Add GetHoleMap to verify the actual sparse structure using lseek().
- Implement a has_holes guard based on FUSE version and OS platform.
- Add TestSparse() to verify sparseness preservation for precache/memcache
and proper fallback for lazycache/nocache.
- Move path definitions to the top of the script for better maintainability.
Makefile:
- wire Homebrew keg-only libarchive into PKG_CONFIG_PATH automatically
- add Homebrew boost include path (required by lib/util.h)
- disable macFUSE Darwin-extended operation signatures
(-DFUSE_DARWIN_ENABLE_EXTENSIONS=0) so fuse-archive's standard POSIX
signatures match the fuse_operations struct members
- default to -std=gnu++23 on macOS to accommodate __typeof__ in macFUSE
headers (as recommended by PR #52)
- default PREFIX to /usr/local on macOS (/usr is SIP-protected)
- replace GNU-only install -D with portable mkdir -p + install
lib/util.cc:
- skip shm_open on macOS for the memcache path; shm_open objects
require ftruncate before any write and cannot auto-extend, making
them unsuitable as a growable cache file — fall through to the
mkstemp path which produces a regular unlinked file that does
auto-extend (mirrors how mount-zip handles the same constraint)
- use bzip2 --help instead of --version since --version reads stdin
- BSD compress (macOS) is always present but does not support -V,
--help, or -h; assume available on darwin rather than probing
- add Unmount() helper: macOS uses umount -f (force, closest equivalent
to lazy detach), Linux keeps umount -l (lazy)
- guard os.listxattr/os.getxattr behind a check; these are Linux-only —
macOS exposes xattrs via a different API
- skip TestSeek on macOS (SEEK_DATA/SEEK_HOLE not supported)
- normalise tree keys to NFC on macOS; the VFS returns NFD-normalised
filenames via os.scandir, mismatching NFC names stored in archives
- skip xattr key comparison in CheckTree on macOS (os.listxattr absent)
- guard all direct os.getxattr/os.listxattr calls in TestFuseErrors
behind checks
- skip rdev comparison on macOS; macFUSE re-encodes device numbers using
BSD packing so raw st_rdev values differ from Linux
- replace all literal errno values (2, 5, 6, 20, 21, 22, 61) with
symbolic names (ENOENT, EIO, ENXIO, ENOTDIR, EISDIR, EINVAL, ENODATA)
- avoids relying on Linux-specific errno values which differ on macOS
(e.g. ENODATA is 61 on Linux, 96 on macOS)
Ref: https://github.com/macfuse/macfuse/issues/1121
- Update Makefile to detect gtest using pkg-config.
- Suppress pkg-config error messages when gtest is missing.
- Conditionally build and run unit tests only if gtest is found.
- Update INSTALL.md to list gtest as a dependency for unit tests.
- Fix readdir filler lambda signature for FUSE 2 in unit tests.
- Change '-ho' to '-h' for FUSE 2 help output.
- Use _exit(EXIT_SUCCESS) in help/version paths for FUSE 2 to bypass
known libfuse2 leaks caught by ASAN.
- Add GetAttrByFi test to verify attribute retrieval via fuse_file_info.
- Add OpenDir tests to verify error handling for non-existent paths and
non-directory nodes.
Expand GetXattr unit tests
- Add a test case for requesting an attribute that exists on a different node.
- Define ENOATTR for better compatibility on Linux.
- Use ENOATTR instead of ENODATA in expectations to match fuse_ops.cc.
- Direct-map FUSE options to Context fields using offsetof.
- Use explicit int casts for scoped enums in the fuse_opt table.
- Add static assertions to ensure enum/int size compatibility.
- Add '-o precache' option for explicit default cache selection.
- Simplify ProcessArg by removing manual enum mapping logic.
This commit consolidates several improvements to library robustness and
FUSE compliance:
- Core Logic: Centralized SEEK_DATA/SEEK_HOLE navigation in
Node::SparseSeek and verified with exhaustive boundary tests.
- Testing: Expanded test/unit_tests.cc to cover Path normalization
(including UTF-8/ZWJ safety), Tree trimming, and Reader recycling
logic.
- FUSE Integration: Standardized callback return codes (EINVAL for
readlink on non-symlinks, ENOATTR for missing attributes) and improved
exception handling to distinguish OOM (ENOMEM) from internal errors.
- Diagnostics: Configured coverage reports to include DEBUG-only paths
and verified all enum-to-string mappings.
- Automation: Added FUSE-level negative tests to verify error
propagation across the filesystem boundary.
- Define 'format' target to apply clang-format to all C++ files.
- Define 'check-format' target to verify formatting without modifying files.
- Use '.clang-format' configuration file for style rules.
- Update DEVELOPMENT.md with formatting targets
- Update INSTALL.md with clang-format prerequisite
- Add Google Test (gtest) and gtest_main as dependencies in the
Makefile.
- Define a new 'unit_test' target that builds and runs a C++ unit test
program.
- Integrate 'unit_test' into 'make check' and 'make check-fast' to
ensure unit tests run before Python integration tests.
- Add an initial 'test/unit_test.cc' with a dummy test case to verify
the framework setup.
- Update DEVELOPMENT.md to distinguish between Unit Tests (C++) and
Integration Tests (Python).
- Update INSTALL.md to list GoogleTest as a build prerequisite and
include the libgtest-dev package for Debian systems.
- Implement comprehensive unit tests for 'Path' (normalization,
splitting, extensions), 'HashedString' (deduplication, hashing), and
'Util' (safe arithmetic, string manipulation, hole accounting).
- Correct 'Path' test expectations to align with the library's security-
conscious normalization logic (e.g., converting '..' components to
'?').
- Add 'friend' declarations to 'FileDescriptor' and 'Tree' classes to
enable targeted unit testing of internal logic.
- Implement 'FileDescriptorTest' to verify sparse file write logic
(WriteBytesAndSkipHoles) and basic I/O operations.
- Implement 'TreeTest' using a test fixture with protected wrapper
methods to verify private directory management (GetOrCreateDirNode)
and collision resolution (RenameIfCollision).
- Implement 'NodeTest' to verify 'GetBlockCount' logic, covering empty,
dense, sparse, and terminal hole cases.
- Implement 'TreeTest::Trim' to verify the collapsing of redundant
single-child directory hierarchies.
- Refined test setup to correctly establish parent-child relationships
and path metadata when manually constructing the virtual tree.
- Implement 'TreeTest::ResolveHardlinks' to verify the two-phase hardlink
resolution logic, ensuring correct inode sharing and nlink counts.
- Implement 'TreeTest::ReaderRecycling' to verify that Reader objects are
properly returned to the pool and reused.
- Implement 'TreeTest::ReaderBestMatch' to verify the optimization logic in
'GetReader' that selects the best available reader based on its current
position and buffer coverage.
- Add 'friend' declaration to 'Reader' to enable detailed state verification.
Transition to a dynamic terminal hole model where sparse regions at the
end of a file are tracked via Node::last_hole_start instead of being
stored in the interior holes vector. This optimization applies to
terminal holes of any size and streamlines filesystem statistics and
navigation.
Key changes:
- Implement Node::IsFullyCached() and Node::GetSizeToLastHole() for
dynamic sparse region detection.
- Refine GetBlockCount to correctly exclude the terminal hole from tree-
wide statistics.
- Update lib/fuse_ops.cc:Seek to correctly navigate both interior and
terminal holes for SEEK_DATA and SEEK_HOLE.
- Atomize cache state updates within Reader::CacheEntryData and improve
error recovery for partial cache states.
- Simplify Hole::GetSavedBlocks to calculate savings solely from hole
boundaries.
- Add diagnostic logging to Seek tests in test/test.py.
This comprehensive refactoring transforms the monolithic fuse-archive
into a modular, memory-safe library (libfuse-archive.a) and a
lightweight CLI wrapper.
Key Improvements:
- **State Encapsulation**: All virtual filesystem state (options, nodes,
readers, cache, and passwords) is now managed within a self-contained
'Tree' class.
- **Memory Safety**: Redesigned command-line option parsing to prevent
heap corruption during 'fuse_opt_parse' and verified clean execution
with ASAN and UBSAN.
- **Automated Resource Management**: Leveraged intrusive containers and
RAII-compliant nested destructors to automate the lifecycles of Nodes
and Readers.
- **Component Isolation**: Extracted FUSE operations, archive reading,
and utility functions into dedicated modules (tree, reader, node,
fuse_ops, util, etc.).
- **Refined API**: Simplified the library interface; 'Tree::Load' now
accepts simple paths, internalizing the complexity of descriptor
management and archive configuration.
- **Technical Integrity**: Maintained 100% functional parity with the
original implementation, as verified by the full test suite.
Added a 'valgrind' target to the Makefile and support for a
'MOUNT_WRAPPER' environment variable in test.py. This allows wrapping
the fuse-archive process with Valgrind during integration tests to check
for memory leaks.
This commit aligns fuse-archive with mount-zip's optimized architectural
model:
- Establishes parent-child relationships and path hashes before tree
attachment.
- Standardizes on RAII memory management using Node::Ptr (unique_ptr).
- Transitioned from time_t to timespec for full nanosecond precision.
- Reordered Node members for optimal alignment (16/8/pointer/4
grouping).
- Modernized logging with a throttled Beat class and ephemeral progress
updates.
- Adjusted test suite to handle nanosecond precision gracefully. Updated
CheckTree to allow second-precision matching when the expected
timestamp has zero nanoseconds. This ensures that tests remain robust
across different archive formats and library versions that may or may
not provide nanosecond resolution, while still allowing for exact
matching if non-zero nanoseconds are specified in the test
expectations.
- Honor FUSE_READDIR_PLUS flag in ReadDir: only provide stat info if
requested.
- Fix bug where uninitialized stat buffer was passed to the filler in
non-plus mode.
- Correctly handle '.' and '..' entries with conditional metadata
preparation.