pcloudcc-lneely/pclsync
Levi Neely 0c0c6855c1
Migrate to FUSE 3.x API (#350)
* Migrate to FUSE 3.x API

- Update FUSE_USE_VERSION from 26 to 30
- Replace fuse_mount/fuse_unmount with fuse_session_mount/fuse_session_unmount
- Update fuse_new() to take args first, remove channel parameter
- Add flags parameter to readdir handler (enum fuse_readdir_flags)
- Add flags parameter to rename handler (for renameat2 support)
- Update filler function calls to include FUSE_FILL_DIR_PLUS flag
- Merge ftruncate into truncate handler (FUSE 3 combines them)
- Update fuse_loop_mt to fuse_loop_mt_31 with loop config
- Link against libfuse3 instead of libfuse
- Remove fuse_chan usage (deprecated in FUSE 3)

Addresses #342

* Remove deprecated FUSE options nonempty and hard_remove

- nonempty: Removed in FUSE 3.0, mounting on non-empty directories is now default behavior
- hard_remove: High-level API option not available in FUSE 3, immediate unlink is standard

These options are no longer recognized by FUSE 3 and cause mount errors.

* Fix init handler signature for FUSE 3

FUSE 3 init handler requires struct fuse_config* parameter.
This parameter provides access to high-level API configuration
options that can be modified during initialization.

Without this parameter, the init handler signature is incompatible
with FUSE 3, causing filesystem operations to fail.

* Add FUSE 2/3 backward compatibility

Automatically detects and builds against either FUSE 2 or FUSE 3:
- detect_fuse.sh script checks for fuse3 or fuse pkg-config
- Makefile dynamically sets FUSE_USE_VERSION, CFLAGS, and LDFLAGS
- Conditional compilation (#if FUSE_USE_VERSION >= 30) for API differences:
  * init handler signature (fuse_config parameter)
  * readdir handler signature (flags parameter)
  * rename handler signature (flags parameter)
  * truncate handler signature (fuse_file_info parameter)
  * filler function calls (flags parameter)
  * fuse_loop_mt vs fuse_loop_mt_31
  * mount/unmount sequence (fuse_session_mount vs fuse_mount)
  * ftruncate operations struct member

Maintains full compatibility with both FUSE 2.x (Debian Bookworm) and
FUSE 3.x (Debian Testing+) without requiring separate code branches.

* Add FORCE_FUSE build option and fix hardcoded version

- Remove hardcoded FUSE_USE_VERSION defines from source files
- Add FORCE_FUSE=2 or FORCE_FUSE=3 Makefile option to override detection
- Fix FUSE 2 channel tracking (psync_fuse_channel variable)
- Properly store and use channel in mount/unmount for FUSE 2

Usage:
  make                  # Auto-detect (prefers FUSE 3)
  make FORCE_FUSE=2     # Force FUSE 2 build
  make FORCE_FUSE=3     # Force FUSE 3 build

Verified both FUSE 2 and FUSE 3 builds work correctly.

* Fix CI/CD: Add fallback for systems without pkg-config

- detect_fuse.sh now checks for pkg-config availability first
- Falls back to checking for header files in standard locations
- Makefile provides default CFLAGS when pkg-config unavailable
- Fixes build on minimal CI/CD environments

Fallback locations checked:
- /usr/include/fuse3/fuse.h (FUSE 3)
- /usr/local/include/fuse3/fuse.h (FUSE 3)
- /usr/include/fuse/fuse.h (FUSE 2)
- /usr/local/include/fuse/fuse.h (FUSE 2)

* Enhance FUSE detection for non-standard locations

Multi-stage detection strategy:
1. Try pkg-config (fastest, most reliable)
2. Search common header locations:
   - /usr/include, /usr/local/include
   - /opt/local/include, /opt/include
3. Compiler test as last resort:
   - Attempts to preprocess #include <fuse.h>
   - Tests both FUSE 3 and FUSE 2 versions

This handles:
- Minimal CI/CD environments (no pkg-config)
- Non-standard install locations (Homebrew, custom builds)
- Distro-specific paths (BSD, macOS, custom Linux)

The compiler test ensures detection works even when headers
are in unusual locations that gcc can find via its search paths.

* Support FUSE 3.12+ API

- Use fuse_loop_mt_312 for FUSE 3.12+, fuse_loop_mt_31 for 3.0-3.11
- Conditionally add fuse_file_info param to getattr/chmod/chown/utimens
- Replace fuse_session_mount/unmount with fuse_mount/unmount
- Tested with FUSE 3.18 on Debian forky

* Fix pcl-1ib: correct FUSE 3.x handler signatures and loop_mt call

- Replace FUSE_MINOR_VERSION >= 12 checks with FUSE_USE_VERSION >= 30
  for getattr/chmod/chown/utimens handler signatures; FUSE 3.x always
  requires the extra struct fuse_file_info* parameter — the wrong
  signature caused type mismatches and "Transport endpoint is not
  connected" failures
- Replace non-existent fuse_loop_mt_312 extern with correct conditional:
  FUSE_USE_VERSION >= 32 uses fuse_loop_mt(f, &config), else
  fuse_loop_mt_31(f, clone_fd)
- Fix inverted return logic in is_fuse3_installed_on_system(): was
  returning 0 on success (when fusermount3 found), now correctly
  returns non-zero

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove unused is_fuse3_installed_on_system() from pfs.c

The function was static and had no remaining call sites after the
-ononempty/-ohard_remove args block was cleaned up, producing a
-Wunused-function warning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Restore shutdown_requested definition removed during rebase conflict resolution

The variable is declared extern in pfs.h and referenced in both
pfs.c (psync_signal_handler) and control_tools.cpp; the definition
must exist in pfs.c.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix pfs_creat: missing canmodify assignment causes EACCES on write

pfs_creat called pfs_create_file() but never set of->canmodify, leaving
it zero-initialized. pfs_write and pfs_ftruncate both check canmodify
and return -EACCES if false, making all writes to newly created files
fail with Permission denied.

All five open paths in pfs_open set canmodify correctly (added in #326),
but pfs_creat was missed. Fix by applying the same pattern immediately
after psql_unlock(), while fpath is still in scope.

Caught during FUSE 2/3 regression testing (Phase 2 write test).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Extend CI matrix: add FUSE 2, FUSE 3 legacy/current/forky build jobs

Replaces single build job with four jobs covering all tested FUSE configs:
- fuse2: debian:trixie + libfuse-dev (FUSE_USE_VERSION=26)
- fuse3-legacy: ubuntu:20.04 + libfuse3-dev 3.9.x (fuse_loop_mt_31 path)
- fuse3-current: ubuntu:22.04 + libfuse3-dev 3.12.x
- fuse3-forky: debian:forky + libfuse3-dev 3.18.1

Each job verifies correct symbol linkage after build. Runtime mount tests
are outside CI scope (require privileged containers with /dev/fuse).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* CI: replace Ubuntu 20.04/22.04 with ubuntu:24.04 for FUSE3 job

ubuntu:20.04 has old compiler (g++-9) and mbedTLS 2.x.
ubuntu:22.04 ships mbedTLS 2.28.x; incompatible with our mbedTLS 3.x-only code.
ubuntu:24.04 has mbedTLS 3.x and libfuse3 3.16.x, covering the 3.12-3.17 range.
FUSE3 < 3.12 is verified locally but not representable in CI without fighting
old toolchains.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* CI: add archlinux:latest job for rolling-release compatibility

Arch Linux is a rolling distro shipping latest fuse3, mbedtls 3.x, and
gcc — useful as an early-warning canary for future API breakage. Also
directly covers the maintained Arch package.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* CI: add fedora:41 and fedora:latest jobs with mbedtls3-devel

Fedora ships both mbedtls 2.x and 3.x; explicitly install mbedtls3-devel
to match our mbedTLS 3.x-only requirement. fedora:41 pins a known-good
release; fedora:latest tracks current as a rolling canary alongside Arch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* README: add compatibility matrix with CI badge references

Documents the 6-distro build matrix tested in CI, mbedTLS 3.x requirement,
and notes on manual runtime mount testing coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix CI package names; clean up README compatibility matrix

- Fedora 41: mbedtls3-devel -> mbedtls3.6-devel (correct versioned name)
- Fedora latest (43): mbedtls3-devel -> mbedtls-devel (now ships 3.6.5)
- Ubuntu 24.04: replaced with debian:trixie FORCE_FUSE=3 (Ubuntu has no
  mbedTLS 3.x in standard repos; trixie has both libfuse3-dev and mbedTLS 3.x)
- README: remove CI badge links from compatibility matrix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-09 21:51:00 +01:00
..
debug Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
LICENSE reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
paccountevents.h reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
papi.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
papi.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pbusinessaccount.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pbusinessaccount.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcache.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcache.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcommands.h Fix #90, #109: Support 2FA when running as a daemon (#175) 2026-03-02 21:36:33 +01:00
pcompiler.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
pcontacts.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcontacts.h reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
pcrc32c.c 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
pcrc32c.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcrypto.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcrypto.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcryptofolder.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcryptofolder.h access pcryptofolder directly from pclsync_lib (#125) 2025-03-09 19:58:00 +01:00
pdatabase.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pdbg.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdbg.h Fix pcl-0c1: make pdbg_runtime_level atomic (#343) 2026-03-03 20:08:18 +01:00
pdeflate.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdeflate.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pdevice.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdevice.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pdevmon.c fix compile errors (#155) 2025-05-15 19:14:57 +02:00
pdevmon.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pdiff.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdiff.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pdownload.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdownload.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
pfile.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfile.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pfileops.c 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
pfileops.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pfolder.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfoldersync.h move folder-related code from psynclib to pfolder 2025-04-18 15:23:50 +02:00
pfs.c Migrate to FUSE 3.x API (#350) 2026-03-09 21:51:00 +01:00
pfs.h Add lock ordering assertions in debug builds (#370) 2026-03-08 15:38:41 +01:00
pfs_internal.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pfscrypto.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfscrypto.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsfolder.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfsfolder.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsstatic.c Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsstatic.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfstasks.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfstasks.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pfstasks_internal.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pfsupload.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfsupload.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsxattr.c Migrate to FUSE 3.x API (#350) 2026-03-09 21:51:00 +01:00
pfsxattr.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pintervaltree.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pintervaltree.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
plibs.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plibs.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
plist.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plist.h Fix typo: rename psync_list_bulder_* to psync_list_builder_* (#302) 2026-03-03 12:23:16 +01:00
plocalnotify.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plocalnotify.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
plocalscan.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plocalscan.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
plocks.c Add deadlock detection with timeouts (#364) 2026-03-08 11:55:25 +01:00
plocks.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pmem.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pmem.h Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pnetlibs.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pnetlibs.h 98 create a pdbg namespace (#139) 2025-03-13 20:28:09 +01:00
pnotify.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pnotify.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pp2p.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pp2p.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ppagecache.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppagecache.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ppassword.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppassword.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ppassworddict.h reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
ppath.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppath.h Musl fixes (#143) 2025-04-13 09:11:11 +02:00
ppathstatus.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppathstatus.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pqevent.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pqevent.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
prand.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prand.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
prpc.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prpc.h 130 use trustworthy location for log and socket (#134) 2025-03-11 19:03:58 +01:00
prun.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prun.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
prunthrottled.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prunthrottled.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pscanexts.h Appease the LSP server (#73) 2024-11-26 19:36:49 +01:00
psettings.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psettings.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pshm.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pshm.h #64 simplify messaging and #71 deserialize failed (#88) 2025-02-25 09:46:46 +01:00
psignal.c Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
psignal.h Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
psock.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psock.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
psql.c Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
psql.h Fix pcl-10w: remove IS_DEBUG conditional from psql.h (#363) 2026-03-07 21:37:21 +01:00
psql_internal.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pssl.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pssl.h 98 create a pdbg namespace (#139) 2025-03-13 20:28:09 +01:00
psslcerts.h Add new pCloud SSL certificate fingerprint (#172) 2026-03-01 09:14:29 +01:00
pstatus.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pstatus.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
psuggest.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psuggest.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
psyncer.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psynclib.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psynclib.h Fix pcl-r0j: rename psync_delete_sync_by_folderid to pfolder_delete_sync_by_id (#361) 2026-03-07 19:54:21 +01:00
psys.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psys.h Fix pcl-ivv: remove weak attribute from debug hooks (#362) 2026-03-07 20:18:51 +01:00
ptask.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptask.h 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
ptevent.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptevent.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ptimer.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptimer.h 98 create a pdbg namespace (#139) 2025-03-13 20:28:09 +01:00
ptools.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptools.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ptree.c 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
ptree.h Fix ptree_for_each_element loop termination condition (#319) 2026-03-03 15:29:44 +01:00
ptypes.h Appease the LSP server (#73) 2024-11-26 19:36:49 +01:00
publiclinks.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
publiclinks.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pupload.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pupload.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
putil.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
putil.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
sockets.h Merge pclsync and poverlay_linux (#46) 2024-08-18 15:09:21 +02:00