Skip to content

Commit

Permalink
update for pr bazil#104
Browse files Browse the repository at this point in the history
- go test runs and successfuly mounts a dir, but, doing an ls
in said dir will result in 'device not configured'.
- more info here: bazil#104
  • Loading branch information
qbit committed May 27, 2017
1 parent 371fbbd commit aff3480
Show file tree
Hide file tree
Showing 25 changed files with 353 additions and 12 deletions.
2 changes: 2 additions & 0 deletions error_freebsd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build freebsd

package fuse

import "syscall"
Expand Down
17 changes: 17 additions & 0 deletions error_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// +build openbsd

package fuse

import "syscall"

const (
ENOATTR = Errno(syscall.ENOATTR)
)

const (
errNoXattr = ENOATTR
)

func init() {
errnoNames[errNoXattr] = "ENOATTR"
}
7 changes: 7 additions & 0 deletions fs/fstestutil/mountinfo_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fstestutil

import "errors"

func getMountInfo(mnt string) (*MountInfo, error) {
return nil, errors.New("OpenBSD has no useful mount information")
}
30 changes: 30 additions & 0 deletions fs/serve_openbsd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fs_test

import (
"testing"

"bazil.org/fuse/fs/fstestutil"
"golang.org/x/sys/unix"
)

type exchangeData struct {
fstestutil.File
// this struct cannot be zero size or multiple instances may look identical
_ int
}

func TestExchangeDataNotSupported(t *testing.T) {
t.Parallel()
mnt, err := fstestutil.MountedT(t, fstestutil.SimpleFS{&fstestutil.ChildMap{
"one": &exchangeData{},
"two": &exchangeData{},
}}, nil)
if err != nil {
t.Fatal(err)
}
defer mnt.Close()

if err := unix.Exchangedata(mnt.Dir+"/one", mnt.Dir+"/two", 0); err != unix.ENOTSUP {
t.Fatalf("expected ENOTSUP from exchangedata: %v", err)
}
}
2 changes: 1 addition & 1 deletion fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func initMount(c *Conn, conf *mountConfig) error {

min := Protocol{protoVersionMinMajor, protoVersionMinMinor}
if r.Kernel.LT(min) {
req.RespondError(Errno(syscall.EPROTO))
req.RespondError(Errno(syscall.EIO))
c.Close()
return &OldVersionError{
Kernel: r.Kernel,
Expand Down
2 changes: 2 additions & 0 deletions fuse_kernel_freebsd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build freebsd

package fuse

import "time"
Expand Down
64 changes: 64 additions & 0 deletions fuse_kernel_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// +build openbsd

package fuse

import "time"

type attr struct {
Ino uint64
Size uint64
Blocks uint64
Atime uint64
Mtime uint64
Ctime uint64
AtimeNsec uint32
MtimeNsec uint32
CtimeNsec uint32
Mode uint32
Nlink uint32
UID uint32
Gid uint32
Rdev uint32
Blksize uint32
padding uint32
}

func (a *attr) Crtime() time.Time {
return time.Time{}
}

func (a *attr) SetCrtime(s uint64, ns uint32) {
// ignored on openbsd
}

func (a *attr) SetFlags(f uint32) {
// ignored on openbsd
}

type setattrIn struct {
setattrInCommon
}

func (in *setattrIn) BkupTime() time.Time {
return time.Time{}
}

func (in *setattrIn) Chgtime() time.Time {
return time.Time{}
}

func (in *setattrIn) Flags() uint32 {
return 0
}

func openFlags(flags uint32) OpenFlags {
return OpenFlags(flags)
}

type getxattrIn struct {
getxattrInCommon
}

type setxattrIn struct {
setxattrInCommon
}
6 changes: 6 additions & 0 deletions fuse_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fuse

// Maximum file write size we are prepared to receive from the kernel.
//
// This number is just a guess.
const maxWrite = 128 * 1024
32 changes: 32 additions & 0 deletions mount_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package fuse

import (
"fmt"
"os"
"unsafe"

"bazil.org/fuse/syscallx"
)

const fuseBufMaxSize = (1024 * 4096)

func mount(dir string, conf *mountConfig, ready chan<- struct{}, errp *error) (*os.File, error) {
defer close(ready)

fmt.Printf("mount(%v, %v)\n", dir, conf)
f, err := os.OpenFile("/dev/fuse0", os.O_RDWR, 0000)
if err != nil {
*errp = err
return nil, err
}

fuse_args := syscallx.Fusefs_args{
FD: int(f.Fd()),
MaxRead: fuseBufMaxSize,
}

fmt.Printf("fusefs_args: %#v\n", fuse_args)

err = syscallx.Mount("fuse", dir, 0, uintptr(unsafe.Pointer(&fuse_args)))
return f, err
}
2 changes: 2 additions & 0 deletions options_freebsd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build freebsd

package fuse

func localVolume(conf *mountConfig) error {
Expand Down
30 changes: 30 additions & 0 deletions options_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// +build openbsd

package fuse

func localVolume(conf *mountConfig) error {
return nil
}

func volumeName(name string) MountOption {
return dummyOption
}

func daemonTimeout(name string) MountOption {
return func(conf *mountConfig) error {
conf.options["timeout"] = name
return nil
}
}

func noAppleXattr(conf *mountConfig) error {
return nil
}

func noAppleDouble(conf *mountConfig) error {
return nil
}

func exclCreate(conf *mountConfig) error {
return nil
}
17 changes: 9 additions & 8 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"runtime"
"syscall"
"strings"
"testing"

"bazil.org/fuse"
Expand All @@ -17,8 +18,8 @@ func init() {
}

func TestMountOptionFSName(t *testing.T) {
if runtime.GOOS == "freebsd" {
t.Skip("FreeBSD does not support FSName")
if strings.Contains(runtime.GOOS, "bsd") {
t.Skip("BSD does not support FSName")
}
t.Parallel()
const name = "FuseTestMarker"
Expand All @@ -40,8 +41,8 @@ func TestMountOptionFSName(t *testing.T) {
}

func testMountOptionFSNameEvil(t *testing.T, evil string) {
if runtime.GOOS == "freebsd" {
t.Skip("FreeBSD does not support FSName")
if strings.Contains(runtime.GOOS, "bsd") {
t.Skip("BSD does not support FSName")
}
t.Parallel()
var name = "FuseTest" + evil + "Marker"
Expand Down Expand Up @@ -97,8 +98,8 @@ func TestMountOptionSubtype(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("OS X does not support Subtype")
}
if runtime.GOOS == "freebsd" {
t.Skip("FreeBSD does not support Subtype")
if strings.Contains(runtime.GOOS, "bsd") {
t.Skip("BSD does not support Subtype")
}
t.Parallel()
const name = "FuseTestMarker"
Expand Down Expand Up @@ -161,8 +162,8 @@ func (f unwritableFile) Attr(ctx context.Context, a *fuse.Attr) error {
}

func TestMountOptionDefaultPermissions(t *testing.T) {
if runtime.GOOS == "freebsd" {
t.Skip("FreeBSD does not support DefaultPermissions")
if strings.Contains(runtime.GOOS, "bsd") {
t.Skip("BSD do not support DefaultPermissions")
}
t.Parallel()

Expand Down
8 changes: 8 additions & 0 deletions syscallx/asm.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "textflag.h"

TEXT ·use(SB),NOSPLIT,$0
RET
7 changes: 7 additions & 0 deletions syscallx/fstestutil/mountinfo_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fstestutil

import "errors"

func getMountInfo(mnt string) (*MountInfo, error) {
return nil, errors.New("OpenBSD has no useful mount information")
}
Empty file.
13 changes: 11 additions & 2 deletions syscallx/generate
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -e

mksys="$(go env GOROOT)/src/pkg/syscall/mksyscall.pl"
mksys="$(go env GOROOT)/src/syscall/mksyscall.pl"

fix() {
sed 's,^package syscall$,&x\nimport "syscall",' \
Expand All @@ -12,7 +12,8 @@ fix() {
| gofmt -r='SYS_LISTXATTR -> syscall.SYS_LISTXATTR' \
| gofmt -r='SYS_SETXATTR -> syscall.SYS_SETXATTR' \
| gofmt -r='SYS_REMOVEXATTR -> syscall.SYS_REMOVEXATTR' \
| gofmt -r='SYS_MSYNC -> syscall.SYS_MSYNC'
| gofmt -r='SYS_MSYNC -> syscall.SYS_MSYNC' \
| gofmt -r='SYS_MOUNT -> syscall.SYS_MOUNT'
}

cd "$(dirname "$0")"
Expand All @@ -32,3 +33,11 @@ $mksys msync.go \
$mksys -l32 msync.go \
| fix \
>msync_386.go

$mksys mount_openbsd.go \
| fix \
> mount_openbsd_amd64.go

$mksys -l32 mount_openbsd.go \
| fix \
> mount_openbsd_386.go
16 changes: 16 additions & 0 deletions syscallx/mount_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package syscallx

import "fmt"

/* This is the source file for syscallx_darwin_*.go, to regenerate run
./generate
*/

//sys mount(tpe string, dir string, flags int, data uintptr) (err error)

func Mount(tpe string, dir string, flags int, data uintptr) (err error) {
fmt.Printf("mount(%v, %v, %v, %v)\n", tpe, dir, flags, data)
return mount(tpe, dir, flags, data)
}
30 changes: 30 additions & 0 deletions syscallx/mount_openbsd_386.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// mksyscall.pl -l32 mount_openbsd.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT

package syscallx

import "syscall"

import "unsafe"

// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT

func mount(tpe string, dir string, flags int, data uintptr) (err error) {
var _p0 *byte
_p0, err = syscall.BytePtrFromString(tpe)
if err != nil {
return
}
var _p1 *byte
_p1, err = syscall.BytePtrFromString(dir)
if err != nil {
return
}
_, _, e1 := syscall.Syscall6(syscall.SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
use(unsafe.Pointer(_p0))
use(unsafe.Pointer(_p1))
if e1 != 0 {
err = e1
}
return
}
30 changes: 30 additions & 0 deletions syscallx/mount_openbsd_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// mksyscall.pl mount_openbsd.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT

package syscallx

import "syscall"

import "unsafe"

// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT

func mount(tpe string, dir string, flags int, data uintptr) (err error) {
var _p0 *byte
_p0, err = syscall.BytePtrFromString(tpe)
if err != nil {
return
}
var _p1 *byte
_p1, err = syscall.BytePtrFromString(dir)
if err != nil {
return
}
_, _, e1 := syscall.Syscall6(syscall.SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
use(unsafe.Pointer(_p0))
use(unsafe.Pointer(_p1))
if e1 != 0 {
err = e1
}
return
}
Loading

0 comments on commit aff3480

Please sign in to comment.