From 757f89f7861ca97679ca07f332cabbae3f7f77ee Mon Sep 17 00:00:00 2001 From: Adam Duke Date: Wed, 30 Jul 2025 15:55:28 -0400 Subject: [PATCH 1/4] allow passing libfuse.dylib path via env variable We're using the commercial license, and need to be able to specify the path to the libfuse dylib within the application bundle to support end users who do not have a fuse implementation installed or do not have admin rights to install a fuse implementation. --- fuse/host_cgo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fuse/host_cgo.go b/fuse/host_cgo.go index 7a3c65a..5ff5c35 100644 --- a/fuse/host_cgo.go +++ b/fuse/host_cgo.go @@ -176,6 +176,13 @@ static void *cgofuse_init_fuse(void) h = dlopen("/usr/local/lib/libosxfuse.2.dylib", RTLD_NOW); // MacFUSE/OSXFuse < v4 if (0 == h) h = dlopen("/usr/local/lib/libfuse-t.dylib", RTLD_NOW); // FUSE-T + if (0 == h) + { + // runtime path for bundled dylib in e.g. Awesome.app/Contents/Frameworks/libfuse.dylib + const char *dylib_path = getenv("CGOFUSE_LIBFUSE_PATH"); + if(dylib_path) + h = dlopen(dylib_path, RTLD_NOW); + } #elif defined(__FreeBSD__) #if FUSE_USE_VERSION < 30 h = dlopen("libfuse.so.2", RTLD_NOW); From e6448c5267ff7c81134a815e568cda92c5a3456a Mon Sep 17 00:00:00 2001 From: Adam Duke Date: Thu, 31 Jul 2025 18:11:49 -0400 Subject: [PATCH 2/4] re-order dlopen calls to prefer env variable --- fuse/host_cgo.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fuse/host_cgo.go b/fuse/host_cgo.go index 5ff5c35..4887cf8 100644 --- a/fuse/host_cgo.go +++ b/fuse/host_cgo.go @@ -171,18 +171,16 @@ static void *cgofuse_init_fuse(void) void *h; #if defined(__APPLE__) - h = dlopen("/usr/local/lib/libfuse.2.dylib", RTLD_NOW); // MacFUSE/OSXFuse >= v4 + // runtime path for bundled dylib in e.g. Awesome.app/Contents/Frameworks/libfuse.dylib + const char *dylib_path = getenv("CGOFUSE_LIBFUSE_PATH"); + if(dylib_path) + h = dlopen(dylib_path, RTLD_NOW); + if (0 == h) + h = dlopen("/usr/local/lib/libfuse.2.dylib", RTLD_NOW); // MacFUSE/OSXFuse >= v4 if (0 == h) h = dlopen("/usr/local/lib/libosxfuse.2.dylib", RTLD_NOW); // MacFUSE/OSXFuse < v4 if (0 == h) h = dlopen("/usr/local/lib/libfuse-t.dylib", RTLD_NOW); // FUSE-T - if (0 == h) - { - // runtime path for bundled dylib in e.g. Awesome.app/Contents/Frameworks/libfuse.dylib - const char *dylib_path = getenv("CGOFUSE_LIBFUSE_PATH"); - if(dylib_path) - h = dlopen(dylib_path, RTLD_NOW); - } #elif defined(__FreeBSD__) #if FUSE_USE_VERSION < 30 h = dlopen("libfuse.so.2", RTLD_NOW); From 2cbe1e9ea2555e4054f90199abc0325ae67d0c9c Mon Sep 17 00:00:00 2001 From: Adam Duke Date: Mon, 4 Aug 2025 12:49:23 -0400 Subject: [PATCH 3/4] explicitly initialize handle to NULL before dlopen --- fuse/host_cgo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuse/host_cgo.go b/fuse/host_cgo.go index 4887cf8..7d4d8c4 100644 --- a/fuse/host_cgo.go +++ b/fuse/host_cgo.go @@ -169,7 +169,7 @@ static void *cgofuse_init_fuse(void) if (0 == (*(void **)&(pfn_ ## n) = dlsym(h, #n)))\ return 0; - void *h; + void *h = NULL; #if defined(__APPLE__) // runtime path for bundled dylib in e.g. Awesome.app/Contents/Frameworks/libfuse.dylib const char *dylib_path = getenv("CGOFUSE_LIBFUSE_PATH"); From 678f4ac1d853e19f44072e6327713debb4eff1e0 Mon Sep 17 00:00:00 2001 From: Adam Duke Date: Tue, 12 Aug 2025 19:55:11 -0400 Subject: [PATCH 4/4] address style consistency issues --- fuse/host_cgo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fuse/host_cgo.go b/fuse/host_cgo.go index 7d4d8c4..d2001ff 100644 --- a/fuse/host_cgo.go +++ b/fuse/host_cgo.go @@ -169,11 +169,11 @@ static void *cgofuse_init_fuse(void) if (0 == (*(void **)&(pfn_ ## n) = dlsym(h, #n)))\ return 0; - void *h = NULL; + void *h = 0; #if defined(__APPLE__) // runtime path for bundled dylib in e.g. Awesome.app/Contents/Frameworks/libfuse.dylib const char *dylib_path = getenv("CGOFUSE_LIBFUSE_PATH"); - if(dylib_path) + if(0 != dylib_path) h = dlopen(dylib_path, RTLD_NOW); if (0 == h) h = dlopen("/usr/local/lib/libfuse.2.dylib", RTLD_NOW); // MacFUSE/OSXFuse >= v4