Commit 75c95c33 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Move InHeader to raw. Drop opcode type.

parent 06ca7ac3
...@@ -249,51 +249,51 @@ type DefaultFile struct{} ...@@ -249,51 +249,51 @@ type DefaultFile struct{}
// //
// Include DefaultRawFileSystem to inherit a null implementation. // Include DefaultRawFileSystem to inherit a null implementation.
type RawFileSystem interface { type RawFileSystem interface {
Lookup(header *InHeader, name string) (out *raw.EntryOut, status Status) Lookup(header *raw.InHeader, name string) (out *raw.EntryOut, status Status)
Forget(nodeid, nlookup uint64) Forget(nodeid, nlookup uint64)
// Attributes. // Attributes.
GetAttr(header *InHeader, input *raw.GetAttrIn) (out *raw.AttrOut, code Status) GetAttr(header *raw.InHeader, input *raw.GetAttrIn) (out *raw.AttrOut, code Status)
SetAttr(header *InHeader, input *raw.SetAttrIn) (out *raw.AttrOut, code Status) SetAttr(header *raw.InHeader, input *raw.SetAttrIn) (out *raw.AttrOut, code Status)
// Modifying structure. // Modifying structure.
Mknod(header *InHeader, input *raw.MknodIn, name string) (out *raw.EntryOut, code Status) Mknod(header *raw.InHeader, input *raw.MknodIn, name string) (out *raw.EntryOut, code Status)
Mkdir(header *InHeader, input *raw.MkdirIn, name string) (out *raw.EntryOut, code Status) Mkdir(header *raw.InHeader, input *raw.MkdirIn, name string) (out *raw.EntryOut, code Status)
Unlink(header *InHeader, name string) (code Status) Unlink(header *raw.InHeader, name string) (code Status)
Rmdir(header *InHeader, name string) (code Status) Rmdir(header *raw.InHeader, name string) (code Status)
Rename(header *InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status)
Link(header *InHeader, input *raw.LinkIn, filename string) (out *raw.EntryOut, code Status) Link(header *raw.InHeader, input *raw.LinkIn, filename string) (out *raw.EntryOut, code Status)
Symlink(header *InHeader, pointedTo string, linkName string) (out *raw.EntryOut, code Status) Symlink(header *raw.InHeader, pointedTo string, linkName string) (out *raw.EntryOut, code Status)
Readlink(header *InHeader) (out []byte, code Status) Readlink(header *raw.InHeader) (out []byte, code Status)
Access(header *InHeader, input *raw.AccessIn) (code Status) Access(header *raw.InHeader, input *raw.AccessIn) (code Status)
// Extended attributes. // Extended attributes.
GetXAttrSize(header *InHeader, attr string) (sz int, code Status) GetXAttrSize(header *raw.InHeader, attr string) (sz int, code Status)
GetXAttrData(header *InHeader, attr string) (data []byte, code Status) GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status)
ListXAttr(header *InHeader) (attributes []byte, code Status) ListXAttr(header *raw.InHeader) (attributes []byte, code Status)
SetXAttr(header *InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status
RemoveXAttr(header *InHeader, attr string) (code Status) RemoveXAttr(header *raw.InHeader, attr string) (code Status)
// File handling. // File handling.
Create(header *InHeader, input *raw.CreateIn, name string) (flags uint32, handle uint64, out *raw.EntryOut, code Status) Create(header *raw.InHeader, input *raw.CreateIn, name string) (flags uint32, handle uint64, out *raw.EntryOut, code Status)
Open(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) Open(header *raw.InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status)
Read(*InHeader, *ReadIn, BufferPool) ([]byte, Status) Read(*raw.InHeader, *ReadIn, BufferPool) ([]byte, Status)
Release(header *InHeader, input *raw.ReleaseIn) Release(header *raw.InHeader, input *raw.ReleaseIn)
Write(*InHeader, *WriteIn, []byte) (written uint32, code Status) Write(*raw.InHeader, *WriteIn, []byte) (written uint32, code Status)
Flush(header *InHeader, input *raw.FlushIn) Status Flush(header *raw.InHeader, input *raw.FlushIn) Status
Fsync(*InHeader, *raw.FsyncIn) (code Status) Fsync(*raw.InHeader, *raw.FsyncIn) (code Status)
// Directory handling // Directory handling
OpenDir(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) OpenDir(header *raw.InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status)
ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) ReadDir(header *raw.InHeader, input *ReadIn) (*DirEntryList, Status)
ReleaseDir(header *InHeader, input *raw.ReleaseIn) ReleaseDir(header *raw.InHeader, input *raw.ReleaseIn)
FsyncDir(header *InHeader, input *raw.FsyncIn) (code Status) FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status)
// //
Ioctl(header *InHeader, input *raw.IoctlIn) (output *raw.IoctlOut, data []byte, code Status) Ioctl(header *raw.InHeader, input *raw.IoctlIn) (output *raw.IoctlOut, data []byte, code Status)
StatFs(header *InHeader) *StatfsOut StatFs(header *raw.InHeader) *StatfsOut
// Provide callbacks for pushing notifications to the kernel. // Provide callbacks for pushing notifications to the kernel.
Init(params *RawFsInit) Init(params *RawFsInit)
......
...@@ -7,131 +7,131 @@ import ( ...@@ -7,131 +7,131 @@ import (
func (me *DefaultRawFileSystem) Init(init *RawFsInit) { func (me *DefaultRawFileSystem) Init(init *RawFsInit) {
} }
func (me *DefaultRawFileSystem) StatFs(h *InHeader) *StatfsOut { func (me *DefaultRawFileSystem) StatFs(h *raw.InHeader) *StatfsOut {
return nil return nil
} }
func (me *DefaultRawFileSystem) Lookup(h *InHeader, name string) (out *raw.EntryOut, code Status) { func (me *DefaultRawFileSystem) Lookup(h *raw.InHeader, name string) (out *raw.EntryOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Forget(nodeID, nlookup uint64) { func (me *DefaultRawFileSystem) Forget(nodeID, nlookup uint64) {
} }
func (me *DefaultRawFileSystem) GetAttr(header *InHeader, input *raw.GetAttrIn) (out *raw.AttrOut, code Status) { func (me *DefaultRawFileSystem) GetAttr(header *raw.InHeader, input *raw.GetAttrIn) (out *raw.AttrOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Open(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) { func (me *DefaultRawFileSystem) Open(header *raw.InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) {
return 0, 0, OK return 0, 0, OK
} }
func (me *DefaultRawFileSystem) SetAttr(header *InHeader, input *raw.SetAttrIn) (out *raw.AttrOut, code Status) { func (me *DefaultRawFileSystem) SetAttr(header *raw.InHeader, input *raw.SetAttrIn) (out *raw.AttrOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { func (me *DefaultRawFileSystem) Readlink(header *raw.InHeader) (out []byte, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Mknod(header *InHeader, input *raw.MknodIn, name string) (out *raw.EntryOut, code Status) { func (me *DefaultRawFileSystem) Mknod(header *raw.InHeader, input *raw.MknodIn, name string) (out *raw.EntryOut, code Status) {
return new(raw.EntryOut), ENOSYS return new(raw.EntryOut), ENOSYS
} }
func (me *DefaultRawFileSystem) Mkdir(header *InHeader, input *raw.MkdirIn, name string) (out *raw.EntryOut, code Status) { func (me *DefaultRawFileSystem) Mkdir(header *raw.InHeader, input *raw.MkdirIn, name string) (out *raw.EntryOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Unlink(header *InHeader, name string) (code Status) { func (me *DefaultRawFileSystem) Unlink(header *raw.InHeader, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { func (me *DefaultRawFileSystem) Rmdir(header *raw.InHeader, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *raw.EntryOut, code Status) { func (me *DefaultRawFileSystem) Symlink(header *raw.InHeader, pointedTo string, linkName string) (out *raw.EntryOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Rename(header *InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) { func (me *DefaultRawFileSystem) Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) Link(header *InHeader, input *raw.LinkIn, name string) (out *raw.EntryOut, code Status) { func (me *DefaultRawFileSystem) Link(header *raw.InHeader, input *raw.LinkIn, name string) (out *raw.EntryOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) GetXAttrSize(header *InHeader, attr string) (size int, code Status) { func (me *DefaultRawFileSystem) GetXAttrSize(header *raw.InHeader, attr string) (size int, code Status) {
return 0, ENOSYS return 0, ENOSYS
} }
func (me *DefaultRawFileSystem) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { func (me *DefaultRawFileSystem) GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) SetXAttr(header *InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status { func (me *DefaultRawFileSystem) SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { func (me *DefaultRawFileSystem) ListXAttr(header *raw.InHeader) (data []byte, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { func (me *DefaultRawFileSystem) RemoveXAttr(header *raw.InHeader, attr string) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) Access(header *InHeader, input *raw.AccessIn) (code Status) { func (me *DefaultRawFileSystem) Access(header *raw.InHeader, input *raw.AccessIn) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) Create(header *InHeader, input *raw.CreateIn, name string) (flags uint32, handle uint64, out *raw.EntryOut, code Status) { func (me *DefaultRawFileSystem) Create(header *raw.InHeader, input *raw.CreateIn, name string) (flags uint32, handle uint64, out *raw.EntryOut, code Status) {
return 0, 0, nil, ENOSYS return 0, 0, nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Bmap(header *InHeader, input *raw.BmapIn) (out *raw.BmapOut, code Status) { func (me *DefaultRawFileSystem) Bmap(header *raw.InHeader, input *raw.BmapIn) (out *raw.BmapOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Poll(header *InHeader, input *raw.PollIn) (out *raw.PollOut, code Status) { func (me *DefaultRawFileSystem) Poll(header *raw.InHeader, input *raw.PollIn) (out *raw.PollOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) OpenDir(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) { func (me *DefaultRawFileSystem) OpenDir(header *raw.InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) {
return 0, 0, ENOSYS return 0, 0, ENOSYS
} }
func (me *DefaultRawFileSystem) Read(header *InHeader, input *ReadIn, bp BufferPool) ([]byte, Status) { func (me *DefaultRawFileSystem) Read(header *raw.InHeader, input *ReadIn, bp BufferPool) ([]byte, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Release(header *InHeader, input *raw.ReleaseIn) { func (me *DefaultRawFileSystem) Release(header *raw.InHeader, input *raw.ReleaseIn) {
} }
func (me *DefaultRawFileSystem) Write(header *InHeader, input *WriteIn, data []byte) (written uint32, code Status) { func (me *DefaultRawFileSystem) Write(header *raw.InHeader, input *WriteIn, data []byte) (written uint32, code Status) {
return 0, ENOSYS return 0, ENOSYS
} }
func (me *DefaultRawFileSystem) Flush(header *InHeader, input *raw.FlushIn) Status { func (me *DefaultRawFileSystem) Flush(header *raw.InHeader, input *raw.FlushIn) Status {
return OK return OK
} }
func (me *DefaultRawFileSystem) Fsync(header *InHeader, input *raw.FsyncIn) (code Status) { func (me *DefaultRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) { func (me *DefaultRawFileSystem) ReadDir(header *raw.InHeader, input *ReadIn) (*DirEntryList, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) ReleaseDir(header *InHeader, input *raw.ReleaseIn) { func (me *DefaultRawFileSystem) ReleaseDir(header *raw.InHeader, input *raw.ReleaseIn) {
} }
func (me *DefaultRawFileSystem) FsyncDir(header *InHeader, input *raw.FsyncIn) (code Status) { func (me *DefaultRawFileSystem) FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultRawFileSystem) Ioctl(header *InHeader, input *raw.IoctlIn) (output *raw.IoctlOut, data []byte, code Status) { func (me *DefaultRawFileSystem) Ioctl(header *raw.InHeader, input *raw.IoctlIn) (output *raw.IoctlOut, data []byte, code Status) {
return nil, nil, ENOSYS return nil, nil, ENOSYS
} }
...@@ -6,6 +6,8 @@ import ( ...@@ -6,6 +6,8 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"unsafe" "unsafe"
"github.com/hanwen/go-fuse/raw"
) )
var _ = fmt.Print var _ = fmt.Print
...@@ -31,7 +33,7 @@ func (me *DirEntryList) AddString(name string, inode uint64, mode uint32) bool { ...@@ -31,7 +33,7 @@ func (me *DirEntryList) AddString(name string, inode uint64, mode uint32) bool {
} }
func (me *DirEntryList) AddDirEntry(e DirEntry) bool { func (me *DirEntryList) AddDirEntry(e DirEntry) bool {
return me.Add([]byte(e.Name), uint64(FUSE_UNKNOWN_INO), e.Mode) return me.Add([]byte(e.Name), uint64(raw.FUSE_UNKNOWN_INO), e.Mode)
} }
func (me *DirEntryList) Add(name []byte, inode uint64, mode uint32) bool { func (me *DirEntryList) Add(name []byte, inode uint64, mode uint32) bool {
......
...@@ -103,7 +103,7 @@ func (me *FileSystemConnector) findMount(parent *Inode, name string) (mount *fil ...@@ -103,7 +103,7 @@ func (me *FileSystemConnector) findMount(parent *Inode, name string) (mount *fil
} }
func (me *FileSystemConnector) toInode(nodeid uint64) *Inode { func (me *FileSystemConnector) toInode(nodeid uint64) *Inode {
if nodeid == FUSE_ROOT_ID { if nodeid == raw.FUSE_ROOT_ID {
return me.rootNode return me.rootNode
} }
i := (*Inode)(unsafe.Pointer(me.inodeMap.Decode(nodeid))) i := (*Inode)(unsafe.Pointer(me.inodeMap.Decode(nodeid)))
...@@ -333,7 +333,7 @@ func (me *FileSystemConnector) Unmount(node *Inode) Status { ...@@ -333,7 +333,7 @@ func (me *FileSystemConnector) Unmount(node *Inode) Status {
func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) Status { func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) Status {
n := node.nodeId n := node.nodeId
if node == me.rootNode { if node == me.rootNode {
n = FUSE_ROOT_ID n = raw.FUSE_ROOT_ID
} }
if n == 0 { if n == 0 {
return OK return OK
...@@ -349,7 +349,7 @@ func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) ...@@ -349,7 +349,7 @@ func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64)
func (me *FileSystemConnector) EntryNotify(dir *Inode, name string) Status { func (me *FileSystemConnector) EntryNotify(dir *Inode, name string) Status {
n := dir.nodeId n := dir.nodeId
if dir == me.rootNode { if dir == me.rootNode {
n = FUSE_ROOT_ID n = raw.FUSE_ROOT_ID
} }
if n == 0 { if n == 0 {
return OK return OK
......
This diff is collapsed.
...@@ -160,7 +160,7 @@ func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem { ...@@ -160,7 +160,7 @@ func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem {
return l return l
} }
func (me *LockingRawFileSystem) Lookup(h *InHeader, name string) (out *raw.EntryOut, code Status) { func (me *LockingRawFileSystem) Lookup(h *raw.InHeader, name string) (out *raw.EntryOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Lookup(h, name) return me.RawFileSystem.Lookup(h, name)
} }
...@@ -170,137 +170,137 @@ func (me *LockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) { ...@@ -170,137 +170,137 @@ func (me *LockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) {
me.RawFileSystem.Forget(nodeID, nlookup) me.RawFileSystem.Forget(nodeID, nlookup)
} }
func (me *LockingRawFileSystem) GetAttr(header *InHeader, input *raw.GetAttrIn) (out *raw.AttrOut, code Status) { func (me *LockingRawFileSystem) GetAttr(header *raw.InHeader, input *raw.GetAttrIn) (out *raw.AttrOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.GetAttr(header, input) return me.RawFileSystem.GetAttr(header, input)
} }
func (me *LockingRawFileSystem) Open(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) { func (me *LockingRawFileSystem) Open(header *raw.InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Open(header, input) return me.RawFileSystem.Open(header, input)
} }
func (me *LockingRawFileSystem) SetAttr(header *InHeader, input *raw.SetAttrIn) (out *raw.AttrOut, code Status) { func (me *LockingRawFileSystem) SetAttr(header *raw.InHeader, input *raw.SetAttrIn) (out *raw.AttrOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.SetAttr(header, input) return me.RawFileSystem.SetAttr(header, input)
} }
func (me *LockingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { func (me *LockingRawFileSystem) Readlink(header *raw.InHeader) (out []byte, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Readlink(header) return me.RawFileSystem.Readlink(header)
} }
func (me *LockingRawFileSystem) Mknod(header *InHeader, input *raw.MknodIn, name string) (out *raw.EntryOut, code Status) { func (me *LockingRawFileSystem) Mknod(header *raw.InHeader, input *raw.MknodIn, name string) (out *raw.EntryOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Mknod(header, input, name) return me.RawFileSystem.Mknod(header, input, name)
} }
func (me *LockingRawFileSystem) Mkdir(header *InHeader, input *raw.MkdirIn, name string) (out *raw.EntryOut, code Status) { func (me *LockingRawFileSystem) Mkdir(header *raw.InHeader, input *raw.MkdirIn, name string) (out *raw.EntryOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Mkdir(header, input, name) return me.RawFileSystem.Mkdir(header, input, name)
} }
func (me *LockingRawFileSystem) Unlink(header *InHeader, name string) (code Status) { func (me *LockingRawFileSystem) Unlink(header *raw.InHeader, name string) (code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Unlink(header, name) return me.RawFileSystem.Unlink(header, name)
} }
func (me *LockingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { func (me *LockingRawFileSystem) Rmdir(header *raw.InHeader, name string) (code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Rmdir(header, name) return me.RawFileSystem.Rmdir(header, name)
} }
func (me *LockingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *raw.EntryOut, code Status) { func (me *LockingRawFileSystem) Symlink(header *raw.InHeader, pointedTo string, linkName string) (out *raw.EntryOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Symlink(header, pointedTo, linkName) return me.RawFileSystem.Symlink(header, pointedTo, linkName)
} }
func (me *LockingRawFileSystem) Rename(header *InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) { func (me *LockingRawFileSystem) Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Rename(header, input, oldName, newName) return me.RawFileSystem.Rename(header, input, oldName, newName)
} }
func (me *LockingRawFileSystem) Link(header *InHeader, input *raw.LinkIn, name string) (out *raw.EntryOut, code Status) { func (me *LockingRawFileSystem) Link(header *raw.InHeader, input *raw.LinkIn, name string) (out *raw.EntryOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Link(header, input, name) return me.RawFileSystem.Link(header, input, name)
} }
func (me *LockingRawFileSystem) SetXAttr(header *InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status { func (me *LockingRawFileSystem) SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.SetXAttr(header, input, attr, data) return me.RawFileSystem.SetXAttr(header, input, attr, data)
} }
func (me *LockingRawFileSystem) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) { func (me *LockingRawFileSystem) GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.GetXAttrData(header, attr) return me.RawFileSystem.GetXAttrData(header, attr)
} }
func (me *LockingRawFileSystem) GetXAttrSize(header *InHeader, attr string) (sz int, code Status) { func (me *LockingRawFileSystem) GetXAttrSize(header *raw.InHeader, attr string) (sz int, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.GetXAttrSize(header, attr) return me.RawFileSystem.GetXAttrSize(header, attr)
} }
func (me *LockingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { func (me *LockingRawFileSystem) ListXAttr(header *raw.InHeader) (data []byte, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.ListXAttr(header) return me.RawFileSystem.ListXAttr(header)
} }
func (me *LockingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { func (me *LockingRawFileSystem) RemoveXAttr(header *raw.InHeader, attr string) Status {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.RemoveXAttr(header, attr) return me.RawFileSystem.RemoveXAttr(header, attr)
} }
func (me *LockingRawFileSystem) Access(header *InHeader, input *raw.AccessIn) (code Status) { func (me *LockingRawFileSystem) Access(header *raw.InHeader, input *raw.AccessIn) (code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Access(header, input) return me.RawFileSystem.Access(header, input)
} }
func (me *LockingRawFileSystem) Create(header *InHeader, input *raw.CreateIn, name string) (flags uint32, handle uint64, out *raw.EntryOut, code Status) { func (me *LockingRawFileSystem) Create(header *raw.InHeader, input *raw.CreateIn, name string) (flags uint32, handle uint64, out *raw.EntryOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Create(header, input, name) return me.RawFileSystem.Create(header, input, name)
} }
func (me *LockingRawFileSystem) OpenDir(header *InHeader, input *raw.OpenIn) (flags uint32, h uint64, status Status) { func (me *LockingRawFileSystem) OpenDir(header *raw.InHeader, input *raw.OpenIn) (flags uint32, h uint64, status Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.OpenDir(header, input) return me.RawFileSystem.OpenDir(header, input)
} }
func (me *LockingRawFileSystem) Release(header *InHeader, input *raw.ReleaseIn) { func (me *LockingRawFileSystem) Release(header *raw.InHeader, input *raw.ReleaseIn) {
defer me.locked()() defer me.locked()()
me.RawFileSystem.Release(header, input) me.RawFileSystem.Release(header, input)
} }
func (me *LockingRawFileSystem) ReleaseDir(header *InHeader, h *raw.ReleaseIn) { func (me *LockingRawFileSystem) ReleaseDir(header *raw.InHeader, h *raw.ReleaseIn) {
defer me.locked()() defer me.locked()()
me.RawFileSystem.ReleaseDir(header, h) me.RawFileSystem.ReleaseDir(header, h)
} }
func (me *LockingRawFileSystem) Read(header *InHeader, input *ReadIn, bp BufferPool) ([]byte, Status) { func (me *LockingRawFileSystem) Read(header *raw.InHeader, input *ReadIn, bp BufferPool) ([]byte, Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Read(header, input, bp) return me.RawFileSystem.Read(header, input, bp)
} }
func (me *LockingRawFileSystem) Write(header *InHeader, input *WriteIn, data []byte) (written uint32, code Status) { func (me *LockingRawFileSystem) Write(header *raw.InHeader, input *WriteIn, data []byte) (written uint32, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Write(header, input, data) return me.RawFileSystem.Write(header, input, data)
} }
func (me *LockingRawFileSystem) Flush(header *InHeader, input *raw.FlushIn) Status { func (me *LockingRawFileSystem) Flush(header *raw.InHeader, input *raw.FlushIn) Status {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Flush(header, input) return me.RawFileSystem.Flush(header, input)
} }
func (me *LockingRawFileSystem) Fsync(header *InHeader, input *raw.FsyncIn) (code Status) { func (me *LockingRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn) (code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.Fsync(header, input) return me.RawFileSystem.Fsync(header, input)
} }
func (me *LockingRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) { func (me *LockingRawFileSystem) ReadDir(header *raw.InHeader, input *ReadIn) (*DirEntryList, Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.ReadDir(header, input) return me.RawFileSystem.ReadDir(header, input)
} }
func (me *LockingRawFileSystem) FsyncDir(header *InHeader, input *raw.FsyncIn) (code Status) { func (me *LockingRawFileSystem) FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.FsyncDir(header, input) return me.RawFileSystem.FsyncDir(header, input)
} }
...@@ -166,7 +166,7 @@ func (me *MountState) recordStats(req *request) { ...@@ -166,7 +166,7 @@ func (me *MountState) recordStats(req *request) {
endNs := time.Now().UnixNano() endNs := time.Now().UnixNano()
dt := endNs - req.startNs dt := endNs - req.startNs
opname := operationName(req.inHeader.opcode) opname := operationName(req.inHeader.Opcode)
me.latencies.AddMany( me.latencies.AddMany(
[]LatencyArg{ []LatencyArg{
{opname, "", dt}, {opname, "", dt},
...@@ -234,7 +234,7 @@ func (me *MountState) handleRequest(req *request) { ...@@ -234,7 +234,7 @@ func (me *MountState) handleRequest(req *request) {
} }
if req.status.Ok() && req.handler.Func == nil { if req.status.Ok() && req.handler.Func == nil {
log.Printf("Unimplemented opcode %v", req.inHeader.opcode) log.Printf("Unimplemented opcode %v", operationName(req.inHeader.Opcode))
req.status = ENOSYS req.status = ENOSYS
} }
...@@ -245,13 +245,13 @@ func (me *MountState) handleRequest(req *request) { ...@@ -245,13 +245,13 @@ func (me *MountState) handleRequest(req *request) {
errNo := me.write(req) errNo := me.write(req)
if errNo != 0 { if errNo != 0 {
log.Printf("writer: Write/Writev %v failed, err: %v. opcode: %v", log.Printf("writer: Write/Writev %v failed, err: %v. opcode: %v",
req.outHeaderBytes, errNo, operationName(req.inHeader.opcode)) req.outHeaderBytes, errNo, operationName(req.inHeader.Opcode))
} }
} }
func (me *MountState) write(req *request) Status { func (me *MountState) write(req *request) Status {
// Forget does not wait for reply. // Forget does not wait for reply.
if req.inHeader.opcode == _OP_FORGET || req.inHeader.opcode == _OP_BATCH_FORGET { if req.inHeader.Opcode == _OP_FORGET || req.inHeader.Opcode == _OP_BATCH_FORGET {
return OK return OK
} }
...@@ -281,8 +281,8 @@ func (me *MountState) write(req *request) Status { ...@@ -281,8 +281,8 @@ func (me *MountState) write(req *request) Status {
func (me *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status { func (me *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status {
req := request{ req := request{
inHeader: &InHeader{ inHeader: &raw.InHeader{
opcode: _OP_NOTIFY_INODE, Opcode: _OP_NOTIFY_INODE,
}, },
handler: operationHandlers[_OP_NOTIFY_INODE], handler: operationHandlers[_OP_NOTIFY_INODE],
status: raw.NOTIFY_INVAL_INODE, status: raw.NOTIFY_INVAL_INODE,
...@@ -299,8 +299,8 @@ func (me *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status { ...@@ -299,8 +299,8 @@ func (me *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status {
func (me *MountState) writeEntryNotify(parent uint64, name string) Status { func (me *MountState) writeEntryNotify(parent uint64, name string) Status {
req := request{ req := request{
inHeader: &InHeader{ inHeader: &raw.InHeader{
opcode: _OP_NOTIFY_ENTRY, Opcode: _OP_NOTIFY_ENTRY,
}, },
handler: operationHandlers[_OP_NOTIFY_ENTRY], handler: operationHandlers[_OP_NOTIFY_ENTRY],
status: raw.NOTIFY_INVAL_ENTRY, status: raw.NOTIFY_INVAL_ENTRY,
......
...@@ -13,55 +13,53 @@ import ( ...@@ -13,55 +13,53 @@ import (
var _ = log.Printf var _ = log.Printf
var _ = fmt.Printf var _ = fmt.Printf
type opcode int
const ( const (
_OP_LOOKUP = opcode(1) _OP_LOOKUP = int32(1)
_OP_FORGET = opcode(2) _OP_FORGET = int32(2)
_OP_GETATTR = opcode(3) _OP_GETATTR = int32(3)
_OP_SETATTR = opcode(4) _OP_SETATTR = int32(4)
_OP_READLINK = opcode(5) _OP_READLINK = int32(5)
_OP_SYMLINK = opcode(6) _OP_SYMLINK = int32(6)
_OP_MKNOD = opcode(8) _OP_MKNOD = int32(8)
_OP_MKDIR = opcode(9) _OP_MKDIR = int32(9)
_OP_UNLINK = opcode(10) _OP_UNLINK = int32(10)
_OP_RMDIR = opcode(11) _OP_RMDIR = int32(11)
_OP_RENAME = opcode(12) _OP_RENAME = int32(12)
_OP_LINK = opcode(13) _OP_LINK = int32(13)
_OP_OPEN = opcode(14) _OP_OPEN = int32(14)
_OP_READ = opcode(15) _OP_READ = int32(15)
_OP_WRITE = opcode(16) _OP_WRITE = int32(16)
_OP_STATFS = opcode(17) _OP_STATFS = int32(17)
_OP_RELEASE = opcode(18) _OP_RELEASE = int32(18)
_OP_FSYNC = opcode(20) _OP_FSYNC = int32(20)
_OP_SETXATTR = opcode(21) _OP_SETXATTR = int32(21)
_OP_GETXATTR = opcode(22) _OP_GETXATTR = int32(22)
_OP_LISTXATTR = opcode(23) _OP_LISTXATTR = int32(23)
_OP_REMOVEXATTR = opcode(24) _OP_REMOVEXATTR = int32(24)
_OP_FLUSH = opcode(25) _OP_FLUSH = int32(25)
_OP_INIT = opcode(26) _OP_INIT = int32(26)
_OP_OPENDIR = opcode(27) _OP_OPENDIR = int32(27)
_OP_READDIR = opcode(28) _OP_READDIR = int32(28)
_OP_RELEASEDIR = opcode(29) _OP_RELEASEDIR = int32(29)
_OP_FSYNCDIR = opcode(30) _OP_FSYNCDIR = int32(30)
_OP_GETLK = opcode(31) _OP_GETLK = int32(31)
_OP_SETLK = opcode(32) _OP_SETLK = int32(32)
_OP_SETLKW = opcode(33) _OP_SETLKW = int32(33)
_OP_ACCESS = opcode(34) _OP_ACCESS = int32(34)
_OP_CREATE = opcode(35) _OP_CREATE = int32(35)
_OP_INTERRUPT = opcode(36) _OP_INTERRUPT = int32(36)
_OP_BMAP = opcode(37) _OP_BMAP = int32(37)
_OP_DESTROY = opcode(38) _OP_DESTROY = int32(38)
_OP_IOCTL = opcode(39) _OP_IOCTL = int32(39)
_OP_POLL = opcode(40) _OP_POLL = int32(40)
_OP_NOTIFY_REPLY = opcode(41) _OP_NOTIFY_REPLY = int32(41)
_OP_BATCH_FORGET = opcode(42) _OP_BATCH_FORGET = int32(42)
// Ugh - what will happen if FUSE introduces a new opcode here? // Ugh - what will happen if FUSE introduces a new opcode here?
_OP_NOTIFY_ENTRY = opcode(51) _OP_NOTIFY_ENTRY = int32(51)
_OP_NOTIFY_INODE = opcode(52) _OP_NOTIFY_INODE = int32(52)
_OPCODE_COUNT = opcode(53) _OPCODE_COUNT = int32(53)
) )
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -172,7 +170,7 @@ const _SECURITY_ACL = "system.posix_acl_access" ...@@ -172,7 +170,7 @@ const _SECURITY_ACL = "system.posix_acl_access"
const _SECURITY_ACL_DEFAULT = "system.posix_acl_default" const _SECURITY_ACL_DEFAULT = "system.posix_acl_default"
func doGetXAttr(state *MountState, req *request) { func doGetXAttr(state *MountState, req *request) {
if state.opts.IgnoreSecurityLabels && req.inHeader.opcode == _OP_GETXATTR { if state.opts.IgnoreSecurityLabels && req.inHeader.Opcode == _OP_GETXATTR {
fn := req.filenames[0] fn := req.filenames[0]
if fn == _SECURITY_CAPABILITY || fn == _SECURITY_ACL_DEFAULT || if fn == _SECURITY_CAPABILITY || fn == _SECURITY_ACL_DEFAULT ||
fn == _SECURITY_ACL { fn == _SECURITY_ACL {
...@@ -184,7 +182,7 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -184,7 +182,7 @@ func doGetXAttr(state *MountState, req *request) {
input := (*raw.GetXAttrIn)(req.inData) input := (*raw.GetXAttrIn)(req.inData)
var data []byte var data []byte
switch { switch {
case req.inHeader.opcode == _OP_GETXATTR && input.Size == 0: case req.inHeader.Opcode == _OP_GETXATTR && input.Size == 0:
sz, code := state.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0]) sz, code := state.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0])
if code.Ok() { if code.Ok() {
out := &raw.GetXAttrOut{ out := &raw.GetXAttrOut{
...@@ -195,7 +193,7 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -195,7 +193,7 @@ func doGetXAttr(state *MountState, req *request) {
return return
} }
req.status = code req.status = code
case req.inHeader.opcode == _OP_GETXATTR: case req.inHeader.Opcode == _OP_GETXATTR:
data, req.status = state.fileSystem.GetXAttrData(req.inHeader, req.filenames[0]) data, req.status = state.fileSystem.GetXAttrData(req.inHeader, req.filenames[0])
default: default:
data, req.status = state.fileSystem.ListXAttr(req.inHeader) data, req.status = state.fileSystem.ListXAttr(req.inHeader)
...@@ -357,7 +355,7 @@ type operationHandler struct { ...@@ -357,7 +355,7 @@ type operationHandler struct {
var operationHandlers []*operationHandler var operationHandlers []*operationHandler
func operationName(op opcode) string { func operationName(op int32) string {
h := getHandler(op) h := getHandler(op)
if h == nil { if h == nil {
return "unknown" return "unknown"
...@@ -365,11 +363,7 @@ func operationName(op opcode) string { ...@@ -365,11 +363,7 @@ func operationName(op opcode) string {
return h.Name return h.Name
} }
func (op opcode) String() string { func getHandler(o int32) *operationHandler {
return operationName(op)
}
func getHandler(o opcode) *operationHandler {
if o >= _OPCODE_COUNT { if o >= _OPCODE_COUNT {
return nil return nil
} }
...@@ -382,12 +376,12 @@ func init() { ...@@ -382,12 +376,12 @@ func init() {
operationHandlers[i] = &operationHandler{Name: "UNKNOWN"} operationHandlers[i] = &operationHandler{Name: "UNKNOWN"}
} }
fileOps := []opcode{_OP_READLINK, _OP_NOTIFY_ENTRY} fileOps := []int32{_OP_READLINK, _OP_NOTIFY_ENTRY}
for _, op := range fileOps { for _, op := range fileOps {
operationHandlers[op].FileNameOut = true operationHandlers[op].FileNameOut = true
} }
for op, sz := range map[opcode]uintptr{ for op, sz := range map[int32]uintptr{
_OP_FORGET: unsafe.Sizeof(raw.ForgetIn{}), _OP_FORGET: unsafe.Sizeof(raw.ForgetIn{}),
_OP_BATCH_FORGET: unsafe.Sizeof(raw.BatchForgetIn{}), _OP_BATCH_FORGET: unsafe.Sizeof(raw.BatchForgetIn{}),
_OP_GETATTR: unsafe.Sizeof(raw.GetAttrIn{}), _OP_GETATTR: unsafe.Sizeof(raw.GetAttrIn{}),
...@@ -420,7 +414,7 @@ func init() { ...@@ -420,7 +414,7 @@ func init() {
operationHandlers[op].InputSize = sz operationHandlers[op].InputSize = sz
} }
for op, sz := range map[opcode]uintptr{ for op, sz := range map[int32]uintptr{
_OP_LOOKUP: unsafe.Sizeof(raw.EntryOut{}), _OP_LOOKUP: unsafe.Sizeof(raw.EntryOut{}),
_OP_GETATTR: unsafe.Sizeof(raw.AttrOut{}), _OP_GETATTR: unsafe.Sizeof(raw.AttrOut{}),
_OP_SETATTR: unsafe.Sizeof(raw.AttrOut{}), _OP_SETATTR: unsafe.Sizeof(raw.AttrOut{}),
...@@ -445,7 +439,7 @@ func init() { ...@@ -445,7 +439,7 @@ func init() {
operationHandlers[op].OutputSize = sz operationHandlers[op].OutputSize = sz
} }
for op, v := range map[opcode]string{ for op, v := range map[int32]string{
_OP_LOOKUP: "LOOKUP", _OP_LOOKUP: "LOOKUP",
_OP_FORGET: "FORGET", _OP_FORGET: "FORGET",
_OP_BATCH_FORGET: "BATCH_FORGET", _OP_BATCH_FORGET: "BATCH_FORGET",
...@@ -491,7 +485,7 @@ func init() { ...@@ -491,7 +485,7 @@ func init() {
operationHandlers[op].Name = v operationHandlers[op].Name = v
} }
for op, v := range map[opcode]operationFunc{ for op, v := range map[int32]operationFunc{
_OP_OPEN: doOpen, _OP_OPEN: doOpen,
_OP_READDIR: doReadDir, _OP_READDIR: doReadDir,
_OP_WRITE: doWrite, _OP_WRITE: doWrite,
...@@ -529,7 +523,7 @@ func init() { ...@@ -529,7 +523,7 @@ func init() {
} }
// Outputs. // Outputs.
for op, f := range map[opcode]castPointerFunc{ for op, f := range map[int32]castPointerFunc{
_OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*raw.EntryOut)(ptr) }, _OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*raw.EntryOut)(ptr) },
_OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*raw.OpenOut)(ptr) }, _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*raw.OpenOut)(ptr) },
_OP_OPENDIR: func(ptr unsafe.Pointer) interface{} { return (*raw.OpenOut)(ptr) }, _OP_OPENDIR: func(ptr unsafe.Pointer) interface{} { return (*raw.OpenOut)(ptr) },
...@@ -547,7 +541,7 @@ func init() { ...@@ -547,7 +541,7 @@ func init() {
} }
// Inputs. // Inputs.
for op, f := range map[opcode]castPointerFunc{ for op, f := range map[int32]castPointerFunc{
_OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*raw.FlushIn)(ptr) }, _OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*raw.FlushIn)(ptr) },
_OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.GetAttrIn)(ptr) }, _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.GetAttrIn)(ptr) },
_OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.SetAttrIn)(ptr) }, _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.SetAttrIn)(ptr) },
...@@ -570,7 +564,7 @@ func init() { ...@@ -570,7 +564,7 @@ func init() {
} }
// File name args. // File name args.
for op, count := range map[opcode]int{ for op, count := range map[int32]int{
_OP_CREATE: 1, _OP_CREATE: 1,
_OP_GETXATTR: 1, _OP_GETXATTR: 1,
_OP_LINK: 1, _OP_LINK: 1,
......
...@@ -14,7 +14,7 @@ type request struct { ...@@ -14,7 +14,7 @@ type request struct {
inputBuf []byte inputBuf []byte
// These split up inputBuf. // These split up inputBuf.
inHeader *InHeader // generic header inHeader *raw.InHeader // generic header
inData unsafe.Pointer // per op data inData unsafe.Pointer // per op data
arg []byte // flat data. arg []byte // flat data.
filenames []string // filename arguments filenames []string // filename arguments
...@@ -51,8 +51,8 @@ func (me *request) InputDebug() string { ...@@ -51,8 +51,8 @@ func (me *request) InputDebug() string {
names += fmt.Sprintf(" %d bytes", len(me.arg)) names += fmt.Sprintf(" %d bytes", len(me.arg))
} }
return fmt.Sprintf("Dispatch: %v, NodeId: %v.%v%v", return fmt.Sprintf("Dispatch: %s, NodeId: %v.%v%v",
me.inHeader.opcode, me.inHeader.NodeId, val, names) operationName(me.inHeader.Opcode), me.inHeader.NodeId, val, names)
} }
func (me *request) OutputDebug() string { func (me *request) OutputDebug() string {
...@@ -81,29 +81,29 @@ func (me *request) OutputDebug() string { ...@@ -81,29 +81,29 @@ func (me *request) OutputDebug() string {
} }
} }
return fmt.Sprintf("Serialize: %v code: %v value: %v%v", return fmt.Sprintf("Serialize: %s code: %v value: %v%v",
me.inHeader.opcode, me.status, dataStr, flatStr) operationName(me.inHeader.Opcode), me.status, dataStr, flatStr)
} }
func (me *request) parse() { func (me *request) parse() {
inHSize := int(unsafe.Sizeof(InHeader{})) inHSize := int(unsafe.Sizeof(raw.InHeader{}))
if len(me.inputBuf) < inHSize { if len(me.inputBuf) < inHSize {
log.Printf("Short read for input header: %v", me.inputBuf) log.Printf("Short read for input header: %v", me.inputBuf)
return return
} }
me.inHeader = (*InHeader)(unsafe.Pointer(&me.inputBuf[0])) me.inHeader = (*raw.InHeader)(unsafe.Pointer(&me.inputBuf[0]))
me.arg = me.inputBuf[inHSize:] me.arg = me.inputBuf[inHSize:]
me.handler = getHandler(me.inHeader.opcode) me.handler = getHandler(me.inHeader.Opcode)
if me.handler == nil { if me.handler == nil {
log.Printf("Unknown opcode %v", me.inHeader.opcode) log.Printf("Unknown opcode %d", me.inHeader.Opcode)
me.status = ENOSYS me.status = ENOSYS
return return
} }
if len(me.arg) < int(me.handler.InputSize) { if len(me.arg) < int(me.handler.InputSize) {
log.Printf("Short read for %v: %v", me.inHeader.opcode, me.arg) log.Printf("Short read for %v: %v", operationName(me.inHeader.Opcode), me.arg)
me.status = EIO me.status = EIO
return return
} }
......
...@@ -7,27 +7,11 @@ import ( ...@@ -7,27 +7,11 @@ import (
) )
const ( const (
FUSE_ROOT_ID = 1
FUSE_UNKNOWN_INO = 0xffffffff
CUSE_UNRESTRICTED_IOCTL = (1 << 0)
FUSE_LK_FLOCK = (1 << 0)
FUSE_IOCTL_MAX_IOV = 256
FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0)
CUSE_INIT_INFO_MAX = 4096
S_IFDIR = syscall.S_IFDIR S_IFDIR = syscall.S_IFDIR
S_IFREG = syscall.S_IFREG S_IFREG = syscall.S_IFREG
S_IFLNK = syscall.S_IFLNK S_IFLNK = syscall.S_IFLNK
S_IFIFO = syscall.S_IFIFO S_IFIFO = syscall.S_IFIFO
CUSE_INIT = 4096
O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC) O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC)
) )
...@@ -62,10 +46,7 @@ type Attr raw.Attr ...@@ -62,10 +46,7 @@ type Attr raw.Attr
type Owner raw.Owner type Owner raw.Owner
type Context struct { type Context raw.Context
Owner
Pid uint32
}
type Kstatfs struct { type Kstatfs struct {
Blocks uint64 Blocks uint64
...@@ -113,15 +94,6 @@ type StatfsOut struct { ...@@ -113,15 +94,6 @@ type StatfsOut struct {
Kstatfs Kstatfs
} }
type InHeader struct {
Length uint32
opcode
Unique uint64
NodeId uint64
Context
Padding uint32
}
type Dirent struct { type Dirent struct {
Ino uint64 Ino uint64
Off uint64 Off uint64
......
package raw
import (
"os"
"syscall"
)
const (
FUSE_ROOT_ID = 1
FUSE_UNKNOWN_INO = 0xffffffff
CUSE_UNRESTRICTED_IOCTL = (1 << 0)
FUSE_LK_FLOCK = (1 << 0)
FUSE_IOCTL_MAX_IOV = 256
FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0)
CUSE_INIT_INFO_MAX = 4096
S_IFDIR = syscall.S_IFDIR
S_IFREG = syscall.S_IFREG
S_IFLNK = syscall.S_IFLNK
S_IFIFO = syscall.S_IFIFO
CUSE_INIT = 4096
O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC)
)
// The raw package contains types and constants used for the FUSE wire
// protocol.
package raw package raw
...@@ -350,3 +353,17 @@ type CreateOut struct { ...@@ -350,3 +353,17 @@ type CreateOut struct {
EntryOut EntryOut
OpenOut OpenOut
} }
type Context struct {
Owner
Pid uint32
}
type InHeader struct {
Length uint32
Opcode int32
Unique uint64
NodeId uint64
Context
Padding uint32
}
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