vendor: update github.com/billziss-gh/cgofuse - fixes #1481

This commit is contained in:
Nick Craig-Wood
2017-06-19 09:53:34 +01:00
parent 5ed4bc97f3
commit 4ce31555b2
6 changed files with 188 additions and 27 deletions
+30 -10
View File
@@ -15,9 +15,13 @@ package fuse
/*
#cgo darwin CFLAGS: -DFUSE_USE_VERSION=28 -D_FILE_OFFSET_BITS=64 -I/usr/local/include/osxfuse/fuse
#cgo darwin LDFLAGS: -L/usr/local/lib -losxfuse
#cgo linux CFLAGS: -DFUSE_USE_VERSION=28 -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse
#cgo linux LDFLAGS: -lfuse
#cgo windows CFLAGS: -D_WIN32_WINNT=0x0600 -DFUSE_USE_VERSION=28
// Use `set CPATH=C:\Program Files (x86)\WinFsp\inc\fuse` on Windows.
// The flag `I/usr/local/include/winfsp` only works on xgo and docker.
#cgo windows CFLAGS: -D_WIN32_WINNT=0x0501 -DFUSE_USE_VERSION=28 -I/usr/local/include/winfsp
#if !(defined(__APPLE__) || defined(__linux__) || defined(_WIN32))
#error platform not supported
@@ -42,7 +46,7 @@ static PVOID cgofuse_init_slow(int hardfail);
static VOID cgofuse_init_fail(VOID);
static PVOID cgofuse_init_winfsp(VOID);
static SRWLOCK cgofuse_lock = SRWLOCK_INIT;
static CRITICAL_SECTION cgofuse_lock;
static PVOID cgofuse_module = 0;
static inline PVOID cgofuse_init_fast(int hardfail)
@@ -57,7 +61,7 @@ static inline PVOID cgofuse_init_fast(int hardfail)
static PVOID cgofuse_init_slow(int hardfail)
{
PVOID Module;
AcquireSRWLockExclusive(&cgofuse_lock);
EnterCriticalSection(&cgofuse_lock);
Module = cgofuse_module;
if (0 == Module)
{
@@ -65,7 +69,7 @@ static PVOID cgofuse_init_slow(int hardfail)
MemoryBarrier();
cgofuse_module = Module;
}
ReleaseSRWLockExclusive(&cgofuse_lock);
LeaveCriticalSection(&cgofuse_lock);
if (0 == Module && hardfail)
cgofuse_init_fail();
return Module;
@@ -351,7 +355,22 @@ static int _hostGetxattr(char *path, char *name, char *value, size_t size,
#define _hostGetxattr hostGetxattr
#endif
static int hostInitializeFuse(void)
// hostStaticInit, hostFuseInit and hostInit serve different purposes.
//
// hostStaticInit and hostFuseInit are needed to provide static and dynamic initialization
// of the FUSE layer. This is currently useful on Windows only.
//
// hostInit is simply the .init implementation of struct fuse_operations.
static void hostStaticInit(void)
{
#if defined(__APPLE__) || defined(__linux__)
#elif defined(_WIN32)
InitializeCriticalSection(&cgofuse_lock);
#endif
}
static int hostFuseInit(void)
{
#if defined(__APPLE__) || defined(__linux__)
return 1;
@@ -907,7 +926,7 @@ func hostInit(conn0 *C.struct_fuse_conn_info) (user_data unsafe.Pointer) {
C.bool(host.capCaseInsensitive),
C.bool(host.capReaddirPlus))
if nil != host.sigc {
signal.Notify(host.sigc, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(host.sigc, syscall.SIGINT, syscall.SIGTERM)
}
host.fsop.Init()
return
@@ -1023,11 +1042,8 @@ func (host *FileSystemHost) SetCapReaddirPlus(value bool) {
// It is allowed for the mountpoint to be the empty string ("") in which case opts is assumed
// to contain the mountpoint. It is also allowed for opts to be nil, although in this case the
// mountpoint must be non-empty.
//
// The file system is considered mounted only after its Init() method has been called
// and before its Destroy() method has been called.
func (host *FileSystemHost) Mount(mountpoint string, opts []string) bool {
if 0 == C.hostInitializeFuse() {
if 0 == C.hostFuseInit() {
panic("cgofuse: cannot find winfsp")
}
@@ -1127,3 +1143,7 @@ func Getcontext() (uid uint32, gid uint32, pid int) {
pid = int(C.fuse_get_context().pid)
return
}
func init() {
C.hostStaticInit()
}