forked from TrueCloudLab/rclone
vendor: update github.com/billziss-gh/cgofuse - fixes #1481
This commit is contained in:
parent
5ed4bc97f3
commit
4ce31555b2
6 changed files with 188 additions and 27 deletions
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -34,8 +34,8 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/billziss-gh/cgofuse"
|
name = "github.com/billziss-gh/cgofuse"
|
||||||
packages = ["fuse"]
|
packages = ["fuse"]
|
||||||
revision = "b402ef9fb28afcc443348ba2d46b5bfd88867fea"
|
revision = "35bcf037030dcadcd247618c75c00c6cd17482d7"
|
||||||
version = "v1.0"
|
version = "v1.0.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/cpuguy83/go-md2man"
|
name = "github.com/cpuguy83/go-md2man"
|
||||||
|
|
71
vendor/github.com/billziss-gh/cgofuse/.circleci/config.yml
generated
vendored
Normal file
71
vendor/github.com/billziss-gh/cgofuse/.circleci/config.yml
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
machine: true
|
||||||
|
|
||||||
|
environment:
|
||||||
|
PROJNAME: github.com/billziss-gh/cgofuse
|
||||||
|
|
||||||
|
working_directory: ~/.go_workspace/src/github.com/billziss-gh/cgofuse
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
# Here we build the billziss/xgo-cgofuse image for testing.
|
||||||
|
# An alternative would be to just `docker pull billziss/xgo-cgofuse`.
|
||||||
|
- run:
|
||||||
|
name: Build xgo-cgofuse image
|
||||||
|
command: docker build -t billziss/xgo-cgofuse .
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Cross-compile cgofuse
|
||||||
|
command: |
|
||||||
|
go get -v github.com/karalabe/xgo
|
||||||
|
xgo \
|
||||||
|
--image=billziss/xgo-cgofuse \
|
||||||
|
--targets=darwin/386,darwin/amd64,linux/386,linux/amd64,windows/386,windows/amd64 \
|
||||||
|
--buildmode=archive \
|
||||||
|
./fuse
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Prepare artifacts
|
||||||
|
command: |
|
||||||
|
mkdir -p /tmp/cgofuse.work/src/$PROJNAME/fuse
|
||||||
|
echo //go:binary-only-package >/tmp/cgofuse.work/src/$PROJNAME/fuse/host.go
|
||||||
|
echo package fuse >>/tmp/cgofuse.work/src/$PROJNAME/fuse/host.go
|
||||||
|
echo //go:binary-only-package >/tmp/cgofuse.work/src/$PROJNAME/fuse/fsop.go
|
||||||
|
echo package fuse >>/tmp/cgofuse.work/src/$PROJNAME/fuse/fsop.go
|
||||||
|
for f in fuse-*.[al]*; do
|
||||||
|
d=$(echo "$f" | sed 's/fuse-\([^-.]*\).*-\([^-.]*\)\..*/\1_\2/g')
|
||||||
|
mkdir -p /tmp/cgofuse.work/pkg/$d/$PROJNAME
|
||||||
|
cp "$f" /tmp/cgofuse.work/pkg/$d/$PROJNAME/fuse.a
|
||||||
|
done
|
||||||
|
mkdir -p /tmp/cgofuse.dist
|
||||||
|
GIT_DSC=$(git describe --long)
|
||||||
|
(cd /tmp/cgofuse.work && zip -rv - *) >/tmp/cgofuse.dist/cgofuse-$GIT_DSC.zip
|
||||||
|
|
||||||
|
- store_artifacts:
|
||||||
|
path: /tmp/cgofuse.dist
|
||||||
|
|
||||||
|
- deploy:
|
||||||
|
name: Make github release
|
||||||
|
command: |
|
||||||
|
if false && [[ $(git describe --exact-match 2>/dev/null) == v* ]]; then
|
||||||
|
GIT_TAG=$(git describe --exact-match)
|
||||||
|
GIT_DSC=$(git describe --long)
|
||||||
|
go get -v github.com/aktau/github-release
|
||||||
|
github-release release \
|
||||||
|
--user "$CIRCLE_PROJECT_USERNAME" \
|
||||||
|
--repo "$CIRCLE_PROJECT_REPONAME" \
|
||||||
|
--tag $GIT_TAG \
|
||||||
|
--pre-release || true
|
||||||
|
github-release upload \
|
||||||
|
--user "$CIRCLE_PROJECT_USERNAME" \
|
||||||
|
--repo "$CIRCLE_PROJECT_REPONAME" \
|
||||||
|
--tag $GIT_TAG \
|
||||||
|
--file /tmp/cgofuse.dist/cgofuse-$GIT_DSC.zip \
|
||||||
|
--name cgofuse-${GIT_TAG:1}.zip \
|
||||||
|
--replace
|
||||||
|
fi
|
40
vendor/github.com/billziss-gh/cgofuse/Dockerfile
generated
vendored
Normal file
40
vendor/github.com/billziss-gh/cgofuse/Dockerfile
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
FROM \
|
||||||
|
karalabe/xgo-latest
|
||||||
|
|
||||||
|
MAINTAINER \
|
||||||
|
Bill Zissimopoulos <billziss at navimatics.com>
|
||||||
|
|
||||||
|
# add 32-bit and 64-bit architectures and install 7zip
|
||||||
|
RUN \
|
||||||
|
dpkg --add-architecture i386 && \
|
||||||
|
dpkg --add-architecture amd64 && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends p7zip-full
|
||||||
|
|
||||||
|
# install OSXFUSE
|
||||||
|
RUN \
|
||||||
|
wget -q -O osxfuse.dmg --no-check-certificate \
|
||||||
|
http://sourceforge.net/projects/osxfuse/files/osxfuse-2.8.3/osxfuse-2.8.3.dmg/download && \
|
||||||
|
7z e osxfuse.dmg 0.hfs &&\
|
||||||
|
7z e 0.hfs "FUSE for OS X/Install OSXFUSE 2.8.pkg" && \
|
||||||
|
7z e "Install OSXFUSE 2.8.pkg" 10.9/OSXFUSECore.pkg/Payload && \
|
||||||
|
7z e Payload && \
|
||||||
|
7z x Payload~ -o/tmp && \
|
||||||
|
cp -R /tmp/usr/local/include/osxfuse /usr/local/include && \
|
||||||
|
cp /tmp/usr/local/lib/libosxfuse_i64.2.dylib /usr/local/lib/libosxfuse.dylib
|
||||||
|
|
||||||
|
# install LIBFUSE
|
||||||
|
RUN \
|
||||||
|
apt-get install -y --no-install-recommends libfuse-dev:i386 && \
|
||||||
|
apt-get install -y --no-install-recommends libfuse-dev:amd64 && \
|
||||||
|
apt-get download libfuse-dev:i386 && \
|
||||||
|
dpkg -x libfuse-dev*i386*.deb /
|
||||||
|
|
||||||
|
# install WinFsp-FUSE
|
||||||
|
RUN \
|
||||||
|
wget -q -O winfsp.zip --no-check-certificate \
|
||||||
|
https://github.com/billziss-gh/winfsp/archive/v1.0.zip && \
|
||||||
|
7z e winfsp.zip 'winfsp-1.0/inc/fuse/*' -o/usr/local/include/winfsp
|
||||||
|
|
||||||
|
ENV \
|
||||||
|
OSXCROSS_NO_INCLUDE_PATH_WARNINGS 1
|
15
vendor/github.com/billziss-gh/cgofuse/README.md
generated
vendored
15
vendor/github.com/billziss-gh/cgofuse/README.md
generated
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
[](https://travis-ci.org/billziss-gh/cgofuse)
|
[](https://travis-ci.org/billziss-gh/cgofuse)
|
||||||
[](https://ci.appveyor.com/project/billziss-gh/cgofuse)
|
[](https://ci.appveyor.com/project/billziss-gh/cgofuse)
|
||||||
|
[](https://circleci.com/gh/billziss-gh/cgofuse)
|
||||||
[](https://godoc.org/github.com/billziss-gh/cgofuse/fuse)
|
[](https://godoc.org/github.com/billziss-gh/cgofuse/fuse)
|
||||||
|
|
||||||
Cgofuse is a cross-platform FUSE library for Go. It is implemented using [cgo](https://golang.org/cmd/cgo/) and can be ported to any platform that has a FUSE implementation.
|
Cgofuse is a cross-platform FUSE library for Go. It is implemented using [cgo](https://golang.org/cmd/cgo/) and can be ported to any platform that has a FUSE implementation.
|
||||||
|
@ -34,6 +35,20 @@ Cgofuse currently runs on **OSX**, **Linux** and **Windows** (using [WinFsp](htt
|
||||||
> go install -v ./fuse ./examples/memfs
|
> go install -v ./fuse ./examples/memfs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## How to cross-compile your project using xgo
|
||||||
|
|
||||||
|
You can easily cross-compile your project using [xgo](https://github.com/karalabe/xgo) and the [billziss/xgo-cgofuse](https://hub.docker.com/r/billziss/xgo-cgofuse/) docker image.
|
||||||
|
|
||||||
|
- Prerequisites: [docker](https://www.docker.com), [xgo](https://github.com/karalabe/xgo)
|
||||||
|
- Build:
|
||||||
|
```
|
||||||
|
$ docker pull billziss/xgo-cgofuse
|
||||||
|
$ go get -u github.com/karalabe/xgo
|
||||||
|
$ cd YOUR-PROJECT-THAT-USES-CGOFUSE
|
||||||
|
$ xgo --image=billziss/xgo-cgofuse \
|
||||||
|
--targets=darwin/386,darwin/amd64,linux/386,linux/amd64,windows/386,windows/amd64 .
|
||||||
|
```
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
User mode file systems are expected to implement `fuse.FileSystemInterface`. To make implementation simpler a file system can embed ("inherit") a `fuse.FileSystemBase` which provides default implementations for all operations. To mount a file system one must instantiate a `fuse.FileSystemHost` using `fuse.NewFileSystemHost`.
|
User mode file systems are expected to implement `fuse.FileSystemInterface`. To make implementation simpler a file system can embed ("inherit") a `fuse.FileSystemBase` which provides default implementations for all operations. To mount a file system one must instantiate a `fuse.FileSystemHost` using `fuse.NewFileSystemHost`.
|
||||||
|
|
45
vendor/github.com/billziss-gh/cgofuse/fuse/fsop.go
generated
vendored
45
vendor/github.com/billziss-gh/cgofuse/fuse/fsop.go
generated
vendored
|
@ -12,10 +12,15 @@
|
||||||
|
|
||||||
// Package fuse allows the creation of user mode file systems in Go.
|
// Package fuse allows the creation of user mode file systems in Go.
|
||||||
//
|
//
|
||||||
// A user mode file system must implement the methods in FileSystemInterface
|
// A user mode file system is a user mode process that receives file system operations
|
||||||
// and be hosted (mounted) by a FileSystemHost.
|
// from the OS FUSE layer and satisfies them in user mode. A user mode file system
|
||||||
// Alternatively a user mode file system can use the FileSystemBase struct which
|
// implements the interface FileSystemInterface either directly or by embedding a
|
||||||
// provides default implementations of the methods in FileSystemInterface.
|
// FileSystemBase struct which provides a default (empty) implementation of all methods
|
||||||
|
// in FileSystemInterface.
|
||||||
|
//
|
||||||
|
// In order to expose the user mode file system to the OS, the file system must be hosted
|
||||||
|
// (mounted) by a FileSystemHost. The FileSystemHost Mount() method is used for this
|
||||||
|
// purpose.
|
||||||
package fuse
|
package fuse
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -397,18 +402,28 @@ type Lock_t struct {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// FileSystemInterface is the interface that all file systems must implement.
|
// FileSystemInterface is the interface that a user mode interface must implement.
|
||||||
// The file system will receive an Init() call when it is mounted and a Destroy()
|
//
|
||||||
// call when it is unmounted (note that depending on how the file system is
|
// The file system will receive an Init() call when the file system is created;
|
||||||
// terminated the file system may not receive the Destroy() call). All other
|
// the Init() call will happen prior to receiving any other file system calls.
|
||||||
// operations must return 0 on success or a FUSE error on failure. To return an
|
// Note that there are no guarantees on the exact timing of when Init() is called.
|
||||||
// error return the NEGATIVE value of a particular error. For example, to report
|
// For example, it cannot be assumed that the file system is mounted at the time
|
||||||
// "file not found" return -fuse.ENOENT.
|
// the Init() call is received.
|
||||||
|
//
|
||||||
|
// The file system will receive a Destroy() call when the file system is destroyed;
|
||||||
|
// the Destroy() call will always be the last call to be received by the file system.
|
||||||
|
// Note that depending on how the file system is terminated the file system may not
|
||||||
|
// receive the Destroy() call. For example, it will not receive the Destroy() call
|
||||||
|
// if the file system process is forcibly killed.
|
||||||
|
//
|
||||||
|
// Except for Init() and Destroy() all file system operations must return 0 on success
|
||||||
|
// or a FUSE error on failure. To return an error return the NEGATIVE value of a
|
||||||
|
// particular error. For example, to report "file not found" return -fuse.ENOENT.
|
||||||
type FileSystemInterface interface {
|
type FileSystemInterface interface {
|
||||||
// Init is called when the file system is mounted.
|
// Init is called when the file system is created.
|
||||||
Init()
|
Init()
|
||||||
|
|
||||||
// Destroy is called when the file system is unmounted.
|
// Destroy is called when the file system is destroyed.
|
||||||
Destroy()
|
Destroy()
|
||||||
|
|
||||||
// Statfs gets file system statistics.
|
// Statfs gets file system statistics.
|
||||||
|
@ -526,12 +541,12 @@ var _ error = (*Error)(nil)
|
||||||
type FileSystemBase struct {
|
type FileSystemBase struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init is called when the file system is mounted.
|
// Init is called when the file system is created.
|
||||||
// The FileSystemBase implementation does nothing.
|
// The FileSystemBase implementation does nothing.
|
||||||
func (*FileSystemBase) Init() {
|
func (*FileSystemBase) Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy is called when the file system is unmounted.
|
// Destroy is called when the file system is destroyed.
|
||||||
// The FileSystemBase implementation does nothing.
|
// The FileSystemBase implementation does nothing.
|
||||||
func (*FileSystemBase) Destroy() {
|
func (*FileSystemBase) Destroy() {
|
||||||
}
|
}
|
||||||
|
|
40
vendor/github.com/billziss-gh/cgofuse/fuse/host.go
generated
vendored
40
vendor/github.com/billziss-gh/cgofuse/fuse/host.go
generated
vendored
|
@ -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 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 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 CFLAGS: -DFUSE_USE_VERSION=28 -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse
|
||||||
#cgo linux LDFLAGS: -lfuse
|
#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))
|
#if !(defined(__APPLE__) || defined(__linux__) || defined(_WIN32))
|
||||||
#error platform not supported
|
#error platform not supported
|
||||||
|
@ -42,7 +46,7 @@ static PVOID cgofuse_init_slow(int hardfail);
|
||||||
static VOID cgofuse_init_fail(VOID);
|
static VOID cgofuse_init_fail(VOID);
|
||||||
static PVOID cgofuse_init_winfsp(VOID);
|
static PVOID cgofuse_init_winfsp(VOID);
|
||||||
|
|
||||||
static SRWLOCK cgofuse_lock = SRWLOCK_INIT;
|
static CRITICAL_SECTION cgofuse_lock;
|
||||||
static PVOID cgofuse_module = 0;
|
static PVOID cgofuse_module = 0;
|
||||||
|
|
||||||
static inline PVOID cgofuse_init_fast(int hardfail)
|
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)
|
static PVOID cgofuse_init_slow(int hardfail)
|
||||||
{
|
{
|
||||||
PVOID Module;
|
PVOID Module;
|
||||||
AcquireSRWLockExclusive(&cgofuse_lock);
|
EnterCriticalSection(&cgofuse_lock);
|
||||||
Module = cgofuse_module;
|
Module = cgofuse_module;
|
||||||
if (0 == Module)
|
if (0 == Module)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +69,7 @@ static PVOID cgofuse_init_slow(int hardfail)
|
||||||
MemoryBarrier();
|
MemoryBarrier();
|
||||||
cgofuse_module = Module;
|
cgofuse_module = Module;
|
||||||
}
|
}
|
||||||
ReleaseSRWLockExclusive(&cgofuse_lock);
|
LeaveCriticalSection(&cgofuse_lock);
|
||||||
if (0 == Module && hardfail)
|
if (0 == Module && hardfail)
|
||||||
cgofuse_init_fail();
|
cgofuse_init_fail();
|
||||||
return Module;
|
return Module;
|
||||||
|
@ -351,7 +355,22 @@ static int _hostGetxattr(char *path, char *name, char *value, size_t size,
|
||||||
#define _hostGetxattr hostGetxattr
|
#define _hostGetxattr hostGetxattr
|
||||||
#endif
|
#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__)
|
#if defined(__APPLE__) || defined(__linux__)
|
||||||
return 1;
|
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.capCaseInsensitive),
|
||||||
C.bool(host.capReaddirPlus))
|
C.bool(host.capReaddirPlus))
|
||||||
if nil != host.sigc {
|
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()
|
host.fsop.Init()
|
||||||
return
|
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
|
// 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
|
// to contain the mountpoint. It is also allowed for opts to be nil, although in this case the
|
||||||
// mountpoint must be non-empty.
|
// 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 {
|
func (host *FileSystemHost) Mount(mountpoint string, opts []string) bool {
|
||||||
if 0 == C.hostInitializeFuse() {
|
if 0 == C.hostFuseInit() {
|
||||||
panic("cgofuse: cannot find winfsp")
|
panic("cgofuse: cannot find winfsp")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1127,3 +1143,7 @@ func Getcontext() (uid uint32, gid uint32, pid int) {
|
||||||
pid = int(C.fuse_get_context().pid)
|
pid = int(C.fuse_get_context().pid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
C.hostStaticInit()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue