Source

go-extra / fuse / fuse_test.go

Full commit
Taru Karttunen 7b2b848 





























































package fuse

import (
	"fmt"
	"os"
	"testing"
)

func TestFuse(t *testing.T) { main() }

func main() {
	var err os.Error
	fmt.Printf("Starting\n")
	os.Mkdir("/tmp/m", 0700)
	fuseFd, err := MountFuse("/tmp/m", nil)
	fmt.Printf("f = %v, err = %v\n", fuseFd, err)
	err = FuseLoop(My(0), fuseFd)
	fmt.Printf("FuseLoop -> err = %v\n", err)
	fmt.Printf("done\n")
}

type My int

func (My) FuseInit(*Init) Error {
	return OK
}
func (My) FuseGetAttr(p *GetAttr) (*Attr, Error) {
	var a Attr
	a.Ino = p.Nodeid
	a.Mode = S_IFDIR
	return &a, OK
}

func (My) FuseGetXAttrSize(h *Header, attr []byte) (int, Error) {
	fmt.Printf("getxattr size '%s'\n", attr)
	return 0, ENOATTR
}

func (My) FuseGetXAttr(h *Header, attr []byte) ([]byte, Error) {
	fmt.Printf("getxattr '%s'\n", attr)
	return []byte{}, ENOATTR
}

func (My) FuseOpenDir(o *Open) (flags Flags, fh FH, e Error) {
	flags = o.Flags
	return
}
func (My) FuseOpen(o *Open) (flags Flags, fh FH, e Error) {
	flags = o.Flags
	return
}


func (My) FuseRelease(*Release) Error {
	return OK
}
func (My) FuseReleaseDir(*Release) Error {
	return OK
}

func (My) FuseReadDir(*Read) ([]byte, Error) {
	return []byte{}, OK
}