495 Commits
Author SHA1 Message Date
François Degros 7704ecaffd Add repository archival and transition notice 2026-09-20 09:47:57 +10:00
François Degros 21bc15d5ac Start development version 1.25 2026-08-04 15:18:02 +10:00
François Degros 3e1298e581 Release version 1.24 v1.24 2026-08-04 15:17:24 +10:00
François Degros 5040faceec Adjust libarchive issue 2514 workaround version check
Update WORK_AROUND_ISSUE_2514 to apply only to versions before 3.8.8, as
the fix has been back-ported and is present in newer 3.8.x releases.
2026-08-04 15:00:44 +10:00
François Degros 893e724630 Isolate GPG integration testing environment
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.
2026-08-04 15:00:38 +10:00
François Degros 8b6426a00c Fix tests with gpg on some systems 2026-06-11 17:06:54 +10:00
François Degros ec8175a873 Add missing overload of Tree::HasSamePath 2026-06-01 09:48:04 +10:00
François Degros 9830698160 Fix hardlink resolution in multi-archive mode
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.
2026-05-31 18:11:11 +10:00
François Degros 6f086e6381 Filter PATH to keep only safe system directories
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.
2026-05-28 22:51:25 +10:00
François Degros ff1688a740 Index renamed nodes by original path to fix hardlink resolution
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.
2026-05-28 22:50:52 +10:00
François Degros 9f9577b290 Replace struct Tree with class Tree in Reader header 2026-05-26 17:45:11 +10:00
François Degros beff0d175c Start development version 1.23 2026-05-24 15:08:29 +10:00
François Degros e218685189 Release version 1.22 v1.22 2026-05-24 15:07:13 +10:00
François Degros b1434306af Rename '-o default_permissions' to '-o enforce_permissions'
- 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.
2026-05-24 15:03:06 +10:00
François Degros 4b13a49b4b Sanitize PATH for external decompression filters
- 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.
2026-05-24 15:02:34 +10:00
François Degros 63f331d775 Add -o noexternal option to disable external decompression filters
- 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.
2026-05-22 16:50:04 +10:00
François Degros f754728f12 Enhance GetTree resilience and clean up test.py
- 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.
2026-05-21 15:27:56 +10:00
François Degros c31d7c1b7a Improve sparse seek error verification in test.py
- 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).
2026-05-21 10:42:51 +10:00
Paal Øye-Strømme bdc90e8c2a Use /tmp for mount points on macOS to avoid Finder CPU spike
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.
2026-05-21 10:24:01 +10:00
Paal Øye-Strømme 3562ae7a04 Skip gpg dependent tests on macOS 2026-05-21 10:23:45 +10:00
Paal Øye-Strømme 40ae7b9975 Skip TestSeek on macOS (SEEK_DATA/SEEK_HOLE not supported)
- 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
2026-05-21 10:23:22 +10:00
François Degros 27a902747a Enhance sparse file verification in test.py
- 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.
2026-05-19 16:58:38 +10:00
François Degros d5912d7670 Refactor struct Node 2026-05-17 21:49:25 +10:00
François Degros cf02a8952a Rename test directory to tests 2026-05-12 16:32:41 +10:00
François Degros 4634b3c4bb Reformat test/test.py 2026-05-12 16:31:50 +10:00
François Degros 5b2140f31e Optimize some unit tests to increase code coverage 2026-05-12 14:19:30 +10:00
Paal Øye-Strømme 66f47fce68 Enable out-of-the-box build and install on macOS
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)
2026-05-12 12:00:10 +10:00
Paal Øye-Strømme f40dc83a3a Fix test.py for macOS
- 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
2026-05-12 11:45:46 +10:00
François Degros 5131ff55ae Migrate project to C++23
- Standardize on -std=c++23 across all targets.
- Verified compatibility with GCC 15.2.0.
2026-05-11 11:48:17 +10:00
François Degros 4a888792dc Make GoogleTest an optional build dependency
- 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.
2026-05-11 11:48:10 +10:00
François Degros f7394bc78c Fix FUSE 2 compatibility and ASAN leaks in help/version
- 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.
2026-05-11 11:46:14 +10:00
François Degros 9b3279506a Expand FUSE operation unit tests
- 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.
2026-05-07 15:46:20 +10:00
François Degros 9b656c4568 Refactor command-line option parsing for clarity and type safety
- 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.
2026-05-07 15:15:08 +10:00
François Degros 026f4c474a Enhance unit tests 2026-05-07 11:06:16 +10:00
François Degros 86f9fae7f8 Repair some of the inadvertent modifications
That happened when the code was modularized.
2026-05-04 18:03:55 +10:00
François Degros e086a3212e Add test for RPM format 2026-05-04 18:02:29 +10:00
François Degros 3718dc08ee Refactor sparse seek logic, expand unit tests, and standardize FUSE error handling
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.
2026-05-04 16:12:24 +10:00
François Degros e1db2ac54e Add format and check-format targets to Makefile
- 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
2026-05-04 10:57:31 +10:00
François Degros ab31b8823c Introduce Google Test framework and add unit tests
- 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.
2026-05-04 10:57:00 +10:00
François Degros 198ee83f12 Optimize terminal hole handling and refine sparse file navigation
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.
2026-05-03 21:24:28 +10:00
François Degros 9aa44a9c6d Modularize fuse-archive into a library and slim CLI wrapper
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.
2026-05-03 21:23:20 +10:00
François Degros 2307c9d57f Rename ScopedFile to FileDescriptor for technical accuracy 2026-04-30 23:08:48 +10:00
François Degros 11a02ba58e Add valgrind target and MOUNT_WRAPPER support
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.
2026-04-30 22:42:39 +10:00
François Degros f71f711c16 Add support for UBSAN=1 to the Makefile 2026-04-30 22:41:54 +10:00
François Degros 1564efe4e0 Tweak some comments 2026-04-30 10:41:13 +10:00
François Degros d0c2b14709 Update documentation to include high-precision timestamps feature 2026-04-29 23:22:52 +10:00
François Degros 11b79181b4 Implement RAII memory management and timespec precision
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.
2026-04-29 23:21:15 +10:00
François Degros 34b1964139 Standardize on Copy Model for hard link metadata
- Update ResolveHardlinks to explicitly clone all metadata from target
  to link node.
2026-04-29 21:31:26 +10:00
François Degros a268ab242d Introduce Stat and StatVfs aliases for better readability and consistency
- Add high-level type aliases for struct stat and struct statvfs.
- Replace all occurrences of struct stat/statvfs with Stat/StatVfs.
2026-04-29 21:25:46 +10:00
François Degros daf80a1d2d Optimize readdir with conditional FUSE_FILL_DIR_PLUS
- 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.
2026-04-29 21:24:21 +10:00