Commit 303e494f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Move more types.

parent bf05480f
...@@ -4,7 +4,7 @@ set -eux ...@@ -4,7 +4,7 @@ set -eux
sh genversion.sh fuse/version.gen.go sh genversion.sh fuse/version.gen.go
for target in "clean" "install" ; do for target in "clean" "install" ; do
for d in fuse benchmark zipfs unionfs \ for d in raw fuse benchmark zipfs unionfs \
example/hello example/loopback example/zipfs \ example/hello example/loopback example/zipfs \
example/bulkstat example/multizip example/unionfs \ example/bulkstat example/multizip example/unionfs \
example/autounionfs ; \ example/autounionfs ; \
......
...@@ -253,8 +253,8 @@ type RawFileSystem interface { ...@@ -253,8 +253,8 @@ type RawFileSystem interface {
Forget(nodeid, nlookup uint64) Forget(nodeid, nlookup uint64)
// Attributes. // Attributes.
GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) GetAttr(header *InHeader, input *raw.GetAttrIn) (out *AttrOut, code Status)
SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) SetAttr(header *InHeader, input *raw.SetAttrIn) (out *AttrOut, code Status)
// Modifying structure. // Modifying structure.
Mknod(header *InHeader, input *raw.MknodIn, name string) (out *EntryOut, code Status) Mknod(header *InHeader, input *raw.MknodIn, name string) (out *EntryOut, code Status)
...@@ -277,18 +277,18 @@ type RawFileSystem interface { ...@@ -277,18 +277,18 @@ type RawFileSystem interface {
// File handling. // File handling.
Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status) Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status)
Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) Open(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status)
Read(*InHeader, *ReadIn, BufferPool) ([]byte, Status) Read(*InHeader, *ReadIn, BufferPool) ([]byte, Status)
Release(header *InHeader, input *ReleaseIn) Release(header *InHeader, input *raw.ReleaseIn)
Write(*InHeader, *WriteIn, []byte) (written uint32, code Status) Write(*InHeader, *WriteIn, []byte) (written uint32, code Status)
Flush(header *InHeader, input *FlushIn) Status Flush(header *InHeader, input *FlushIn) Status
Fsync(*InHeader, *FsyncIn) (code Status) Fsync(*InHeader, *FsyncIn) (code Status)
// Directory handling // Directory handling
OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) OpenDir(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status)
ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status)
ReleaseDir(header *InHeader, input *ReleaseIn) ReleaseDir(header *InHeader, input *raw.ReleaseIn)
FsyncDir(header *InHeader, input *FsyncIn) (code Status) FsyncDir(header *InHeader, input *FsyncIn) (code Status)
// //
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"os" "os"
"sync" "sync"
"testing" "testing"
"github.com/hanwen/go-fuse/raw"
) )
var _ = log.Println var _ = log.Println
...@@ -22,7 +23,7 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F ...@@ -22,7 +23,7 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F
} }
return &WithFlags{ return &WithFlags{
File: f, File: f,
FuseFlags: FOPEN_KEEP_CACHE, FuseFlags: raw.FOPEN_KEEP_CACHE,
}, c }, c
} }
...@@ -111,7 +112,7 @@ func (me *nonseekFs) Open(name string, flags uint32, context *Context) (fuseFile ...@@ -111,7 +112,7 @@ func (me *nonseekFs) Open(name string, flags uint32, context *Context) (fuseFile
f := NewDataFile(data) f := NewDataFile(data)
return &WithFlags{ return &WithFlags{
File: f, File: f,
FuseFlags: FOPEN_NONSEEKABLE, FuseFlags: raw.FOPEN_NONSEEKABLE,
}, OK }, OK
} }
......
...@@ -18,15 +18,15 @@ func (me *DefaultRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut, ...@@ -18,15 +18,15 @@ func (me *DefaultRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut,
func (me *DefaultRawFileSystem) Forget(nodeID, nlookup uint64) { func (me *DefaultRawFileSystem) Forget(nodeID, nlookup uint64) {
} }
func (me *DefaultRawFileSystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) { func (me *DefaultRawFileSystem) GetAttr(header *InHeader, input *raw.GetAttrIn) (out *AttrOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *DefaultRawFileSystem) Open(header *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 *SetAttrIn) (out *AttrOut, code Status) { func (me *DefaultRawFileSystem) SetAttr(header *InHeader, input *raw.SetAttrIn) (out *AttrOut, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
...@@ -98,7 +98,7 @@ func (me *DefaultRawFileSystem) Poll(header *InHeader, input *PollIn) (out *Poll ...@@ -98,7 +98,7 @@ func (me *DefaultRawFileSystem) Poll(header *InHeader, input *PollIn) (out *Poll
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *DefaultRawFileSystem) OpenDir(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) {
return 0, 0, ENOSYS return 0, 0, ENOSYS
} }
...@@ -106,7 +106,7 @@ func (me *DefaultRawFileSystem) Read(header *InHeader, input *ReadIn, bp BufferP ...@@ -106,7 +106,7 @@ func (me *DefaultRawFileSystem) Read(header *InHeader, input *ReadIn, bp BufferP
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) Release(header *InHeader, input *ReleaseIn) { func (me *DefaultRawFileSystem) Release(header *InHeader, input *raw.ReleaseIn) {
} }
func (me *DefaultRawFileSystem) Write(header *InHeader, input *WriteIn, data []byte) (written uint32, code Status) { func (me *DefaultRawFileSystem) Write(header *InHeader, input *WriteIn, data []byte) (written uint32, code Status) {
...@@ -125,7 +125,7 @@ func (me *DefaultRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEn ...@@ -125,7 +125,7 @@ func (me *DefaultRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEn
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) ReleaseDir(header *InHeader, input *ReleaseIn) { func (me *DefaultRawFileSystem) ReleaseDir(header *InHeader, input *raw.ReleaseIn) {
} }
func (me *DefaultRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) { func (me *DefaultRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) {
......
...@@ -80,11 +80,11 @@ func (me *FileSystemConnector) Forget(nodeID, nlookup uint64) { ...@@ -80,11 +80,11 @@ func (me *FileSystemConnector) Forget(nodeID, nlookup uint64) {
me.forgetUpdate(node, int(nlookup)) me.forgetUpdate(node, int(nlookup))
} }
func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) { func (me *FileSystemConnector) GetAttr(header *InHeader, input *raw.GetAttrIn) (out *AttrOut, code Status) {
node := me.toInode(header.NodeId) node := me.toInode(header.NodeId)
var f File var f File
if input.Flags&FUSE_GETATTR_FH != 0 { if input.Flags&raw.FUSE_GETATTR_FH != 0 {
if opened := node.mount.getOpenedFile(input.Fh); opened != nil { if opened := node.mount.getOpenedFile(input.Fh); opened != nil {
f = opened.WithFlags.File f = opened.WithFlags.File
} }
...@@ -98,7 +98,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out ...@@ -98,7 +98,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
return out, OK return out, OK
} }
func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, code Status) { func (me *FileSystemConnector) OpenDir(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, code Status) {
node := me.toInode(header.NodeId) node := me.toInode(header.NodeId)
stream, err := node.fsInode.OpenDir(&header.Context) stream, err := node.fsInode.OpenDir(&header.Context)
if err != OK { if err != OK {
...@@ -113,7 +113,7 @@ func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags u ...@@ -113,7 +113,7 @@ func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags u
h, opened := node.mount.registerFileHandle(node, de, nil, input.Flags) h, opened := node.mount.registerFileHandle(node, de, nil, input.Flags)
// TODO - implement seekable directories // TODO - implement seekable directories
opened.FuseFlags |= FOPEN_NONSEEKABLE opened.FuseFlags |= raw.FOPEN_NONSEEKABLE
return opened.FuseFlags, h, OK return opened.FuseFlags, h, OK
} }
...@@ -127,7 +127,7 @@ func (me *FileSystemConnector) ReadDir(header *InHeader, input *ReadIn) (*DirEnt ...@@ -127,7 +127,7 @@ func (me *FileSystemConnector) ReadDir(header *InHeader, input *ReadIn) (*DirEnt
return de, OK return de, OK
} }
func (me *FileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *FileSystemConnector) Open(header *InHeader, input *raw.OpenIn) (flags uint32, handle uint64, status Status) {
node := me.toInode(header.NodeId) node := me.toInode(header.NodeId)
f, code := node.fsInode.Open(input.Flags, &header.Context) f, code := node.fsInode.Open(input.Flags, &header.Context)
if !code.Ok() { if !code.Ok() {
...@@ -137,37 +137,37 @@ func (me *FileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint ...@@ -137,37 +137,37 @@ func (me *FileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint
return opened.FuseFlags, h, OK return opened.FuseFlags, h, OK
} }
func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) { func (me *FileSystemConnector) SetAttr(header *InHeader, input *raw.SetAttrIn) (out *AttrOut, code Status) {
node := me.toInode(header.NodeId) node := me.toInode(header.NodeId)
var f File var f File
if input.Valid&FATTR_FH != 0 { if input.Valid&raw.FATTR_FH != 0 {
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
f = opened.WithFlags.File f = opened.WithFlags.File
} }
if code.Ok() && input.Valid&FATTR_MODE != 0 { if code.Ok() && input.Valid&raw.FATTR_MODE != 0 {
permissions := uint32(07777) & input.Mode permissions := uint32(07777) & input.Mode
code = node.fsInode.Chmod(f, permissions, &header.Context) code = node.fsInode.Chmod(f, permissions, &header.Context)
} }
if code.Ok() && (input.Valid&(FATTR_UID|FATTR_GID) != 0) { if code.Ok() && (input.Valid&(raw.FATTR_UID|raw.FATTR_GID) != 0) {
code = node.fsInode.Chown(f, uint32(input.Uid), uint32(input.Gid), &header.Context) code = node.fsInode.Chown(f, uint32(input.Uid), uint32(input.Gid), &header.Context)
} }
if code.Ok() && input.Valid&FATTR_SIZE != 0 { if code.Ok() && input.Valid&raw.FATTR_SIZE != 0 {
code = node.fsInode.Truncate(f, input.Size, &header.Context) code = node.fsInode.Truncate(f, input.Size, &header.Context)
} }
if code.Ok() && (input.Valid&(FATTR_ATIME|FATTR_MTIME|FATTR_ATIME_NOW|FATTR_MTIME_NOW) != 0) { if code.Ok() && (input.Valid&(raw.FATTR_ATIME|raw.FATTR_MTIME|raw.FATTR_ATIME_NOW|raw.FATTR_MTIME_NOW) != 0) {
now := int64(0) now := int64(0)
if input.Valid&FATTR_ATIME_NOW != 0 || input.Valid&FATTR_MTIME_NOW != 0 { if input.Valid&raw.FATTR_ATIME_NOW != 0 || input.Valid&raw.FATTR_MTIME_NOW != 0 {
now = time.Now().UnixNano() now = time.Now().UnixNano()
} }
atime := int64(input.Atime*1e9) + int64(input.Atimensec) atime := int64(input.Atime*1e9) + int64(input.Atimensec)
if input.Valid&FATTR_ATIME_NOW != 0 { if input.Valid&raw.FATTR_ATIME_NOW != 0 {
atime = now atime = now
} }
mtime := int64(input.Mtime*1e9) + int64(input.Mtimensec) mtime := int64(input.Mtime*1e9) + int64(input.Mtimensec)
if input.Valid&FATTR_MTIME_NOW != 0 { if input.Valid&raw.FATTR_MTIME_NOW != 0 {
mtime = now mtime = now
} }
...@@ -278,13 +278,13 @@ func (me *FileSystemConnector) Create(header *InHeader, input *CreateIn, name st ...@@ -278,13 +278,13 @@ func (me *FileSystemConnector) Create(header *InHeader, input *CreateIn, name st
return opened.FuseFlags, handle, out, code return opened.FuseFlags, handle, out, code
} }
func (me *FileSystemConnector) Release(header *InHeader, input *ReleaseIn) { func (me *FileSystemConnector) Release(header *InHeader, input *raw.ReleaseIn) {
node := me.toInode(header.NodeId) node := me.toInode(header.NodeId)
opened := node.mount.unregisterFileHandle(input.Fh, node) opened := node.mount.unregisterFileHandle(input.Fh, node)
opened.WithFlags.File.Release() opened.WithFlags.File.Release()
} }
func (me *FileSystemConnector) ReleaseDir(header *InHeader, input *ReleaseIn) { func (me *FileSystemConnector) ReleaseDir(header *InHeader, input *raw.ReleaseIn) {
node := me.toInode(header.NodeId) node := me.toInode(header.NodeId)
opened := node.mount.unregisterFileHandle(input.Fh, node) opened := node.mount.unregisterFileHandle(input.Fh, node)
opened.dir.Release() opened.dir.Release()
......
...@@ -170,17 +170,17 @@ func (me *LockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) { ...@@ -170,17 +170,17 @@ 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 *GetAttrIn) (out *AttrOut, code Status) { func (me *LockingRawFileSystem) GetAttr(header *InHeader, input *raw.GetAttrIn) (out *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 *OpenIn) (flags uint32, handle uint64, status Status) { func (me *LockingRawFileSystem) Open(header *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 *SetAttrIn) (out *AttrOut, code Status) { func (me *LockingRawFileSystem) SetAttr(header *InHeader, input *raw.SetAttrIn) (out *AttrOut, code Status) {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.SetAttr(header, input) return me.RawFileSystem.SetAttr(header, input)
} }
...@@ -260,17 +260,17 @@ func (me *LockingRawFileSystem) Create(header *InHeader, input *CreateIn, name s ...@@ -260,17 +260,17 @@ func (me *LockingRawFileSystem) Create(header *InHeader, input *CreateIn, name s
return me.RawFileSystem.Create(header, input, name) return me.RawFileSystem.Create(header, input, name)
} }
func (me *LockingRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, h uint64, status Status) { func (me *LockingRawFileSystem) OpenDir(header *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 *ReleaseIn) { func (me *LockingRawFileSystem) Release(header *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 *ReleaseIn) { func (me *LockingRawFileSystem) ReleaseDir(header *InHeader, h *raw.ReleaseIn) {
defer me.locked()() defer me.locked()()
me.RawFileSystem.ReleaseDir(header, h) me.RawFileSystem.ReleaseDir(header, h)
} }
......
...@@ -105,13 +105,13 @@ func doInit(state *MountState, req *request) { ...@@ -105,13 +105,13 @@ func doInit(state *MountState, req *request) {
} }
func doOpen(state *MountState, req *request) { func doOpen(state *MountState, req *request) {
flags, handle, status := state.fileSystem.Open(req.inHeader, (*OpenIn)(req.inData)) flags, handle, status := state.fileSystem.Open(req.inHeader, (*raw.OpenIn)(req.inData))
req.status = status req.status = status
if status != OK { if status != OK {
return return
} }
out := &OpenOut{ out := &raw.OpenOut{
Fh: handle, Fh: handle,
OpenFlags: flags, OpenFlags: flags,
} }
...@@ -125,7 +125,7 @@ func doCreate(state *MountState, req *request) { ...@@ -125,7 +125,7 @@ func doCreate(state *MountState, req *request) {
if status.Ok() { if status.Ok() {
req.outData = unsafe.Pointer(&CreateOut{ req.outData = unsafe.Pointer(&CreateOut{
EntryOut: *entry, EntryOut: *entry,
OpenOut: OpenOut{ raw.OpenOut: raw.OpenOut{
Fh: handle, Fh: handle,
OpenFlags: flags, OpenFlags: flags,
}, },
...@@ -142,10 +142,10 @@ func doReadDir(state *MountState, req *request) { ...@@ -142,10 +142,10 @@ func doReadDir(state *MountState, req *request) {
} }
func doOpenDir(state *MountState, req *request) { func doOpenDir(state *MountState, req *request) {
flags, handle, status := state.fileSystem.OpenDir(req.inHeader, (*OpenIn)(req.inData)) flags, handle, status := state.fileSystem.OpenDir(req.inHeader, (*raw.OpenIn)(req.inData))
req.status = status req.status = status
if status.Ok() { if status.Ok() {
req.outData = unsafe.Pointer(&OpenOut{ req.outData = unsafe.Pointer(&raw.OpenOut{
Fh: handle, Fh: handle,
OpenFlags: flags, OpenFlags: flags,
}) })
...@@ -153,7 +153,7 @@ func doOpenDir(state *MountState, req *request) { ...@@ -153,7 +153,7 @@ func doOpenDir(state *MountState, req *request) {
} }
func doSetattr(state *MountState, req *request) { func doSetattr(state *MountState, req *request) {
o, s := state.fileSystem.SetAttr(req.inHeader, (*SetAttrIn)(req.inData)) o, s := state.fileSystem.SetAttr(req.inHeader, (*raw.SetAttrIn)(req.inData))
req.outData = unsafe.Pointer(o) req.outData = unsafe.Pointer(o)
req.status = s req.status = s
} }
...@@ -213,7 +213,7 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -213,7 +213,7 @@ func doGetXAttr(state *MountState, req *request) {
} }
func doGetAttr(state *MountState, req *request) { func doGetAttr(state *MountState, req *request) {
attrOut, s := state.fileSystem.GetAttr(req.inHeader, (*GetAttrIn)(req.inData)) attrOut, s := state.fileSystem.GetAttr(req.inHeader, (*raw.GetAttrIn)(req.inData))
req.status = s req.status = s
req.outData = unsafe.Pointer(attrOut) req.outData = unsafe.Pointer(attrOut)
} }
...@@ -284,7 +284,7 @@ func doFlush(state *MountState, req *request) { ...@@ -284,7 +284,7 @@ func doFlush(state *MountState, req *request) {
} }
func doRelease(state *MountState, req *request) { func doRelease(state *MountState, req *request) {
state.fileSystem.Release(req.inHeader, (*ReleaseIn)(req.inData)) state.fileSystem.Release(req.inHeader, (*raw.ReleaseIn)(req.inData))
} }
func doFsync(state *MountState, req *request) { func doFsync(state *MountState, req *request) {
...@@ -292,7 +292,7 @@ func doFsync(state *MountState, req *request) { ...@@ -292,7 +292,7 @@ func doFsync(state *MountState, req *request) {
} }
func doReleaseDir(state *MountState, req *request) { func doReleaseDir(state *MountState, req *request) {
state.fileSystem.ReleaseDir(req.inHeader, (*ReleaseIn)(req.inData)) state.fileSystem.ReleaseDir(req.inHeader, (*raw.ReleaseIn)(req.inData))
} }
func doFsyncDir(state *MountState, req *request) { func doFsyncDir(state *MountState, req *request) {
...@@ -390,25 +390,25 @@ func init() { ...@@ -390,25 +390,25 @@ func init() {
for op, sz := range map[opcode]uintptr{ for op, sz := range map[opcode]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(GetAttrIn{}), _OP_GETATTR: unsafe.Sizeof(raw.GetAttrIn{}),
_OP_SETATTR: unsafe.Sizeof(SetAttrIn{}), _OP_SETATTR: unsafe.Sizeof(raw.SetAttrIn{}),
_OP_MKNOD: unsafe.Sizeof(raw.MknodIn{}), _OP_MKNOD: unsafe.Sizeof(raw.MknodIn{}),
_OP_MKDIR: unsafe.Sizeof(raw.MkdirIn{}), _OP_MKDIR: unsafe.Sizeof(raw.MkdirIn{}),
_OP_RENAME: unsafe.Sizeof(raw.RenameIn{}), _OP_RENAME: unsafe.Sizeof(raw.RenameIn{}),
_OP_LINK: unsafe.Sizeof(raw.LinkIn{}), _OP_LINK: unsafe.Sizeof(raw.LinkIn{}),
_OP_OPEN: unsafe.Sizeof(OpenIn{}), _OP_OPEN: unsafe.Sizeof(raw.OpenIn{}),
_OP_READ: unsafe.Sizeof(ReadIn{}), _OP_READ: unsafe.Sizeof(ReadIn{}),
_OP_WRITE: unsafe.Sizeof(WriteIn{}), _OP_WRITE: unsafe.Sizeof(WriteIn{}),
_OP_RELEASE: unsafe.Sizeof(ReleaseIn{}), _OP_RELEASE: unsafe.Sizeof(raw.ReleaseIn{}),
_OP_FSYNC: unsafe.Sizeof(FsyncIn{}), _OP_FSYNC: unsafe.Sizeof(FsyncIn{}),
_OP_SETXATTR: unsafe.Sizeof(SetXAttrIn{}), _OP_SETXATTR: unsafe.Sizeof(SetXAttrIn{}),
_OP_GETXATTR: unsafe.Sizeof(GetXAttrIn{}), _OP_GETXATTR: unsafe.Sizeof(GetXAttrIn{}),
_OP_LISTXATTR: unsafe.Sizeof(GetXAttrIn{}), _OP_LISTXATTR: unsafe.Sizeof(GetXAttrIn{}),
_OP_FLUSH: unsafe.Sizeof(FlushIn{}), _OP_FLUSH: unsafe.Sizeof(FlushIn{}),
_OP_INIT: unsafe.Sizeof(InitIn{}), _OP_INIT: unsafe.Sizeof(InitIn{}),
_OP_OPENDIR: unsafe.Sizeof(OpenIn{}), _OP_OPENDIR: unsafe.Sizeof(raw.OpenIn{}),
_OP_READDIR: unsafe.Sizeof(ReadIn{}), _OP_READDIR: unsafe.Sizeof(ReadIn{}),
_OP_RELEASEDIR: unsafe.Sizeof(ReleaseIn{}), _OP_RELEASEDIR: unsafe.Sizeof(raw.ReleaseIn{}),
_OP_FSYNCDIR: unsafe.Sizeof(FsyncIn{}), _OP_FSYNCDIR: unsafe.Sizeof(FsyncIn{}),
_OP_ACCESS: unsafe.Sizeof(AccessIn{}), _OP_ACCESS: unsafe.Sizeof(AccessIn{}),
_OP_CREATE: unsafe.Sizeof(CreateIn{}), _OP_CREATE: unsafe.Sizeof(CreateIn{}),
...@@ -428,13 +428,13 @@ func init() { ...@@ -428,13 +428,13 @@ func init() {
_OP_MKNOD: unsafe.Sizeof(EntryOut{}), _OP_MKNOD: unsafe.Sizeof(EntryOut{}),
_OP_MKDIR: unsafe.Sizeof(EntryOut{}), _OP_MKDIR: unsafe.Sizeof(EntryOut{}),
_OP_LINK: unsafe.Sizeof(EntryOut{}), _OP_LINK: unsafe.Sizeof(EntryOut{}),
_OP_OPEN: unsafe.Sizeof(OpenOut{}), _OP_OPEN: unsafe.Sizeof(raw.OpenOut{}),
_OP_WRITE: unsafe.Sizeof(WriteOut{}), _OP_WRITE: unsafe.Sizeof(WriteOut{}),
_OP_STATFS: unsafe.Sizeof(StatfsOut{}), _OP_STATFS: unsafe.Sizeof(StatfsOut{}),
_OP_GETXATTR: unsafe.Sizeof(GetXAttrOut{}), _OP_GETXATTR: unsafe.Sizeof(GetXAttrOut{}),
_OP_LISTXATTR: unsafe.Sizeof(GetXAttrOut{}), _OP_LISTXATTR: unsafe.Sizeof(GetXAttrOut{}),
_OP_INIT: unsafe.Sizeof(InitOut{}), _OP_INIT: unsafe.Sizeof(InitOut{}),
_OP_OPENDIR: unsafe.Sizeof(OpenOut{}), _OP_OPENDIR: unsafe.Sizeof(raw.OpenOut{}),
_OP_CREATE: unsafe.Sizeof(CreateOut{}), _OP_CREATE: unsafe.Sizeof(CreateOut{}),
_OP_BMAP: unsafe.Sizeof(BmapOut{}), _OP_BMAP: unsafe.Sizeof(BmapOut{}),
_OP_IOCTL: unsafe.Sizeof(IoctlOut{}), _OP_IOCTL: unsafe.Sizeof(IoctlOut{}),
...@@ -531,8 +531,8 @@ func init() { ...@@ -531,8 +531,8 @@ func init() {
// Outputs. // Outputs.
for op, f := range map[opcode]castPointerFunc{ for op, f := range map[opcode]castPointerFunc{
_OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, _OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) },
_OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*OpenOut)(ptr) }, _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*raw.OpenOut)(ptr) },
_OP_OPENDIR: func(ptr unsafe.Pointer) interface{} { return (*OpenOut)(ptr) }, _OP_OPENDIR: func(ptr unsafe.Pointer) interface{} { return (*raw.OpenOut)(ptr) },
_OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) }, _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) },
_OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateOut)(ptr) }, _OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateOut)(ptr) },
_OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, _OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) },
...@@ -549,11 +549,11 @@ func init() { ...@@ -549,11 +549,11 @@ func init() {
// Inputs. // Inputs.
for op, f := range map[opcode]castPointerFunc{ for op, f := range map[opcode]castPointerFunc{
_OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*FlushIn)(ptr) }, _OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*FlushIn)(ptr) },
_OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*GetAttrIn)(ptr) }, _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.GetAttrIn)(ptr) },
_OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*SetAttrIn)(ptr) }, _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.SetAttrIn)(ptr) },
_OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*InitIn)(ptr) }, _OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*InitIn)(ptr) },
_OP_IOCTL: func(ptr unsafe.Pointer) interface{} { return (*IoctlIn)(ptr) }, _OP_IOCTL: func(ptr unsafe.Pointer) interface{} { return (*IoctlIn)(ptr) },
_OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*OpenIn)(ptr) }, _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*raw.OpenIn)(ptr) },
_OP_MKNOD: func(ptr unsafe.Pointer) interface{} { return (*raw.MknodIn)(ptr) }, _OP_MKNOD: func(ptr unsafe.Pointer) interface{} { return (*raw.MknodIn)(ptr) },
_OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateIn)(ptr) }, _OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateIn)(ptr) },
_OP_READ: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) }, _OP_READ: func(ptr unsafe.Pointer) interface{} { return (*ReadIn)(ptr) },
...@@ -563,8 +563,8 @@ func init() { ...@@ -563,8 +563,8 @@ func init() {
_OP_BATCH_FORGET: func(ptr unsafe.Pointer) interface{} { return (*raw.BatchForgetIn)(ptr) }, _OP_BATCH_FORGET: func(ptr unsafe.Pointer) interface{} { return (*raw.BatchForgetIn)(ptr) },
_OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*raw.LinkIn)(ptr) }, _OP_LINK: func(ptr unsafe.Pointer) interface{} { return (*raw.LinkIn)(ptr) },
_OP_MKDIR: func(ptr unsafe.Pointer) interface{} { return (*raw.MkdirIn)(ptr) }, _OP_MKDIR: func(ptr unsafe.Pointer) interface{} { return (*raw.MkdirIn)(ptr) },
_OP_RELEASE: func(ptr unsafe.Pointer) interface{} { return (*ReleaseIn)(ptr) }, _OP_RELEASE: func(ptr unsafe.Pointer) interface{} { return (*raw.ReleaseIn)(ptr) },
_OP_RELEASEDIR: func(ptr unsafe.Pointer) interface{} { return (*ReleaseIn)(ptr) }, _OP_RELEASEDIR: func(ptr unsafe.Pointer) interface{} { return (*raw.ReleaseIn)(ptr) },
} { } {
operationHandlers[op].DecodeIn = f operationHandlers[op].DecodeIn = f
} }
......
...@@ -2,42 +2,15 @@ package fuse ...@@ -2,42 +2,15 @@ package fuse
import ( import (
"fmt" "fmt"
"os" "github.com/hanwen/go-fuse/raw"
// "sort"
"strings"
"syscall"
) )
var openFlagNames map[int]string
var initFlagNames map[int]string var initFlagNames map[int]string
var fuseOpenFlagNames map[int]string
var writeFlagNames map[int]string var writeFlagNames map[int]string
var readFlagNames map[int]string var readFlagNames map[int]string
var releaseFlagNames map[int]string
var accessFlagName map[int]string var accessFlagName map[int]string
func init() { func init() {
releaseFlagNames = map[int]string{
RELEASE_FLUSH: "FLUSH",
}
openFlagNames = map[int]string{
os.O_WRONLY: "WRONLY",
os.O_RDWR: "RDWR",
os.O_APPEND: "APPEND",
syscall.O_ASYNC: "ASYNC",
os.O_CREATE: "CREAT",
os.O_EXCL: "EXCL",
syscall.O_NOCTTY: "NOCTTY",
syscall.O_NONBLOCK: "NONBLOCK",
os.O_SYNC: "SYNC",
os.O_TRUNC: "TRUNC",
syscall.O_CLOEXEC: "CLOEXEC",
syscall.O_DIRECT: "DIRECT",
syscall.O_DIRECTORY: "DIRECTORY",
syscall.O_LARGEFILE: "LARGEFILE",
syscall.O_NOATIME: "NOATIME",
}
initFlagNames = map[int]string{ initFlagNames = map[int]string{
CAP_ASYNC_READ: "ASYNC_READ", CAP_ASYNC_READ: "ASYNC_READ",
CAP_POSIX_LOCKS: "POSIX_LOCKS", CAP_POSIX_LOCKS: "POSIX_LOCKS",
...@@ -50,11 +23,6 @@ func init() { ...@@ -50,11 +23,6 @@ func init() {
CAP_SPLICE_MOVE: "SPLICE_MOVE", CAP_SPLICE_MOVE: "SPLICE_MOVE",
CAP_SPLICE_READ: "SPLICE_READ", CAP_SPLICE_READ: "SPLICE_READ",
} }
fuseOpenFlagNames = map[int]string{
FOPEN_DIRECT_IO: "DIRECT",
FOPEN_KEEP_CACHE: "CACHE",
FOPEN_NONSEEKABLE: "NONSEEK",
}
writeFlagNames = map[int]string{ writeFlagNames = map[int]string{
WRITE_CACHE: "CACHE", WRITE_CACHE: "CACHE",
WRITE_LOCKOWNER: "LOCKOWNER", WRITE_LOCKOWNER: "LOCKOWNER",
...@@ -69,55 +37,6 @@ func init() { ...@@ -69,55 +37,6 @@ func init() {
} }
} }
func flagString(names map[int]string, fl int, def string) string {
s := []string{}
for k, v := range names {
if fl&k != 0 {
s = append(s, v)
fl ^= k
}
}
if len(s) == 0 && def != "" {
s = []string{def}
}
if fl != 0 {
s = append(s, fmt.Sprintf("0x%x", fl))
}
return strings.Join(s, ",")
}
func (me *OpenIn) String() string {
return fmt.Sprintf("{%s}", flagString(openFlagNames, int(me.Flags), "O_RDONLY"))
}
func (me *SetAttrIn) String() string {
s := []string{}
if me.Valid&FATTR_MODE != 0 {
s = append(s, fmt.Sprintf("mode 0%o", me.Mode))
}
if me.Valid&FATTR_UID != 0 {
s = append(s, fmt.Sprintf("uid %d", me.Uid))
}
if me.Valid&FATTR_GID != 0 {
s = append(s, fmt.Sprintf("uid %d", me.Gid))
}
if me.Valid&FATTR_SIZE != 0 {
s = append(s, fmt.Sprintf("size %d", me.Size))
}
if me.Valid&FATTR_ATIME != 0 {
s = append(s, fmt.Sprintf("atime %d.%09d", me.Atime, me.Atimensec))
}
if me.Valid&FATTR_MTIME != 0 {
s = append(s, fmt.Sprintf("mtime %d.%09d", me.Mtime, me.Mtimensec))
}
if me.Valid&FATTR_MTIME != 0 {
s = append(s, fmt.Sprintf("fh %d", me.Fh))
}
// TODO - FATTR_ATIME_NOW = (1 << 7), FATTR_MTIME_NOW = (1 << 8), FATTR_LOCKOWNER = (1 << 9)
return fmt.Sprintf("{%s}", strings.Join(s, ", "))
}
func (me *Attr) String() string { func (me *Attr) String() string {
return fmt.Sprintf( return fmt.Sprintf(
"{M0%o S=%d L=%d "+ "{M0%o S=%d L=%d "+
...@@ -142,7 +61,7 @@ func (me *AttrOut) String() string { ...@@ -142,7 +61,7 @@ func (me *AttrOut) String() string {
func (me *CreateIn) String() string { func (me *CreateIn) String() string {
return fmt.Sprintf( return fmt.Sprintf(
"{0%o [%s] (0%o)}", me.Mode, "{0%o [%s] (0%o)}", me.Mode,
flagString(openFlagNames, int(me.Flags), "O_RDONLY"), me.Umask) raw.FlagString(raw.OpenFlagNames, int(me.Flags), "O_RDONLY"), me.Umask)
} }
func (me *EntryOut) String() string { func (me *EntryOut) String() string {
...@@ -155,48 +74,33 @@ func (me *CreateOut) String() string { ...@@ -155,48 +74,33 @@ func (me *CreateOut) String() string {
return fmt.Sprintf("{%v %v}", &me.EntryOut, &me.OpenOut) return fmt.Sprintf("{%v %v}", &me.EntryOut, &me.OpenOut)
} }
func (me *OpenOut) String() string {
return fmt.Sprintf("{Fh %d %s}", me.Fh,
flagString(fuseOpenFlagNames, int(me.OpenFlags), ""))
}
func (me *GetAttrIn) String() string {
return fmt.Sprintf("{Fh %d}", me.Fh)
}
func (me *InitIn) String() string { func (me *InitIn) String() string {
return fmt.Sprintf("{%d.%d Ra 0x%x %s}", return fmt.Sprintf("{%d.%d Ra 0x%x %s}",
me.Major, me.Minor, me.MaxReadAhead, me.Major, me.Minor, me.MaxReadAhead,
flagString(initFlagNames, int(me.Flags), "")) raw.FlagString(initFlagNames, int(me.Flags), ""))
} }
func (me *InitOut) String() string { func (me *InitOut) String() string {
return fmt.Sprintf("{%d.%d Ra 0x%x %s %d/%d Wr 0x%x}", return fmt.Sprintf("{%d.%d Ra 0x%x %s %d/%d Wr 0x%x}",
me.Major, me.Minor, me.MaxReadAhead, me.Major, me.Minor, me.MaxReadAhead,
flagString(initFlagNames, int(me.Flags), ""), raw.FlagString(initFlagNames, int(me.Flags), ""),
me.CongestionThreshold, me.MaxBackground, me.MaxWrite) me.CongestionThreshold, me.MaxBackground, me.MaxWrite)
} }
func (me *ReadIn) String() string { func (me *ReadIn) String() string {
return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}", return fmt.Sprintf("{Fh %d off %d sz %d %s L %d %s}",
me.Fh, me.Offset, me.Size, me.Fh, me.Offset, me.Size,
flagString(readFlagNames, int(me.ReadFlags), ""), raw.FlagString(readFlagNames, int(me.ReadFlags), ""),
me.LockOwner, me.LockOwner,
flagString(openFlagNames, int(me.Flags), "RDONLY")) raw.FlagString(raw.OpenFlagNames, int(me.Flags), "RDONLY"))
} }
func (me *ReleaseIn) String() string {
return fmt.Sprintf("{Fh %d %s %s L%d}",
me.Fh, flagString(openFlagNames, int(me.Flags), ""),
flagString(releaseFlagNames, int(me.ReleaseFlags), ""),
me.LockOwner)
}
func (me *FlushIn) String() string { func (me *FlushIn) String() string {
return fmt.Sprintf("{Fh %d}", me.Fh) return fmt.Sprintf("{Fh %d}", me.Fh)
} }
func (me *AccessIn) String() string { func (me *AccessIn) String() string {
return fmt.Sprintf("{%s}", flagString(accessFlagName, int(me.Mask), "")) return fmt.Sprintf("{%s}", raw.FlagString(accessFlagName, int(me.Mask), ""))
} }
func (me *SetXAttrIn) String() string { func (me *SetXAttrIn) String() string {
...@@ -220,7 +124,8 @@ func (me *Kstatfs) String() string { ...@@ -220,7 +124,8 @@ func (me *Kstatfs) String() string {
func (me *WithFlags) String() string { func (me *WithFlags) String() string {
return fmt.Sprintf("File %s (%s) %s %s", return fmt.Sprintf("File %s (%s) %s %s",
me.File, me.Description, flagString(openFlagNames, int(me.OpenFlags), "O_RDONLY"), me.File, me.Description, raw.FlagString(raw.OpenFlagNames, int(me.OpenFlags), "O_RDONLY"),
flagString(fuseOpenFlagNames, int(me.FuseFlags), "")) raw.FlagString(raw.FuseOpenFlagNames, int(me.FuseFlags), ""))
} }
...@@ -3,6 +3,7 @@ package fuse ...@@ -3,6 +3,7 @@ package fuse
import ( import (
"os" "os"
"syscall" "syscall"
"github.com/hanwen/go-fuse/raw"
) )
const ( const (
...@@ -123,17 +124,6 @@ type EntryOut struct { ...@@ -123,17 +124,6 @@ type EntryOut struct {
Attr Attr
} }
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
}
type AttrOut struct { type AttrOut struct {
AttrValid uint64 AttrValid uint64
AttrValidNsec uint32 AttrValidNsec uint32
...@@ -141,42 +131,6 @@ type AttrOut struct { ...@@ -141,42 +131,6 @@ type AttrOut struct {
Attr Attr
} }
const ( // SetAttrIn.Valid
FATTR_MODE = (1 << 0)
FATTR_UID = (1 << 1)
FATTR_GID = (1 << 2)
FATTR_SIZE = (1 << 3)
FATTR_ATIME = (1 << 4)
FATTR_MTIME = (1 << 5)
FATTR_FH = (1 << 6)
FATTR_ATIME_NOW = (1 << 7)
FATTR_MTIME_NOW = (1 << 8)
FATTR_LOCKOWNER = (1 << 9)
)
type SetAttrIn struct {
Valid uint32
Padding uint32
Fh uint64
Size uint64
LockOwner uint64
Atime uint64
Mtime uint64
Unused2 uint64
Atimensec uint32
Mtimensec uint32
Unused3 uint32
Mode uint32
Unused4 uint32
Owner
Unused5 uint32
}
type OpenIn struct {
Flags uint32
Unused uint32
}
type CreateIn struct { type CreateIn struct {
Flags uint32 Flags uint32
Mode uint32 Mode uint32
...@@ -184,31 +138,9 @@ type CreateIn struct { ...@@ -184,31 +138,9 @@ type CreateIn struct {
Padding uint32 Padding uint32
} }
const (
// OpenOut.Flags
FOPEN_DIRECT_IO = (1 << 0)
FOPEN_KEEP_CACHE = (1 << 1)
FOPEN_NONSEEKABLE = (1 << 2)
)
type OpenOut struct {
Fh uint64
OpenFlags uint32
Padding uint32
}
type CreateOut struct { type CreateOut struct {
EntryOut EntryOut
OpenOut raw.OpenOut
}
const RELEASE_FLUSH = (1 << 0)
type ReleaseIn struct {
Fh uint64
Flags uint32
ReleaseFlags uint32
LockOwner uint64
} }
type FlushIn struct { type FlushIn struct {
......
package raw package raw
import "fmt" import (
"fmt"
"os"
"strings"
"syscall"
)
var releaseFlagNames map[int]string
var OpenFlagNames map[int]string
var FuseOpenFlagNames map[int]string
func init() {
releaseFlagNames = map[int]string{
RELEASE_FLUSH: "FLUSH",
}
OpenFlagNames = map[int]string{
os.O_WRONLY: "WRONLY",
os.O_RDWR: "RDWR",
os.O_APPEND: "APPEND",
syscall.O_ASYNC: "ASYNC",
os.O_CREATE: "CREAT",
os.O_EXCL: "EXCL",
syscall.O_NOCTTY: "NOCTTY",
syscall.O_NONBLOCK: "NONBLOCK",
os.O_SYNC: "SYNC",
os.O_TRUNC: "TRUNC",
syscall.O_CLOEXEC: "CLOEXEC",
syscall.O_DIRECT: "DIRECT",
syscall.O_DIRECTORY: "DIRECTORY",
syscall.O_LARGEFILE: "LARGEFILE",
syscall.O_NOATIME: "NOATIME",
}
FuseOpenFlagNames = map[int]string{
FOPEN_DIRECT_IO: "DIRECT",
FOPEN_KEEP_CACHE: "CACHE",
FOPEN_NONSEEKABLE: "NONSEEK",
}
}
func FlagString(names map[int]string, fl int, def string) string {
s := []string{}
for k, v := range names {
if fl&k != 0 {
s = append(s, v)
fl ^= k
}
}
if len(s) == 0 && def != "" {
s = []string{def}
}
if fl != 0 {
s = append(s, fmt.Sprintf("0x%x", fl))
}
return strings.Join(s, ",")
}
func (me *ForgetIn) String() string { func (me *ForgetIn) String() string {
return fmt.Sprintf("{%d}", me.Nlookup) return fmt.Sprintf("{%d}", me.Nlookup)
...@@ -17,3 +73,54 @@ func (me *MkdirIn) String() string { ...@@ -17,3 +73,54 @@ func (me *MkdirIn) String() string {
func (me *MknodIn) String() string { func (me *MknodIn) String() string {
return fmt.Sprintf("{0%o (0%o), %d}", me.Mode, me.Umask, me.Rdev) return fmt.Sprintf("{0%o (0%o), %d}", me.Mode, me.Umask, me.Rdev)
} }
func (me *SetAttrIn) String() string {
s := []string{}
if me.Valid&FATTR_MODE != 0 {
s = append(s, fmt.Sprintf("mode 0%o", me.Mode))
}
if me.Valid&FATTR_UID != 0 {
s = append(s, fmt.Sprintf("uid %d", me.Uid))
}
if me.Valid&FATTR_GID != 0 {
s = append(s, fmt.Sprintf("uid %d", me.Gid))
}
if me.Valid&FATTR_SIZE != 0 {
s = append(s, fmt.Sprintf("size %d", me.Size))
}
if me.Valid&FATTR_ATIME != 0 {
s = append(s, fmt.Sprintf("atime %d.%09d", me.Atime, me.Atimensec))
}
if me.Valid&FATTR_MTIME != 0 {
s = append(s, fmt.Sprintf("mtime %d.%09d", me.Mtime, me.Mtimensec))
}
if me.Valid&FATTR_MTIME != 0 {
s = append(s, fmt.Sprintf("fh %d", me.Fh))
}
// TODO - FATTR_ATIME_NOW = (1 << 7), FATTR_MTIME_NOW = (1 << 8), FATTR_LOCKOWNER = (1 << 9)
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), ""),
FlagString(releaseFlagNames, int(me.ReleaseFlags), ""),
me.LockOwner)
}
func (me *OpenIn) String() string {
return fmt.Sprintf("{%s}", FlagString(OpenFlagNames, int(me.Flags), "O_RDONLY"))
}
func (me *OpenOut) String() string {
return fmt.Sprintf("{Fh %d %s}", me.Fh,
FlagString(FuseOpenFlagNames, int(me.OpenFlags), ""))
}
...@@ -36,3 +36,77 @@ type MknodIn struct { ...@@ -36,3 +36,77 @@ type MknodIn struct {
Padding uint32 Padding uint32
} }
type Owner struct {
Uid uint32
Gid uint32
}
const ( // SetAttrIn.Valid
FATTR_MODE = (1 << 0)
FATTR_UID = (1 << 1)
FATTR_GID = (1 << 2)
FATTR_SIZE = (1 << 3)
FATTR_ATIME = (1 << 4)
FATTR_MTIME = (1 << 5)
FATTR_FH = (1 << 6)
FATTR_ATIME_NOW = (1 << 7)
FATTR_MTIME_NOW = (1 << 8)
FATTR_LOCKOWNER = (1 << 9)
)
type SetAttrIn struct {
Valid uint32
Padding uint32
Fh uint64
Size uint64
LockOwner uint64
Atime uint64
Mtime uint64
Unused2 uint64
Atimensec uint32
Mtimensec uint32
Unused3 uint32
Mode uint32
Unused4 uint32
Owner
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 {
Fh uint64
Flags uint32
ReleaseFlags uint32
LockOwner uint64
}
type OpenIn struct {
Flags uint32
Unused uint32
}
const (
// OpenOut.Flags
FOPEN_DIRECT_IO = (1 << 0)
FOPEN_KEEP_CACHE = (1 << 1)
FOPEN_NONSEEKABLE = (1 << 2)
)
type OpenOut struct {
Fh uint64
OpenFlags uint32
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