Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
Nick Craig-Wood
f60476e30a cmount: make work under OpenBSD - fixes #1727 2020-09-01 13:50:10 +01:00
Nick Craig-Wood
a910ec398d vfs: make mount tests run on OpenBSD 2020-09-01 13:49:53 +01:00
8 changed files with 50 additions and 14 deletions

View file

@ -1,6 +1,6 @@
// +build cmount
// +build cgo
// +build linux darwin freebsd windows
// +build linux darwin freebsd openbsd windows
package cmount
@ -8,6 +8,7 @@ import (
"io"
"os"
"path"
"runtime"
"sync"
"time"
@ -225,6 +226,12 @@ func (fsys *FS) Readdir(dirPath string,
// We can't seek in directories and FUSE should know that so
// return an error if ofst is ever set.
if ofst > 0 {
// However openbsd doesn't seem to know this - perhaps a bug in its
// FUSE implementation or a bug in cgofuse?
// See: https://github.com/billziss-gh/cgofuse/issues/49
if runtime.GOOS == "openbsd" {
return 0
}
return -fuse.ESPIPE
}

View file

@ -4,7 +4,7 @@
// +build cmount
// +build cgo
// +build linux darwin freebsd windows
// +build linux darwin freebsd openbsd windows
package cmount
@ -37,13 +37,17 @@ func mountOptions(VFS *vfs.VFS, device string, mountpoint string, opt *mountlib.
options = []string{
"-o", "fsname=" + device,
"-o", "subtype=rclone",
"-o", fmt.Sprintf("max_readahead=%d", opt.MaxReadAhead),
"-o", fmt.Sprintf("attr_timeout=%g", opt.AttrTimeout.Seconds()),
// This causes FUSE to supply O_TRUNC with the Open
// call which is more efficient for cmount. However
// it does not work with cgofuse on Windows with
// WinFSP so cmount must work with or without it.
"-o", "atomic_o_trunc",
}
if runtime.GOOS != "openbsd" {
options = append(options,
"-o", fmt.Sprintf("max_readahead=%d", opt.MaxReadAhead),
// This causes FUSE to supply O_TRUNC with the Open
// call which is more efficient for cmount. However
// it does not work with cgofuse on Windows with
// WinFSP so cmount must work with or without it.
"-o", "atomic_o_trunc",
)
}
if opt.DebugFUSE {
options = append(options, "-o", "debug")

View file

@ -1,6 +1,6 @@
// +build cmount
// +build cgo
// +build linux darwin freebsd windows
// +build linux darwin freebsd openbsd windows
// +build !race !windows
// FIXME this doesn't work with the race detector under Windows either

View file

@ -1,6 +1,6 @@
// Build for cmount for unsupported platforms to stop go complaining
// about "no buildable Go source files "
// +build !linux,!darwin,!freebsd,!windows !cgo !cmount
// +build !linux,!darwin,!freebsd,!openbsd,!windows !cgo !cmount
package cmount

View file

@ -5,6 +5,7 @@ import (
"runtime"
"testing"
"github.com/rclone/rclone/vfs"
"github.com/rclone/rclone/vfs/vfscommon"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -15,7 +16,7 @@ func TestWriteFileNoWrite(t *testing.T) {
run.skipIfNoFUSE(t)
fd, err := osCreate(run.path("testnowrite"))
assert.NoError(t, err)
require.NoError(t, err)
err = fd.Close()
assert.NoError(t, err)
@ -110,6 +111,9 @@ func TestWriteFileDup(t *testing.T) {
var dupFd uintptr
dupFd, err = writeTestDup(fh.Fd())
if err == vfs.ENOSYS {
t.Skip("dup not supported on this platform")
}
require.NoError(t, err)
dupFile := os.NewFile(dupFd, fh.Name())

View file

@ -0,0 +1,20 @@
// +build !linux,!darwin,!freebsd,!openbsd,!windows
package vfstest
import (
"runtime"
"testing"
"github.com/rclone/rclone/vfs"
)
// TestWriteFileDoubleClose tests double close on write
func TestWriteFileDoubleClose(t *testing.T) {
t.Skip("not supported on " + runtime.GOOS)
}
// writeTestDup performs the platform-specific implementation of the dup() syscall
func writeTestDup(oldfd uintptr) (uintptr, error) {
return oldfd, vfs.ENOSYS
}

View file

@ -1,4 +1,4 @@
// +build linux darwin freebsd
// +build linux darwin freebsd openbsd
package vfstest
@ -8,6 +8,7 @@ import (
"github.com/rclone/rclone/vfs/vfscommon"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sys/unix"
)
@ -20,7 +21,7 @@ func TestWriteFileDoubleClose(t *testing.T) {
}
out, err := osCreate(run.path("testdoubleclose"))
assert.NoError(t, err)
require.NoError(t, err)
fd := out.Fd()
fd1, err := unix.Dup(int(fd))

View file

@ -1,4 +1,4 @@
// +build !linux,!darwin,!freebsd
// +build windows
package vfstest