Commit e75e9054 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Go-FUSE for Darwin: runs a first test.

parent 088ea6ab
......@@ -18,5 +18,4 @@ func (a *Attr) FromStat(s *syscall.Stat_t) {
a.Uid = uint32(s.Uid)
a.Gid = uint32(s.Gid)
a.Rdev = uint32(s.Rdev)
a.Blksize = uint32(s.Blksize)
}
......@@ -105,8 +105,8 @@ func (c *FileSystemConnector) GetAttr(out *raw.AttrOut, context *Context, input
node := c.toInode(context.NodeId)
var f File
if input.Flags&raw.FUSE_GETATTR_FH != 0 {
if opened := node.mount.getOpenedFile(input.Fh); opened != nil {
if input.Flags() & raw.FUSE_GETATTR_FH != 0 {
if opened := node.mount.getOpenedFile(input.Fh()); opened != nil {
f = opened.WithFlags.File
}
}
......
package fuse
import (
"syscall"
)
func (fs *LoopbackFileSystem) StatFs(name string) *StatfsOut {
s := syscall.Statfs_t{}
err := syscall.Statfs(fs.GetPath(name), &s)
if err == nil {
return &StatfsOut{
Blocks: s.Blocks,
Bsize: uint32(s.Bsize),
Bfree: s.Bfree,
Bavail: s.Bavail,
Files: s.Files,
Ffree: s.Ffree,
}
}
return nil
}
package fuse
import (
"syscall"
)
func clearStatfs(s *syscall.Statfs_t) {
empty := syscall.Statfs_t{}
s.Type = 0
s.Fsid = empty.Fsid
// s.Spare = empty.Spare
// TODO - figure out what this is for.
s.Flags = 0
}
......@@ -66,20 +66,14 @@ const (
////////////////////////////////////////////////////////////////
func doInit(state *MountState, req *request) {
const (
FUSE_KERNEL_VERSION = 7
MINIMUM_MINOR_VERSION = 13
OUR_MINOR_VERSION = 16
)
input := (*raw.InitIn)(req.inData)
if input.Major != FUSE_KERNEL_VERSION {
log.Printf("Major versions does not match. Given %d, want %d\n", input.Major, FUSE_KERNEL_VERSION)
if input.Major != _FUSE_KERNEL_VERSION {
log.Printf("Major versions does not match. Given %d, want %d\n", input.Major, _FUSE_KERNEL_VERSION)
req.status = EIO
return
}
if input.Minor < MINIMUM_MINOR_VERSION {
log.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, MINIMUM_MINOR_VERSION)
if input.Minor < _MINIMUM_MINOR_VERSION {
log.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, _MINIMUM_MINOR_VERSION)
req.status = EIO
return
}
......@@ -93,8 +87,8 @@ func doInit(state *MountState, req *request) {
state.reqMu.Unlock()
out := &raw.InitOut{
Major: FUSE_KERNEL_VERSION,
Minor: OUR_MINOR_VERSION,
Major: _FUSE_KERNEL_VERSION,
Minor: _OUR_MINOR_VERSION,
MaxReadAhead: input.MaxReadAhead,
Flags: state.kernelSettings.Flags,
MaxWrite: uint32(state.opts.MaxWrite),
......@@ -339,6 +333,10 @@ func doIoctl(state *MountState, req *request) {
req.status = ENOSYS
}
func doDestroy(state *MountState, req *request) {
req.status = OK
}
////////////////////////////////////////////////////////////////
type operationFunc func(*MountState, *request)
......@@ -522,6 +520,7 @@ func init() {
_OP_RENAME: doRename,
_OP_STATFS: doStatFs,
_OP_IOCTL: doIoctl,
_OP_DESTROY: doDestroy,
} {
operationHandlers[op].Func = v
}
......
......@@ -11,7 +11,7 @@ import (
)
var sizeOfOutHeader = unsafe.Sizeof(raw.OutHeader{})
var zeroOutBuf [160]byte
var zeroOutBuf [outputHeaderSize]byte
type request struct {
inputBuf []byte
......@@ -49,7 +49,7 @@ type request struct {
// arrays:
//
// Output header and structured data.
outBuf [160]byte
outBuf [outputHeaderSize]byte
// Input, if small enough to fit here.
smallInputBuf [128]byte
......
package fuse
const outputHeaderSize = 200
const (
_FUSE_KERNEL_VERSION = 7
_MINIMUM_MINOR_VERSION = 8
_OUR_MINOR_VERSION = 8
)
\ No newline at end of file
package fuse
const outputHeaderSize = 160
const (
_FUSE_KERNEL_VERSION = 7
_MINIMUM_MINOR_VERSION = 13
_OUR_MINOR_VERSION = 16
)
......@@ -129,10 +129,6 @@ func (me *SetAttrIn) String() string {
return fmt.Sprintf("{%s}", strings.Join(s, ", "))
}
func (me *GetAttrIn) String() string {
return fmt.Sprintf("{Fh %d}", me.Fh)
}
func (me *ReleaseIn) String() string {
return fmt.Sprintf("{Fh %d %s %s L%d}",
me.Fh, FlagString(OpenFlagNames, int(me.Flags), ""),
......
package raw
import (
"fmt"
"syscall"
)
func (a *Attr) String() string {
......@@ -18,3 +18,5 @@ func (a *Attr) String() string {
a.Rdev, a.Ino, a.Atime, a.Atimensec, a.Mtime, a.Mtimensec,
a.Ctime, a.Ctimensec)
}
func (me *GetAttrIn) String() string { return "" }
\ No newline at end of file
......@@ -25,3 +25,7 @@ func (a *Attr) String() string {
a.Rdev, a.Ino, a.Atime, a.Atimensec, a.Mtime, a.Mtimensec,
a.Ctime, a.Ctimensec)
}
func (me *GetAttrIn) String() string {
return fmt.Sprintf("{Fh %d}", me.Fh_)
}
......@@ -73,17 +73,6 @@ type SetAttrInCommon struct {
Unused5 uint32
}
const (
// Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set.
FUSE_GETATTR_FH = (1 << 0)
)
type GetAttrIn struct {
Flags uint32
Dummy uint32
Fh uint64
}
const RELEASE_FLUSH = (1 << 0)
type ReleaseIn struct {
......
......@@ -32,3 +32,20 @@ type SetAttrIn struct {
CrtimeNsec uint32
Flags_ uint32 // see chflags(2)
}
// compat with linux.
const (
// Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set.
FUSE_GETATTR_FH = (1 << 0)
)
type GetAttrIn struct {
}
func (g *GetAttrIn) Flags() uint32 {
return 0
}
func (g *GetAttrIn) Fh() uint64 {
return 0
}
\ No newline at end of file
......@@ -21,3 +21,22 @@ type Attr struct {
type SetAttrIn struct {
SetAttrInCommon
}
const (
// Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set.
FUSE_GETATTR_FH = (1 << 0)
)
type GetAttrIn struct {
Flags_ uint32
Dummy uint32
Fh_ uint64
}
func (g *GetAttrIn) Flags() uint32 {
return g.Flags_
}
func (g *GetAttrIn) Fh() uint64 {
return g.Fh_
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment