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.
This commit is contained in:
Levi Neely 2026-03-04 20:11:32 +01:00
parent a2886a907a
commit a47db80789
3 changed files with 19 additions and 7 deletions

View File

@ -5,8 +5,19 @@ AR := ar
DIST_CFLAGS := $(CFLAGS)
DIST_CXXFLAGS := $(CXXFLAGS)
# Detect FUSE version
FUSE_VERSION := $(shell ./detect_fuse.sh)
# Detect FUSE version (can be overridden with FORCE_FUSE=2 or FORCE_FUSE=3)
ifdef FORCE_FUSE
ifeq ($(FORCE_FUSE),2)
FUSE_VERSION := FUSE2
else ifeq ($(FORCE_FUSE),3)
FUSE_VERSION := FUSE3
else
$(error FORCE_FUSE must be 2 or 3)
endif
else
FUSE_VERSION := $(shell ./detect_fuse.sh)
endif
ifeq ($(FUSE_VERSION),FUSE3)
FUSE_CFLAGS := $(shell pkg-config --cflags fuse3)
FUSE_LIBS := -lfuse3

View File

@ -28,8 +28,6 @@
DAMAGE.
*/
#define FUSE_USE_VERSION 30
#include <errno.h>
#include <fuse.h>
#include <pthread.h>
@ -94,6 +92,9 @@ typedef off_t fuse_off_t;
static int shutdown_in_progress = 0;
static struct fuse *psync_fuse = NULL;
#if FUSE_USE_VERSION < 30
static struct fuse_chan *psync_fuse_channel = NULL;
#endif
static char *psync_current_mountpoint = NULL;
static psync_generic_callback_t psync_start_callback = NULL;
char *pfs_fake_prefix = NULL;
@ -3600,7 +3601,8 @@ static void pfs_do_stop(void) {
struct fuse_session *se = fuse_get_session(psync_fuse);
fuse_session_unmount(se);
#else
fuse_unmount(mp, fuse_get_session(psync_fuse));
fuse_unmount(mp, psync_fuse_channel);
psync_fuse_channel = NULL;
#endif
clock_gettime(CLOCK_REALTIME, &ts);
@ -3862,6 +3864,7 @@ static int pfs_do_start() {
fuse_unmount(mp, ch);
goto err0;
}
psync_fuse_channel = ch;
#endif
psync_current_mountpoint = mp;

View File

@ -29,8 +29,6 @@
DAMAGE.
*/
#define FUSE_USE_VERSION 30
#include <errno.h>
#include <fuse.h>
#include <string.h>