Commit 2dff88ce authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Move passthrough and dummyfuse into examplelib/

Provide a passthrough main for real-world tests.
parent ebe18c90
# Use "gomake install" to build and install this package.
include $(GOROOT)/src/Make.inc
TARG=main
GOFILES=main.go
DEPS=../examplelib
include $(GOROOT)/src/Make.cmd
package main
import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/examplelib"
"fmt"
"os"
"flag"
)
func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
threaded := flag.Bool("threaded", true, "switch off threading; print debugging messages.")
flag.Parse()
if flag.NArg() < 2 {
// TODO - where to get program name?
fmt.Println("usage: main ORIGINAL MOUNTPOINT")
os.Exit(2)
}
orig := flag.Arg(0)
pt := examplelib.NewPassThroughFuse(orig)
fs := fuse.NewPathFileSystemConnector(pt)
state := fuse.NewMountState(fs)
state.Debug = *debug
mountPoint := flag.Arg(1)
state.Mount(mountPoint, *threaded)
fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v)\n", orig, mountPoint, *threaded, *debug)
}
# Use "gomake install" to build and install this package.
include $(GOROOT)/src/Make.inc
TARG=github.com/hanwen/go-fuse/examplelib
DEPS=../fuse
GOFILES=dummyfuse.go\
passthrough.go\
include $(GOROOT)/src/Make.pkg
package examplelib
import (
"github.com/hanwen/go-fuse/fuse"
)
// Declare dummy methods, for cut & paste convenience.
type DummyFuse struct{}
func (fs *DummyFuse) Init(h *fuse.InHeader, input *fuse.InitIn) (*fuse.InitOut, fuse.Status) {
return new(fuse.InitOut), fuse.OK
}
func (fs *DummyFuse) Destroy(h *fuse.InHeader, input *fuse.InitIn) {
}
func (fs *DummyFuse) Lookup(h *fuse.InHeader, name string) (out *fuse.EntryOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (fs *DummyFuse) Forget(h *fuse.InHeader, input *fuse.ForgetIn) {
}
func (fs *DummyFuse) GetAttr(header *fuse.InHeader, input *fuse.GetAttrIn) (out *fuse.AttrOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (fs *DummyFuse) Open(header *fuse.InHeader, input *fuse.OpenIn) (flags uint32, fuseFile fuse.RawFuseFile, status fuse.Status) {
return 0, nil, fuse.OK
}
func (self *DummyFuse) SetAttr(header *fuse.InHeader, input *fuse.SetAttrIn) (out *fuse.AttrOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) Readlink(header *fuse.InHeader) (out []byte, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) Mknod(header *fuse.InHeader, input *fuse.MknodIn, name string) (out *fuse.EntryOut, code fuse.Status) {
return new(fuse.EntryOut), fuse.ENOSYS
}
func (self *DummyFuse) Mkdir(header *fuse.InHeader, input *fuse.MkdirIn, name string) (out *fuse.EntryOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) Unlink(header *fuse.InHeader, name string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyFuse) Rmdir(header *fuse.InHeader, name string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyFuse) Symlink(header *fuse.InHeader, pointedTo string, linkName string) (out *fuse.EntryOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) Rename(header *fuse.InHeader, input *fuse.RenameIn, oldName string, newName string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyFuse) Link(header *fuse.InHeader, input *fuse.LinkIn, name string) (out *fuse.EntryOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) SetXAttr(header *fuse.InHeader, input *fuse.SetXAttrIn) fuse.Status {
return fuse.ENOSYS
}
func (self *DummyFuse) GetXAttr(header *fuse.InHeader, input *fuse.GetXAttrIn) (out *fuse.GetXAttrOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) Access(header *fuse.InHeader, input *fuse.AccessIn) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyFuse) Create(header *fuse.InHeader, input *fuse.CreateIn, name string) (flags uint32, fuseFile fuse.RawFuseFile, out *fuse.EntryOut, code fuse.Status) {
return 0, nil, nil, fuse.ENOSYS
}
func (self *DummyFuse) Bmap(header *fuse.InHeader, input *fuse.BmapIn) (out *fuse.BmapOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) Ioctl(header *fuse.InHeader, input *fuse.IoctlIn) (out *fuse.IoctlOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) Poll(header *fuse.InHeader, input *fuse.PollIn) (out *fuse.PollOut, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuse) OpenDir(header *fuse.InHeader, input *fuse.OpenIn) (flags uint32, fuseFile fuse.RawFuseDir, status fuse.Status) {
return 0, nil, fuse.ENOSYS
}
////////////////////////////////////////////////////////////////
// DummyFuseFile
type DummyFuseFile struct{}
func (self *DummyFuseFile) Read(*fuse.ReadIn) ([]byte, fuse.Status) {
return []byte(""), fuse.ENOSYS
}
func (self *DummyFuseFile) Write(*fuse.WriteIn, []byte) (uint32, fuse.Status) {
return 0, fuse.ENOSYS
}
func (self *DummyFuseFile) Flush() {
}
func (self *DummyFuseFile) Release() {
}
func (self *DummyFuseFile) Fsync(*fuse.FsyncIn) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyFuseFile) ReadDir(input *fuse.ReadIn) (*fuse.DirEntryList, fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyFuseFile) ReleaseDir() {
}
func (self *DummyFuseFile) FsyncDir(input *fuse.FsyncIn) (code fuse.Status) {
return fuse.ENOSYS
}
////////////////////////////////////////////////////////////////
// DummyPathFuse
type DummyPathFuse struct{}
func (self *DummyPathFuse) GetAttr(name string) (*fuse.Attr, fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyPathFuse) Readlink(name string) (string, fuse.Status) {
return "", fuse.ENOSYS
}
func (self *DummyPathFuse) Mknod(name string, mode uint32, dev uint32) fuse.Status {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Mkdir(name string, mode uint32) fuse.Status {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Unlink(name string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Rmdir(name string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Symlink(value string, linkName string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Rename(oldName string, newName string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Link(oldName string, newName string) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Chmod(name string, mode uint32) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Chown(name string, uid uint32, gid uint32) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Truncate(name string, offset uint64) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Open(name string, flags uint32) (file fuse.RawFuseFile, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyPathFuse) OpenDir(name string) (dir fuse.RawFuseDir, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyPathFuse) Init() (*fuse.InitOut, fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyPathFuse) Destroy() {
}
func (self *DummyPathFuse) Access(name string, mode uint32) (code fuse.Status) {
return fuse.ENOSYS
}
func (self *DummyPathFuse) Create(name string, flags uint32, mode uint32) (file fuse.RawFuseFile, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (self *DummyPathFuse) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code fuse.Status) {
return fuse.ENOSYS
}
package fuse package examplelib
// Compilation test for DummyFuse and DummyPathFuse // Compilation test for DummyFuse and DummyPathFuse
import ( import (
"github.com/hanwen/go-fuse/fuse"
"testing" "testing"
) )
func TestDummy(t *testing.T) { func TestDummy(t *testing.T) {
fs := new(DummyFuse) fs := new(DummyFuse)
NewMountState(fs) fuse.NewMountState(fs)
pathFs := new(DummyPathFuse) pathFs := new(DummyPathFuse)
NewPathFileSystemConnector(pathFs) fuse.NewPathFileSystemConnector(pathFs)
} }
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
// system. Its main purpose is to provide test coverage without // system. Its main purpose is to provide test coverage without
// having to build an actual synthetic filesystem. // having to build an actual synthetic filesystem.
package fuse package examplelib
import ( import (
"github.com/hanwen/go-fuse/fuse"
"fmt" "fmt"
"os" "os"
"path" "path"
...@@ -24,7 +25,7 @@ func NewPassThroughFuse(root string) (out *PassThroughFuse) { ...@@ -24,7 +25,7 @@ func NewPassThroughFuse(root string) (out *PassThroughFuse) {
return out return out
} }
func CopyFileInfo(fi *os.FileInfo, attr *Attr) { func CopyFileInfo(fi *os.FileInfo, attr *fuse.Attr) {
attr.Ino = uint64(fi.Ino) attr.Ino = uint64(fi.Ino)
attr.Size = uint64(fi.Size) attr.Size = uint64(fi.Size)
attr.Blocks = uint64(fi.Blocks) attr.Blocks = uint64(fi.Blocks)
...@@ -46,8 +47,8 @@ func CopyFileInfo(fi *os.FileInfo, attr *Attr) { ...@@ -46,8 +47,8 @@ func CopyFileInfo(fi *os.FileInfo, attr *Attr) {
attr.Blksize = uint32(fi.Blksize) attr.Blksize = uint32(fi.Blksize)
} }
func (self *PassThroughFuse) Init() (*InitOut, Status) { func (self *PassThroughFuse) Init() (*fuse.InitOut, fuse.Status) {
return new(InitOut), OK return new(fuse.InitOut), fuse.OK
} }
func (self *PassThroughFuse) Destroy() { func (self *PassThroughFuse) Destroy() {
...@@ -58,95 +59,95 @@ func (self *PassThroughFuse) GetPath(relPath string) string { ...@@ -58,95 +59,95 @@ func (self *PassThroughFuse) GetPath(relPath string) string {
return path.Join(self.root, relPath) return path.Join(self.root, relPath)
} }
func (self *PassThroughFuse) GetAttr(name string) (*Attr, Status) { func (self *PassThroughFuse) GetAttr(name string) (*fuse.Attr, fuse.Status) {
fullPath := self.GetPath(name) fullPath := self.GetPath(name)
fi, err := os.Lstat(fullPath) fi, err := os.Lstat(fullPath)
if err != nil { if err != nil {
return nil, ENOENT return nil, fuse.ENOENT
} }
out := new(Attr) out := new(fuse.Attr)
CopyFileInfo(fi, out) CopyFileInfo(fi, out)
return out, OK return out, fuse.OK
} }
func (self *PassThroughFuse) OpenDir(name string) (fuseFile RawFuseDir, status Status) { func (self *PassThroughFuse) OpenDir(name string) (fuseFile fuse.RawFuseDir, status fuse.Status) {
// What other ways beyond O_RDONLY are there to open // What other ways beyond O_RDONLY are there to open
// directories? // directories?
f, err := os.Open(self.GetPath(name), os.O_RDONLY, 0) f, err := os.Open(self.GetPath(name), os.O_RDONLY, 0)
if err != nil { if err != nil {
return nil, OsErrorToFuseError(err) return nil, fuse.OsErrorToFuseError(err)
} }
p := NewPassThroughDir(f) p := NewPassThroughDir(f)
return p, OK return p, fuse.OK
} }
func (self *PassThroughFuse) Open(name string, flags uint32) (fuseFile RawFuseFile, status Status) { func (self *PassThroughFuse) Open(name string, flags uint32) (fuseFile fuse.RawFuseFile, status fuse.Status) {
f, err := os.Open(self.GetPath(name), int(flags), 0) f, err := os.Open(self.GetPath(name), int(flags), 0)
if err != nil { if err != nil {
return nil, OsErrorToFuseError(err) return nil, fuse.OsErrorToFuseError(err)
} }
return &PassThroughFile{file: f}, OK return &PassThroughFile{file: f}, fuse.OK
} }
func (self *PassThroughFuse) Chmod(path string, mode uint32) (code Status) { func (self *PassThroughFuse) Chmod(path string, mode uint32) (code fuse.Status) {
err := os.Chmod(self.GetPath(path), mode) err := os.Chmod(self.GetPath(path), mode)
return OsErrorToFuseError(err) return fuse.OsErrorToFuseError(err)
} }
func (self *PassThroughFuse) Chown(path string, uid uint32, gid uint32) (code Status) { func (self *PassThroughFuse) Chown(path string, uid uint32, gid uint32) (code fuse.Status) {
return OsErrorToFuseError(os.Chown(self.GetPath(path), int(uid), int(gid))) return fuse.OsErrorToFuseError(os.Chown(self.GetPath(path), int(uid), int(gid)))
} }
func (self *PassThroughFuse) Truncate(path string, offset uint64) (code Status) { func (self *PassThroughFuse) Truncate(path string, offset uint64) (code fuse.Status) {
return OsErrorToFuseError(os.Truncate(self.GetPath(path), int64(offset))) return fuse.OsErrorToFuseError(os.Truncate(self.GetPath(path), int64(offset)))
} }
func (self *PassThroughFuse) Utimens(path string, AtimeNs uint64, MtimeNs uint64) (code Status) { func (self *PassThroughFuse) Utimens(path string, AtimeNs uint64, MtimeNs uint64) (code fuse.Status) {
return OsErrorToFuseError(os.Chtimes(self.GetPath(path), int64(AtimeNs), int64(MtimeNs))) return fuse.OsErrorToFuseError(os.Chtimes(self.GetPath(path), int64(AtimeNs), int64(MtimeNs)))
} }
func (self *PassThroughFuse) Readlink(name string) (out string, code Status) { func (self *PassThroughFuse) Readlink(name string) (out string, code fuse.Status) {
f, err := os.Readlink(self.GetPath(name)) f, err := os.Readlink(self.GetPath(name))
return f, OsErrorToFuseError(err) return f, fuse.OsErrorToFuseError(err)
} }
func (self *PassThroughFuse) Mknod(name string, mode uint32, dev uint32) (code Status) { func (self *PassThroughFuse) Mknod(name string, mode uint32, dev uint32) (code fuse.Status) {
return Status(syscall.Mknod(self.GetPath(name), mode, int(dev))) return fuse.Status(syscall.Mknod(self.GetPath(name), mode, int(dev)))
} }
func (self *PassThroughFuse) Mkdir(path string, mode uint32) (code Status) { func (self *PassThroughFuse) Mkdir(path string, mode uint32) (code fuse.Status) {
return OsErrorToFuseError(os.Mkdir(self.GetPath(path), mode)) return fuse.OsErrorToFuseError(os.Mkdir(self.GetPath(path), mode))
} }
func (self *PassThroughFuse) Unlink(name string) (code Status) { func (self *PassThroughFuse) Unlink(name string) (code fuse.Status) {
return OsErrorToFuseError(os.Remove(self.GetPath(name))) return fuse.OsErrorToFuseError(os.Remove(self.GetPath(name)))
} }
func (self *PassThroughFuse) Rmdir(name string) (code Status) { func (self *PassThroughFuse) Rmdir(name string) (code fuse.Status) {
return OsErrorToFuseError(os.Remove(self.GetPath(name))) return fuse.OsErrorToFuseError(os.Remove(self.GetPath(name)))
} }
func (self *PassThroughFuse) Symlink(pointedTo string, linkName string) (code Status) { func (self *PassThroughFuse) Symlink(pointedTo string, linkName string) (code fuse.Status) {
return OsErrorToFuseError(os.Symlink(pointedTo, self.GetPath(linkName))) return fuse.OsErrorToFuseError(os.Symlink(pointedTo, self.GetPath(linkName)))
} }
func (self *PassThroughFuse) Rename(oldPath string, newPath string) (code Status) { func (self *PassThroughFuse) Rename(oldPath string, newPath string) (code fuse.Status) {
err := os.Rename(self.GetPath(oldPath), self.GetPath(newPath)) err := os.Rename(self.GetPath(oldPath), self.GetPath(newPath))
return OsErrorToFuseError(err) return fuse.OsErrorToFuseError(err)
} }
func (self *PassThroughFuse) Link(orig string, newName string) (code Status) { func (self *PassThroughFuse) Link(orig string, newName string) (code fuse.Status) {
return OsErrorToFuseError(os.Link(self.GetPath(orig), self.GetPath(newName))) return fuse.OsErrorToFuseError(os.Link(self.GetPath(orig), self.GetPath(newName)))
} }
func (self *PassThroughFuse) Access(name string, mode uint32) (code Status) { func (self *PassThroughFuse) Access(name string, mode uint32) (code fuse.Status) {
return Status(syscall.Access(self.GetPath(name), mode)) return fuse.Status(syscall.Access(self.GetPath(name), mode))
} }
func (self *PassThroughFuse) Create(path string, flags uint32, mode uint32) (fuseFile RawFuseFile, code Status) { func (self *PassThroughFuse) Create(path string, flags uint32, mode uint32) (fuseFile fuse.RawFuseFile, code fuse.Status) {
f, err := os.Open(self.GetPath(path), int(flags)|os.O_CREAT, mode) f, err := os.Open(self.GetPath(path), int(flags)|os.O_CREAT, mode)
return &PassThroughFile{file: f}, OsErrorToFuseError(err) return &PassThroughFile{file: f}, fuse.OsErrorToFuseError(err)
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -155,33 +156,33 @@ type PassThroughFile struct { ...@@ -155,33 +156,33 @@ type PassThroughFile struct {
file *os.File file *os.File
} }
func (self *PassThroughFile) Read(input *ReadIn) ([]byte, Status) { func (self *PassThroughFile) Read(input *fuse.ReadIn) ([]byte, fuse.Status) {
buf := make([]byte, input.Size) buf := make([]byte, input.Size)
slice := buf[:] slice := buf[:]
n, err := self.file.ReadAt(slice, int64(input.Offset)) n, err := self.file.ReadAt(slice, int64(input.Offset))
if err == os.EOF { if err == os.EOF {
// TODO - how to signal EOF? // TODO - how to signal EOF?
return slice[:n], OK return slice[:n], fuse.OK
} }
return slice[:n], OsErrorToFuseError(err) return slice[:n], fuse.OsErrorToFuseError(err)
} }
func (self *PassThroughFile) Write(input *WriteIn, data []byte) (uint32, Status) { func (self *PassThroughFile) Write(input *fuse.WriteIn, data []byte) (uint32, fuse.Status) {
n, err := self.file.WriteAt(data, int64(input.Offset)) n, err := self.file.WriteAt(data, int64(input.Offset))
return uint32(n), OsErrorToFuseError(err) return uint32(n), fuse.OsErrorToFuseError(err)
} }
func (self *PassThroughFile) Flush() Status { func (self *PassThroughFile) Flush() fuse.Status {
return OK return fuse.OK
} }
func (self *PassThroughFile) Release() { func (self *PassThroughFile) Release() {
self.file.Close() self.file.Close()
} }
func (self *PassThroughFile) Fsync(*FsyncIn) (code Status) { func (self *PassThroughFile) Fsync(*fuse.FsyncIn) (code fuse.Status) {
return Status(syscall.Fsync(self.file.Fd())) return fuse.Status(syscall.Fsync(self.file.Fd()))
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -218,8 +219,8 @@ func NewPassThroughDir(file *os.File) *PassThroughDir { ...@@ -218,8 +219,8 @@ func NewPassThroughDir(file *os.File) *PassThroughDir {
return self return self
} }
func (self *PassThroughDir) ReadDir(input *ReadIn) (*DirEntryList, Status) { func (self *PassThroughDir) ReadDir(input *fuse.ReadIn) (*fuse.DirEntryList, fuse.Status) {
list := NewDirEntryList(int(input.Size)) list := fuse.NewDirEntryList(int(input.Size))
if self.leftOver != nil { if self.leftOver != nil {
success := list.AddString(self.leftOver.Name, self.leftOver.Ino, self.leftOver.Mode) success := list.AddString(self.leftOver.Name, self.leftOver.Ino, self.leftOver.Mode)
...@@ -240,13 +241,13 @@ func (self *PassThroughDir) ReadDir(input *ReadIn) (*DirEntryList, Status) { ...@@ -240,13 +241,13 @@ func (self *PassThroughDir) ReadDir(input *ReadIn) (*DirEntryList, Status) {
break break
} }
} }
return list, OsErrorToFuseError(self.directoryError) return list, fuse.OsErrorToFuseError(self.directoryError)
} }
func (self *PassThroughDir) ReleaseDir() { func (self *PassThroughDir) ReleaseDir() {
close(self.directoryChannel) close(self.directoryChannel)
} }
func (self *PassThroughDir) FsyncDir(input *FsyncIn) (code Status) { func (self *PassThroughDir) FsyncDir(input *fuse.FsyncIn) (code fuse.Status) {
return ENOSYS return fuse.ENOSYS
} }
package fuse package examplelib
import ( import (
"github.com/hanwen/go-fuse/fuse"
"bytes" "bytes"
"fmt" "fmt"
"log" "log"
...@@ -48,7 +49,7 @@ type testCase struct { ...@@ -48,7 +49,7 @@ type testCase struct {
origSubdir string origSubdir string
origSubfile string origSubfile string
tester *testing.T tester *testing.T
state *MountState state *fuse.MountState
} }
// Create and mount filesystem. // Create and mount filesystem.
...@@ -58,8 +59,8 @@ func (self *testCase) Setup(t *testing.T) { ...@@ -58,8 +59,8 @@ func (self *testCase) Setup(t *testing.T) {
const name string = "hello.txt" const name string = "hello.txt"
const subdir string = "subdir" const subdir string = "subdir"
self.origDir = MakeTempDir() self.origDir = fuse.MakeTempDir()
self.mountPoint = MakeTempDir() self.mountPoint = fuse.MakeTempDir()
self.mountFile = path.Join(self.mountPoint, name) self.mountFile = path.Join(self.mountPoint, name)
self.mountSubdir = path.Join(self.mountPoint, subdir) self.mountSubdir = path.Join(self.mountPoint, subdir)
...@@ -68,9 +69,9 @@ func (self *testCase) Setup(t *testing.T) { ...@@ -68,9 +69,9 @@ func (self *testCase) Setup(t *testing.T) {
self.origSubdir = path.Join(self.origDir, subdir) self.origSubdir = path.Join(self.origDir, subdir)
self.origSubfile = path.Join(self.origSubdir, "subfile") self.origSubfile = path.Join(self.origSubdir, "subfile")
fs := NewPathFileSystemConnector(NewPassThroughFuse(self.origDir)) fs := fuse.NewPathFileSystemConnector(NewPassThroughFuse(self.origDir))
self.state = NewMountState(fs) self.state = fuse.NewMountState(fs)
self.state.Mount(self.mountPoint, false) self.state.Mount(self.mountPoint, false)
//self.state.Debug = false //self.state.Debug = false
......
# Use "gomake install" to build and install this package. # Use "gomake install" to build and install this package.
include $(GOROOT)/src/Make.inc include $(GOROOT)/src/Make.inc
#TARG=github.com/krasin/go-fuse-zip/fuse TARG=github.com/hanwen/go-fuse/fuse
TARG=fuse #TARG=fuse
GOFILES=misc.go\ GOFILES=misc.go\
fuse.go\ fuse.go\
mount.go\ mount.go\
types.go\ types.go\
dummyfuse.go\
pathfilesystem.go \ pathfilesystem.go \
passthrough.go\
include $(GOROOT)/src/Make.pkg include $(GOROOT)/src/Make.pkg
package fuse
// Declare dummy methods, for cut & paste convenience.
type DummyFuse struct{}
func (fs *DummyFuse) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
return new(InitOut), OK
}
func (fs *DummyFuse) Destroy(h *InHeader, input *InitIn) {
}
func (fs *DummyFuse) Lookup(h *InHeader, name string) (out *EntryOut, code Status) {
return nil, ENOSYS
}
func (fs *DummyFuse) Forget(h *InHeader, input *ForgetIn) {
}
func (fs *DummyFuse) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) {
return nil, ENOSYS
}
func (fs *DummyFuse) Open(header *InHeader, input *OpenIn) (flags uint32, fuseFile RawFuseFile, status Status) {
return 0, nil, OK
}
func (self *DummyFuse) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) Readlink(header *InHeader) (out []byte, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) {
return new(EntryOut), ENOSYS
}
func (self *DummyFuse) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) Unlink(header *InHeader, name string) (code Status) {
return ENOSYS
}
func (self *DummyFuse) Rmdir(header *InHeader, name string) (code Status) {
return ENOSYS
}
func (self *DummyFuse) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) {
return ENOSYS
}
func (self *DummyFuse) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) SetXAttr(header *InHeader, input *SetXAttrIn) Status {
return ENOSYS
}
func (self *DummyFuse) GetXAttr(header *InHeader, input *GetXAttrIn) (out *GetXAttrOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) Access(header *InHeader, input *AccessIn) (code Status) {
return ENOSYS
}
func (self *DummyFuse) Create(header *InHeader, input *CreateIn, name string) (flags uint32, fuseFile RawFuseFile, out *EntryOut, code Status) {
return 0, nil, nil, ENOSYS
}
func (self *DummyFuse) Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) {
return nil, ENOSYS
}
func (self *DummyFuse) OpenDir(header *InHeader, input *OpenIn) (flags uint32, fuseFile RawFuseDir, status Status) {
return 0, nil, ENOSYS
}
////////////////////////////////////////////////////////////////
// DummyFuseFile
type DummyFuseFile struct{}
func (self *DummyFuseFile) Read(*ReadIn) ([]byte, Status) {
return []byte(""), ENOSYS
}
func (self *DummyFuseFile) Write(*WriteIn, []byte) (uint32, Status) {
return 0, ENOSYS
}
func (self *DummyFuseFile) Flush() {
}
func (self *DummyFuseFile) Release() {
}
func (self *DummyFuseFile) Fsync(*FsyncIn) (code Status) {
return ENOSYS
}
func (self *DummyFuseFile) ReadDir(input *ReadIn) (*DirEntryList, Status) {
return nil, ENOSYS
}
func (self *DummyFuseFile) ReleaseDir() {
}
func (self *DummyFuseFile) FsyncDir(input *FsyncIn) (code Status) {
return ENOSYS
}
////////////////////////////////////////////////////////////////
// DummyPathFuse
type DummyPathFuse struct{}
func (self *DummyPathFuse) GetAttr(name string) (*Attr, Status) {
return nil, ENOSYS
}
func (self *DummyPathFuse) Readlink(name string) (string, Status) {
return "", ENOSYS
}
func (self *DummyPathFuse) Mknod(name string, mode uint32, dev uint32) Status {
return ENOSYS
}
func (self *DummyPathFuse) Mkdir(name string, mode uint32) Status {
return ENOSYS
}
func (self *DummyPathFuse) Unlink(name string) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Rmdir(name string) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Symlink(value string, linkName string) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Rename(oldName string, newName string) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Link(oldName string, newName string) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Chmod(name string, mode uint32) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Chown(name string, uid uint32, gid uint32) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Truncate(name string, offset uint64) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Open(name string, flags uint32) (file RawFuseFile, code Status) {
return nil, ENOSYS
}
func (self *DummyPathFuse) OpenDir(name string) (dir RawFuseDir, code Status) {
return nil, ENOSYS
}
func (self *DummyPathFuse) Init() (*InitOut, Status) {
return nil, ENOSYS
}
func (self *DummyPathFuse) Destroy() {
}
func (self *DummyPathFuse) Access(name string, mode uint32) (code Status) {
return ENOSYS
}
func (self *DummyPathFuse) Create(name string, flags uint32, mode uint32) (file RawFuseFile, code Status) {
return nil, ENOSYS
}
func (self *DummyPathFuse) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
return ENOSYS
}
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