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

Introduce fuse.Context type, and pass it into raw API methods.

parent bf44ee43
...@@ -283,50 +283,50 @@ type DefaultFile struct{} ...@@ -283,50 +283,50 @@ type DefaultFile struct{}
type RawFileSystem interface { type RawFileSystem interface {
String() string String() string
Lookup(out *raw.EntryOut, header *raw.InHeader, name string) (status Status) Lookup(out *raw.EntryOut, context *Context, name string) (status Status)
Forget(nodeid, nlookup uint64) Forget(nodeid, nlookup uint64)
// Attributes. // Attributes.
GetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.GetAttrIn) (code Status) GetAttr(out *raw.AttrOut, context *Context, input *raw.GetAttrIn) (code Status)
SetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.SetAttrIn) (code Status) SetAttr(out *raw.AttrOut, context *Context, input *raw.SetAttrIn) (code Status)
// Modifying structure. // Modifying structure.
Mknod(out *raw.EntryOut, header *raw.InHeader, input *raw.MknodIn, name string) (code Status) Mknod(out *raw.EntryOut, context *Context, input *raw.MknodIn, name string) (code Status)
Mkdir(out *raw.EntryOut, header *raw.InHeader, input *raw.MkdirIn, name string) (code Status) Mkdir(out *raw.EntryOut, context *Context, input *raw.MkdirIn, name string) (code Status)
Unlink(header *raw.InHeader, name string) (code Status) Unlink(context *Context, name string) (code Status)
Rmdir(header *raw.InHeader, name string) (code Status) Rmdir(context *Context, name string) (code Status)
Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) Rename(context *Context, input *raw.RenameIn, oldName string, newName string) (code Status)
Link(out *raw.EntryOut, header *raw.InHeader, input *raw.LinkIn, filename string) (code Status) Link(out *raw.EntryOut, context *Context, input *raw.LinkIn, filename string) (code Status)
Symlink(out *raw.EntryOut, header *raw.InHeader, pointedTo string, linkName string) (code Status) Symlink(out *raw.EntryOut, context *Context, pointedTo string, linkName string) (code Status)
Readlink(header *raw.InHeader) (out []byte, code Status) Readlink(context *Context) (out []byte, code Status)
Access(header *raw.InHeader, input *raw.AccessIn) (code Status) Access(context *Context, input *raw.AccessIn) (code Status)
// Extended attributes. // Extended attributes.
GetXAttrSize(header *raw.InHeader, attr string) (sz int, code Status) GetXAttrSize(context *Context, attr string) (sz int, code Status)
GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status) GetXAttrData(context *Context, attr string) (data []byte, code Status)
ListXAttr(header *raw.InHeader) (attributes []byte, code Status) ListXAttr(context *Context) (attributes []byte, code Status)
SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status SetXAttr(context *Context, input *raw.SetXAttrIn, attr string, data []byte) Status
RemoveXAttr(header *raw.InHeader, attr string) (code Status) RemoveXAttr(context *Context, attr string) (code Status)
// File handling. // File handling.
Create(out *raw.CreateOut, header *raw.InHeader, input *raw.CreateIn, name string) (code Status) Create(out *raw.CreateOut, context *Context, input *raw.CreateIn, name string) (code Status)
Open(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status) Open(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status)
Read(*raw.InHeader, *raw.ReadIn, []byte) (ReadResult, Status) Read(*Context, *raw.ReadIn, []byte) (ReadResult, Status)
Release(header *raw.InHeader, input *raw.ReleaseIn) Release(context *Context, input *raw.ReleaseIn)
Write(*raw.InHeader, *raw.WriteIn, []byte) (written uint32, code Status) Write(*Context, *raw.WriteIn, []byte) (written uint32, code Status)
Flush(header *raw.InHeader, input *raw.FlushIn) Status Flush(context *Context, input *raw.FlushIn) Status
Fsync(*raw.InHeader, *raw.FsyncIn) (code Status) Fsync(*Context, *raw.FsyncIn) (code Status)
// Directory handling // Directory handling
OpenDir(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status) OpenDir(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status)
ReadDir(out *DirEntryList, header *raw.InHeader, input *raw.ReadIn) Status ReadDir(out *DirEntryList, context *Context, input *raw.ReadIn) Status
ReleaseDir(header *raw.InHeader, input *raw.ReleaseIn) ReleaseDir(context *Context, input *raw.ReleaseIn)
FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status) FsyncDir(context *Context, input *raw.FsyncIn) (code Status)
// //
StatFs(out *StatfsOut, eader *raw.InHeader) (code Status) StatFs(out *StatfsOut, context *Context) (code Status)
// Provide callbacks for pushing notifications to the kernel. // Provide callbacks for pushing notifications to the kernel.
Init(params *RawFsInit) Init(params *RawFsInit)
......
...@@ -15,119 +15,119 @@ func (fs *DefaultRawFileSystem) String() string { ...@@ -15,119 +15,119 @@ func (fs *DefaultRawFileSystem) String() string {
return os.Args[0] return os.Args[0]
} }
func (fs *DefaultRawFileSystem) StatFs(out *StatfsOut, h *raw.InHeader) Status { func (fs *DefaultRawFileSystem) StatFs(out *StatfsOut, context *Context) Status {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Lookup(out *raw.EntryOut, h *raw.InHeader, name string) (code Status) { func (fs *DefaultRawFileSystem) Lookup(out *raw.EntryOut, context *Context, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Forget(nodeID, nlookup uint64) { func (fs *DefaultRawFileSystem) Forget(nodeID, nlookup uint64) {
} }
func (fs *DefaultRawFileSystem) GetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.GetAttrIn) (code Status) { func (fs *DefaultRawFileSystem) GetAttr(out *raw.AttrOut, context *Context, input *raw.GetAttrIn) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Open(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status) { func (fs *DefaultRawFileSystem) Open(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status) {
return OK return OK
} }
func (fs *DefaultRawFileSystem) SetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.SetAttrIn) (code Status) { func (fs *DefaultRawFileSystem) SetAttr(out *raw.AttrOut, context *Context, input *raw.SetAttrIn) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Readlink(header *raw.InHeader) (out []byte, code Status) { func (fs *DefaultRawFileSystem) Readlink(context *Context) (out []byte, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (fs *DefaultRawFileSystem) Mknod(out *raw.EntryOut, header *raw.InHeader, input *raw.MknodIn, name string) (code Status) { func (fs *DefaultRawFileSystem) Mknod(out *raw.EntryOut, context *Context, input *raw.MknodIn, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Mkdir(out *raw.EntryOut, header *raw.InHeader, input *raw.MkdirIn, name string) (code Status) { func (fs *DefaultRawFileSystem) Mkdir(out *raw.EntryOut, context *Context, input *raw.MkdirIn, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Unlink(header *raw.InHeader, name string) (code Status) { func (fs *DefaultRawFileSystem) Unlink(context *Context, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Rmdir(header *raw.InHeader, name string) (code Status) { func (fs *DefaultRawFileSystem) Rmdir(context *Context, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Symlink(out *raw.EntryOut, header *raw.InHeader, pointedTo string, linkName string) (code Status) { func (fs *DefaultRawFileSystem) Symlink(out *raw.EntryOut, context *Context, pointedTo string, linkName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) { func (fs *DefaultRawFileSystem) Rename(context *Context, input *raw.RenameIn, oldName string, newName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Link(out *raw.EntryOut, header *raw.InHeader, input *raw.LinkIn, name string) (code Status) { func (fs *DefaultRawFileSystem) Link(out *raw.EntryOut, context *Context, input *raw.LinkIn, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) GetXAttrSize(header *raw.InHeader, attr string) (size int, code Status) { func (fs *DefaultRawFileSystem) GetXAttrSize(context *Context, attr string) (size int, code Status) {
return 0, ENOSYS return 0, ENOSYS
} }
func (fs *DefaultRawFileSystem) GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status) { func (fs *DefaultRawFileSystem) GetXAttrData(context *Context, attr string) (data []byte, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (fs *DefaultRawFileSystem) SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status { func (fs *DefaultRawFileSystem) SetXAttr(context *Context, input *raw.SetXAttrIn, attr string, data []byte) Status {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) ListXAttr(header *raw.InHeader) (data []byte, code Status) { func (fs *DefaultRawFileSystem) ListXAttr(context *Context) (data []byte, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (fs *DefaultRawFileSystem) RemoveXAttr(header *raw.InHeader, attr string) Status { func (fs *DefaultRawFileSystem) RemoveXAttr(context *Context, attr string) Status {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Access(header *raw.InHeader, input *raw.AccessIn) (code Status) { func (fs *DefaultRawFileSystem) Access(context *Context, input *raw.AccessIn) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Create(out *raw.CreateOut, header *raw.InHeader, input *raw.CreateIn, name string) (code Status) { func (fs *DefaultRawFileSystem) Create(out *raw.CreateOut, context *Context, input *raw.CreateIn, name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) OpenDir(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status) { func (fs *DefaultRawFileSystem) OpenDir(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) Read(header *raw.InHeader, input *raw.ReadIn, buf []byte) (ReadResult, Status) { func (fs *DefaultRawFileSystem) Read(context *Context, input *raw.ReadIn, buf []byte) (ReadResult, Status) {
return &ReadResultData{}, ENOSYS return &ReadResultData{}, ENOSYS
} }
func (fs *DefaultRawFileSystem) Release(header *raw.InHeader, input *raw.ReleaseIn) { func (fs *DefaultRawFileSystem) Release(context *Context, input *raw.ReleaseIn) {
} }
func (fs *DefaultRawFileSystem) Write(header *raw.InHeader, input *raw.WriteIn, data []byte) (written uint32, code Status) { func (fs *DefaultRawFileSystem) Write(context *Context, input *raw.WriteIn, data []byte) (written uint32, code Status) {
return 0, ENOSYS return 0, ENOSYS
} }
func (fs *DefaultRawFileSystem) Flush(header *raw.InHeader, input *raw.FlushIn) Status { func (fs *DefaultRawFileSystem) Flush(context *Context, input *raw.FlushIn) Status {
return OK return OK
} }
func (fs *DefaultRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn) (code Status) { func (fs *DefaultRawFileSystem) Fsync(context *Context, input *raw.FsyncIn) (code Status) {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) ReadDir(l *DirEntryList, header *raw.InHeader, input *raw.ReadIn) Status { func (fs *DefaultRawFileSystem) ReadDir(l *DirEntryList, context *Context, input *raw.ReadIn) Status {
return ENOSYS return ENOSYS
} }
func (fs *DefaultRawFileSystem) ReleaseDir(header *raw.InHeader, input *raw.ReleaseIn) { func (fs *DefaultRawFileSystem) ReleaseDir(context *Context, input *raw.ReleaseIn) {
} }
func (fs *DefaultRawFileSystem) FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status) { func (fs *DefaultRawFileSystem) FsyncDir(context *Context, input *raw.FsyncIn) (code Status) {
return ENOSYS return ENOSYS
} }
...@@ -71,13 +71,12 @@ func (c *FileSystemConnector) internalLookup(out *Attr, parent *Inode, name stri ...@@ -71,13 +71,12 @@ func (c *FileSystemConnector) internalLookup(out *Attr, parent *Inode, name stri
return child, code return child, code
} }
func (c *FileSystemConnector) Lookup(out *raw.EntryOut, header *raw.InHeader, name string) (code Status) { func (c *FileSystemConnector) Lookup(out *raw.EntryOut, context *Context, name string) (code Status) {
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
if !parent.IsDir() { if !parent.IsDir() {
log.Printf("Lookup %q called on non-Directory node %d", name, header.NodeId) log.Printf("Lookup %q called on non-Directory node %d", name, context.NodeId)
return ENOTDIR return ENOTDIR
} }
context := (*Context)(&header.Context)
outAttr := (*Attr)(&out.Attr) outAttr := (*Attr)(&out.Attr)
child, code := c.internalLookup(outAttr, parent, name, context) child, code := c.internalLookup(outAttr, parent, name, context)
if code == ENOENT && parent.mount.negativeEntry(out) { if code == ENOENT && parent.mount.negativeEntry(out) {
...@@ -102,8 +101,8 @@ func (c *FileSystemConnector) Forget(nodeID, nlookup uint64) { ...@@ -102,8 +101,8 @@ func (c *FileSystemConnector) Forget(nodeID, nlookup uint64) {
c.forgetUpdate(nodeID, int(nlookup)) c.forgetUpdate(nodeID, int(nlookup))
} }
func (c *FileSystemConnector) GetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.GetAttrIn) (code Status) { func (c *FileSystemConnector) GetAttr(out *raw.AttrOut, context *Context, input *raw.GetAttrIn) (code Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
var f File var f File
if input.Flags&raw.FUSE_GETATTR_FH != 0 { if input.Flags&raw.FUSE_GETATTR_FH != 0 {
...@@ -113,18 +112,18 @@ func (c *FileSystemConnector) GetAttr(out *raw.AttrOut, header *raw.InHeader, in ...@@ -113,18 +112,18 @@ func (c *FileSystemConnector) GetAttr(out *raw.AttrOut, header *raw.InHeader, in
} }
dest := (*Attr)(&out.Attr) dest := (*Attr)(&out.Attr)
code = node.fsInode.GetAttr(dest, f, (*Context)(&header.Context)) code = node.fsInode.GetAttr(dest, f, context)
if !code.Ok() { if !code.Ok() {
return code return code
} }
node.mount.fillAttr(out, header.NodeId) node.mount.fillAttr(out, context.NodeId)
return OK return OK
} }
func (c *FileSystemConnector) OpenDir(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (code Status) { func (c *FileSystemConnector) OpenDir(out *raw.OpenOut, context *Context, input *raw.OpenIn) (code Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
stream, err := node.fsInode.OpenDir((*Context)(&header.Context)) stream, err := node.fsInode.OpenDir(context)
if err != OK { if err != OK {
return err return err
} }
...@@ -139,15 +138,15 @@ func (c *FileSystemConnector) OpenDir(out *raw.OpenOut, header *raw.InHeader, in ...@@ -139,15 +138,15 @@ func (c *FileSystemConnector) OpenDir(out *raw.OpenOut, header *raw.InHeader, in
return OK return OK
} }
func (c *FileSystemConnector) ReadDir(l *DirEntryList, header *raw.InHeader, input *raw.ReadIn) Status { func (c *FileSystemConnector) ReadDir(l *DirEntryList, context *Context, input *raw.ReadIn) Status {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
return opened.dir.ReadDir(l, input) return opened.dir.ReadDir(l, input)
} }
func (c *FileSystemConnector) Open(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status) { func (c *FileSystemConnector) Open(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
f, code := node.fsInode.Open(input.Flags, (*Context)(&header.Context)) f, code := node.fsInode.Open(input.Flags, context)
if !code.Ok() { if !code.Ok() {
return code return code
} }
...@@ -157,8 +156,8 @@ func (c *FileSystemConnector) Open(out *raw.OpenOut, header *raw.InHeader, input ...@@ -157,8 +156,8 @@ func (c *FileSystemConnector) Open(out *raw.OpenOut, header *raw.InHeader, input
return OK return OK
} }
func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.SetAttrIn) (code Status) { func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, context *Context, input *raw.SetAttrIn) (code Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
var f File var f File
if input.Valid&raw.FATTR_FH != 0 { if input.Valid&raw.FATTR_FH != 0 {
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
...@@ -167,13 +166,13 @@ func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, in ...@@ -167,13 +166,13 @@ func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, in
if code.Ok() && input.Valid&raw.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, (*Context)(&header.Context)) code = node.fsInode.Chmod(f, permissions, context)
} }
if code.Ok() && (input.Valid&(raw.FATTR_UID|raw.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), (*Context)(&header.Context)) code = node.fsInode.Chown(f, uint32(input.Uid), uint32(input.Gid), context)
} }
if code.Ok() && input.Valid&raw.FATTR_SIZE != 0 { if code.Ok() && input.Valid&raw.FATTR_SIZE != 0 {
code = node.fsInode.Truncate(f, input.Size, (*Context)(&header.Context)) code = node.fsInode.Truncate(f, input.Size, context)
} }
if code.Ok() && (input.Valid&(raw.FATTR_ATIME|raw.FATTR_MTIME|raw.FATTR_ATIME_NOW|raw.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 := time.Now() now := time.Now()
...@@ -198,7 +197,7 @@ func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, in ...@@ -198,7 +197,7 @@ func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, in
} }
} }
code = node.fsInode.Utimens(f, atime, mtime, (*Context)(&header.Context)) code = node.fsInode.Utimens(f, atime, mtime, context)
} }
if !code.Ok() { if !code.Ok() {
...@@ -208,21 +207,21 @@ func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, in ...@@ -208,21 +207,21 @@ func (c *FileSystemConnector) SetAttr(out *raw.AttrOut, header *raw.InHeader, in
// Must call GetAttr(); the filesystem may override some of // Must call GetAttr(); the filesystem may override some of
// the changes we effect here. // the changes we effect here.
attr := (*Attr)(&out.Attr) attr := (*Attr)(&out.Attr)
code = node.fsInode.GetAttr(attr, nil, (*Context)(&header.Context)) code = node.fsInode.GetAttr(attr, nil, context)
if code.Ok() { if code.Ok() {
node.mount.fillAttr(out, header.NodeId) node.mount.fillAttr(out, context.NodeId)
} }
return code return code
} }
func (c *FileSystemConnector) Readlink(header *raw.InHeader) (out []byte, code Status) { func (c *FileSystemConnector) Readlink(context *Context) (out []byte, code Status) {
n := c.toInode(header.NodeId) n := c.toInode(context.NodeId)
return n.fsInode.Readlink((*Context)(&header.Context)) return n.fsInode.Readlink(context)
} }
func (c *FileSystemConnector) Mknod(out *raw.EntryOut, header *raw.InHeader, input *raw.MknodIn, name string) (code Status) { func (c *FileSystemConnector) Mknod(out *raw.EntryOut, context *Context, input *raw.MknodIn, name string) (code Status) {
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
ctx := (*Context)(&header.Context) ctx := context
fsNode, code := parent.fsInode.Mknod(name, input.Mode, uint32(input.Rdev), ctx) fsNode, code := parent.fsInode.Mknod(name, input.Mode, uint32(input.Rdev), ctx)
if code.Ok() { if code.Ok() {
c.childLookup(out, fsNode) c.childLookup(out, fsNode)
...@@ -231,9 +230,9 @@ func (c *FileSystemConnector) Mknod(out *raw.EntryOut, header *raw.InHeader, inp ...@@ -231,9 +230,9 @@ func (c *FileSystemConnector) Mknod(out *raw.EntryOut, header *raw.InHeader, inp
return code return code
} }
func (c *FileSystemConnector) Mkdir(out *raw.EntryOut, header *raw.InHeader, input *raw.MkdirIn, name string) (code Status) { func (c *FileSystemConnector) Mkdir(out *raw.EntryOut, context *Context, input *raw.MkdirIn, name string) (code Status) {
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
ctx := (*Context)(&header.Context) ctx := context
fsNode, code := parent.fsInode.Mkdir(name, input.Mode, ctx) fsNode, code := parent.fsInode.Mkdir(name, input.Mode, ctx)
if code.Ok() { if code.Ok() {
c.childLookup(out, fsNode) c.childLookup(out, fsNode)
...@@ -242,19 +241,19 @@ func (c *FileSystemConnector) Mkdir(out *raw.EntryOut, header *raw.InHeader, inp ...@@ -242,19 +241,19 @@ func (c *FileSystemConnector) Mkdir(out *raw.EntryOut, header *raw.InHeader, inp
return code return code
} }
func (c *FileSystemConnector) Unlink(header *raw.InHeader, name string) (code Status) { func (c *FileSystemConnector) Unlink(context *Context, name string) (code Status) {
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
return parent.fsInode.Unlink(name, (*Context)(&header.Context)) return parent.fsInode.Unlink(name, context)
} }
func (c *FileSystemConnector) Rmdir(header *raw.InHeader, name string) (code Status) { func (c *FileSystemConnector) Rmdir(context *Context, name string) (code Status) {
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
return parent.fsInode.Rmdir(name, (*Context)(&header.Context)) return parent.fsInode.Rmdir(name, context)
} }
func (c *FileSystemConnector) Symlink(out *raw.EntryOut, header *raw.InHeader, pointedTo string, linkName string) (code Status) { func (c *FileSystemConnector) Symlink(out *raw.EntryOut, context *Context, pointedTo string, linkName string) (code Status) {
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
ctx := (*Context)(&header.Context) ctx := context
fsNode, code := parent.fsInode.Symlink(linkName, pointedTo, ctx) fsNode, code := parent.fsInode.Symlink(linkName, pointedTo, ctx)
if code.Ok() { if code.Ok() {
c.childLookup(out, fsNode) c.childLookup(out, fsNode)
...@@ -263,8 +262,8 @@ func (c *FileSystemConnector) Symlink(out *raw.EntryOut, header *raw.InHeader, p ...@@ -263,8 +262,8 @@ func (c *FileSystemConnector) Symlink(out *raw.EntryOut, header *raw.InHeader, p
return code return code
} }
func (c *FileSystemConnector) Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) { func (c *FileSystemConnector) Rename(context *Context, input *raw.RenameIn, oldName string, newName string) (code Status) {
oldParent := c.toInode(header.NodeId) oldParent := c.toInode(context.NodeId)
child := oldParent.GetChild(oldName) child := oldParent.GetChild(oldName)
if child.mountPoint != nil { if child.mountPoint != nil {
...@@ -276,17 +275,17 @@ func (c *FileSystemConnector) Rename(header *raw.InHeader, input *raw.RenameIn, ...@@ -276,17 +275,17 @@ func (c *FileSystemConnector) Rename(header *raw.InHeader, input *raw.RenameIn,
return EXDEV return EXDEV
} }
return oldParent.fsInode.Rename(oldName, newParent.fsInode, newName, (*Context)(&header.Context)) return oldParent.fsInode.Rename(oldName, newParent.fsInode, newName, context)
} }
func (c *FileSystemConnector) Link(out *raw.EntryOut, header *raw.InHeader, input *raw.LinkIn, name string) (code Status) { func (c *FileSystemConnector) Link(out *raw.EntryOut, context *Context, input *raw.LinkIn, name string) (code Status) {
existing := c.toInode(input.Oldnodeid) existing := c.toInode(input.Oldnodeid)
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
if existing.mount != parent.mount { if existing.mount != parent.mount {
return EXDEV return EXDEV
} }
ctx := (*Context)(&header.Context) ctx := context
fsNode, code := parent.fsInode.Link(name, existing.fsInode, ctx) fsNode, code := parent.fsInode.Link(name, existing.fsInode, ctx)
if code.Ok() { if code.Ok() {
c.childLookup(out, fsNode) c.childLookup(out, fsNode)
...@@ -296,14 +295,14 @@ func (c *FileSystemConnector) Link(out *raw.EntryOut, header *raw.InHeader, inpu ...@@ -296,14 +295,14 @@ func (c *FileSystemConnector) Link(out *raw.EntryOut, header *raw.InHeader, inpu
return code return code
} }
func (c *FileSystemConnector) Access(header *raw.InHeader, input *raw.AccessIn) (code Status) { func (c *FileSystemConnector) Access(context *Context, input *raw.AccessIn) (code Status) {
n := c.toInode(header.NodeId) n := c.toInode(context.NodeId)
return n.fsInode.Access(input.Mask, (*Context)(&header.Context)) return n.fsInode.Access(input.Mask, context)
} }
func (c *FileSystemConnector) Create(out *raw.CreateOut, header *raw.InHeader, input *raw.CreateIn, name string) (code Status) { func (c *FileSystemConnector) Create(out *raw.CreateOut, context *Context, input *raw.CreateIn, name string) (code Status) {
parent := c.toInode(header.NodeId) parent := c.toInode(context.NodeId)
f, fsNode, code := parent.fsInode.Create(name, uint32(input.Flags), input.Mode, (*Context)(&header.Context)) f, fsNode, code := parent.fsInode.Create(name, uint32(input.Flags), input.Mode, context)
if !code.Ok() { if !code.Ok() {
return code return code
} }
...@@ -316,42 +315,42 @@ func (c *FileSystemConnector) Create(out *raw.CreateOut, header *raw.InHeader, i ...@@ -316,42 +315,42 @@ func (c *FileSystemConnector) Create(out *raw.CreateOut, header *raw.InHeader, i
return code return code
} }
func (c *FileSystemConnector) Release(header *raw.InHeader, input *raw.ReleaseIn) { func (c *FileSystemConnector) Release(context *Context, input *raw.ReleaseIn) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
opened := node.mount.unregisterFileHandle(input.Fh, node) opened := node.mount.unregisterFileHandle(input.Fh, node)
opened.WithFlags.File.Release() opened.WithFlags.File.Release()
} }
func (c *FileSystemConnector) ReleaseDir(header *raw.InHeader, input *raw.ReleaseIn) { func (c *FileSystemConnector) ReleaseDir(context *Context, input *raw.ReleaseIn) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
opened := node.mount.unregisterFileHandle(input.Fh, node) opened := node.mount.unregisterFileHandle(input.Fh, node)
opened.dir.Release() opened.dir.Release()
} }
func (c *FileSystemConnector) GetXAttrSize(header *raw.InHeader, attribute string) (sz int, code Status) { func (c *FileSystemConnector) GetXAttrSize(context *Context, attribute string) (sz int, code Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
data, errno := node.fsInode.GetXAttr(attribute, (*Context)(&header.Context)) data, errno := node.fsInode.GetXAttr(attribute, context)
return len(data), errno return len(data), errno
} }
func (c *FileSystemConnector) GetXAttrData(header *raw.InHeader, attribute string) (data []byte, code Status) { func (c *FileSystemConnector) GetXAttrData(context *Context, attribute string) (data []byte, code Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
return node.fsInode.GetXAttr(attribute, (*Context)(&header.Context)) return node.fsInode.GetXAttr(attribute, context)
} }
func (c *FileSystemConnector) RemoveXAttr(header *raw.InHeader, attr string) Status { func (c *FileSystemConnector) RemoveXAttr(context *Context, attr string) Status {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
return node.fsInode.RemoveXAttr(attr, (*Context)(&header.Context)) return node.fsInode.RemoveXAttr(attr, context)
} }
func (c *FileSystemConnector) SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status { func (c *FileSystemConnector) SetXAttr(context *Context, input *raw.SetXAttrIn, attr string, data []byte) Status {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
return node.fsInode.SetXAttr(attr, data, int(input.Flags), (*Context)(&header.Context)) return node.fsInode.SetXAttr(attr, data, int(input.Flags), context)
} }
func (c *FileSystemConnector) ListXAttr(header *raw.InHeader) (data []byte, code Status) { func (c *FileSystemConnector) ListXAttr(context *Context) (data []byte, code Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
attrs, code := node.fsInode.ListXAttr((*Context)(&header.Context)) attrs, code := node.fsInode.ListXAttr(context)
if code != OK { if code != OK {
return nil, code return nil, code
} }
...@@ -368,21 +367,21 @@ func (c *FileSystemConnector) ListXAttr(header *raw.InHeader) (data []byte, code ...@@ -368,21 +367,21 @@ func (c *FileSystemConnector) ListXAttr(header *raw.InHeader) (data []byte, code
//////////////// ////////////////
// files. // files.
func (c *FileSystemConnector) Write(header *raw.InHeader, input *raw.WriteIn, data []byte) (written uint32, code Status) { func (c *FileSystemConnector) Write(context *Context, input *raw.WriteIn, data []byte) (written uint32, code Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Write(data, int64(input.Offset)) return opened.WithFlags.File.Write(data, int64(input.Offset))
} }
func (c *FileSystemConnector) Read(header *raw.InHeader, input *raw.ReadIn, buf []byte) (ReadResult, Status) { func (c *FileSystemConnector) Read(context *Context, input *raw.ReadIn, buf []byte) (ReadResult, Status) {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Read(buf, int64(input.Offset)) return opened.WithFlags.File.Read(buf, int64(input.Offset))
} }
func (c *FileSystemConnector) StatFs(out *StatfsOut, header *raw.InHeader) Status { func (c *FileSystemConnector) StatFs(out *StatfsOut, context *Context) Status {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
s := node.FsNode().StatFs() s := node.FsNode().StatFs()
if s == nil { if s == nil {
return ENOSYS return ENOSYS
...@@ -391,8 +390,8 @@ func (c *FileSystemConnector) StatFs(out *StatfsOut, header *raw.InHeader) Statu ...@@ -391,8 +390,8 @@ func (c *FileSystemConnector) StatFs(out *StatfsOut, header *raw.InHeader) Statu
return OK return OK
} }
func (c *FileSystemConnector) Flush(header *raw.InHeader, input *raw.FlushIn) Status { func (c *FileSystemConnector) Flush(context *Context, input *raw.FlushIn) Status {
node := c.toInode(header.NodeId) node := c.toInode(context.NodeId)
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Flush() return opened.WithFlags.File.Flush()
} }
...@@ -163,7 +163,7 @@ func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem { ...@@ -163,7 +163,7 @@ func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem {
return l return l
} }
func (fs *LockingRawFileSystem) Lookup(out *raw.EntryOut, h *raw.InHeader, name string) (code Status) { func (fs *LockingRawFileSystem) Lookup(out *raw.EntryOut, h *Context, name string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Lookup(out, h, name) return fs.RawFileSystem.Lookup(out, h, name)
} }
...@@ -173,138 +173,138 @@ func (fs *LockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) { ...@@ -173,138 +173,138 @@ func (fs *LockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) {
fs.RawFileSystem.Forget(nodeID, nlookup) fs.RawFileSystem.Forget(nodeID, nlookup)
} }
func (fs *LockingRawFileSystem) GetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.GetAttrIn) (code Status) { func (fs *LockingRawFileSystem) GetAttr(out *raw.AttrOut, header *Context, input *raw.GetAttrIn) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.GetAttr(out, header, input) return fs.RawFileSystem.GetAttr(out, header, input)
} }
func (fs *LockingRawFileSystem) Open(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status) { func (fs *LockingRawFileSystem) Open(out *raw.OpenOut, header *Context, input *raw.OpenIn) (status Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Open(out, header, input) return fs.RawFileSystem.Open(out, header, input)
} }
func (fs *LockingRawFileSystem) SetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.SetAttrIn) (code Status) { func (fs *LockingRawFileSystem) SetAttr(out *raw.AttrOut, header *Context, input *raw.SetAttrIn) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.SetAttr(out, header, input) return fs.RawFileSystem.SetAttr(out, header, input)
} }
func (fs *LockingRawFileSystem) Readlink(header *raw.InHeader) (out []byte, code Status) { func (fs *LockingRawFileSystem) Readlink(header *Context) (out []byte, code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Readlink(header) return fs.RawFileSystem.Readlink(header)
} }
func (fs *LockingRawFileSystem) Mknod(out *raw.EntryOut, header *raw.InHeader, input *raw.MknodIn, name string) (code Status) { func (fs *LockingRawFileSystem) Mknod(out *raw.EntryOut, header *Context, input *raw.MknodIn, name string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Mknod(out, header, input, name) return fs.RawFileSystem.Mknod(out, header, input, name)
} }
func (fs *LockingRawFileSystem) Mkdir(out *raw.EntryOut, header *raw.InHeader, input *raw.MkdirIn, name string) (code Status) { func (fs *LockingRawFileSystem) Mkdir(out *raw.EntryOut, header *Context, input *raw.MkdirIn, name string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Mkdir(out, header, input, name) return fs.RawFileSystem.Mkdir(out, header, input, name)
} }
func (fs *LockingRawFileSystem) Unlink(header *raw.InHeader, name string) (code Status) { func (fs *LockingRawFileSystem) Unlink(header *Context, name string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Unlink(header, name) return fs.RawFileSystem.Unlink(header, name)
} }
func (fs *LockingRawFileSystem) Rmdir(header *raw.InHeader, name string) (code Status) { func (fs *LockingRawFileSystem) Rmdir(header *Context, name string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Rmdir(header, name) return fs.RawFileSystem.Rmdir(header, name)
} }
func (fs *LockingRawFileSystem) Symlink(out *raw.EntryOut, header *raw.InHeader, pointedTo string, linkName string) (code Status) { func (fs *LockingRawFileSystem) Symlink(out *raw.EntryOut, header *Context, pointedTo string, linkName string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Symlink(out, header, pointedTo, linkName) return fs.RawFileSystem.Symlink(out, header, pointedTo, linkName)
} }
func (fs *LockingRawFileSystem) Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) { func (fs *LockingRawFileSystem) Rename(header *Context, input *raw.RenameIn, oldName string, newName string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Rename(header, input, oldName, newName) return fs.RawFileSystem.Rename(header, input, oldName, newName)
} }
func (fs *LockingRawFileSystem) Link(out *raw.EntryOut, header *raw.InHeader, input *raw.LinkIn, name string) (code Status) { func (fs *LockingRawFileSystem) Link(out *raw.EntryOut, header *Context, input *raw.LinkIn, name string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Link(out, header, input, name) return fs.RawFileSystem.Link(out, header, input, name)
} }
func (fs *LockingRawFileSystem) SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status { func (fs *LockingRawFileSystem) SetXAttr(header *Context, input *raw.SetXAttrIn, attr string, data []byte) Status {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.SetXAttr(header, input, attr, data) return fs.RawFileSystem.SetXAttr(header, input, attr, data)
} }
func (fs *LockingRawFileSystem) GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status) { func (fs *LockingRawFileSystem) GetXAttrData(header *Context, attr string) (data []byte, code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.GetXAttrData(header, attr) return fs.RawFileSystem.GetXAttrData(header, attr)
} }
func (fs *LockingRawFileSystem) GetXAttrSize(header *raw.InHeader, attr string) (sz int, code Status) { func (fs *LockingRawFileSystem) GetXAttrSize(header *Context, attr string) (sz int, code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.GetXAttrSize(header, attr) return fs.RawFileSystem.GetXAttrSize(header, attr)
} }
func (fs *LockingRawFileSystem) ListXAttr(header *raw.InHeader) (data []byte, code Status) { func (fs *LockingRawFileSystem) ListXAttr(header *Context) (data []byte, code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.ListXAttr(header) return fs.RawFileSystem.ListXAttr(header)
} }
func (fs *LockingRawFileSystem) RemoveXAttr(header *raw.InHeader, attr string) Status { func (fs *LockingRawFileSystem) RemoveXAttr(header *Context, attr string) Status {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.RemoveXAttr(header, attr) return fs.RawFileSystem.RemoveXAttr(header, attr)
} }
func (fs *LockingRawFileSystem) Access(header *raw.InHeader, input *raw.AccessIn) (code Status) { func (fs *LockingRawFileSystem) Access(header *Context, input *raw.AccessIn) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Access(header, input) return fs.RawFileSystem.Access(header, input)
} }
func (fs *LockingRawFileSystem) Create(out *raw.CreateOut, header *raw.InHeader, input *raw.CreateIn, name string) (code Status) { func (fs *LockingRawFileSystem) Create(out *raw.CreateOut, header *Context, input *raw.CreateIn, name string) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Create(out, header, input, name) return fs.RawFileSystem.Create(out, header, input, name)
} }
func (fs *LockingRawFileSystem) OpenDir(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status) { func (fs *LockingRawFileSystem) OpenDir(out *raw.OpenOut, header *Context, input *raw.OpenIn) (status Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.OpenDir(out, header, input) return fs.RawFileSystem.OpenDir(out, header, input)
} }
func (fs *LockingRawFileSystem) Release(header *raw.InHeader, input *raw.ReleaseIn) { func (fs *LockingRawFileSystem) Release(header *Context, input *raw.ReleaseIn) {
defer fs.locked()() defer fs.locked()()
fs.RawFileSystem.Release(header, input) fs.RawFileSystem.Release(header, input)
} }
func (fs *LockingRawFileSystem) ReleaseDir(header *raw.InHeader, h *raw.ReleaseIn) { func (fs *LockingRawFileSystem) ReleaseDir(header *Context, h *raw.ReleaseIn) {
defer fs.locked()() defer fs.locked()()
fs.RawFileSystem.ReleaseDir(header, h) fs.RawFileSystem.ReleaseDir(header, h)
} }
func (fs *LockingRawFileSystem) Read(header *raw.InHeader, input *raw.ReadIn, buf []byte) (ReadResult, Status) { func (fs *LockingRawFileSystem) Read(header *Context, input *raw.ReadIn, buf []byte) (ReadResult, Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Read(header, input, buf) return fs.RawFileSystem.Read(header, input, buf)
} }
func (fs *LockingRawFileSystem) Write(header *raw.InHeader, input *raw.WriteIn, data []byte) (written uint32, code Status) { func (fs *LockingRawFileSystem) Write(header *Context, input *raw.WriteIn, data []byte) (written uint32, code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Write(header, input, data) return fs.RawFileSystem.Write(header, input, data)
} }
func (fs *LockingRawFileSystem) Flush(header *raw.InHeader, input *raw.FlushIn) Status { func (fs *LockingRawFileSystem) Flush(header *Context, input *raw.FlushIn) Status {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Flush(header, input) return fs.RawFileSystem.Flush(header, input)
} }
func (fs *LockingRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn) (code Status) { func (fs *LockingRawFileSystem) Fsync(header *Context, input *raw.FsyncIn) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.Fsync(header, input) return fs.RawFileSystem.Fsync(header, input)
} }
func (fs *LockingRawFileSystem) ReadDir(out *DirEntryList, header *raw.InHeader, input *raw.ReadIn) Status { func (fs *LockingRawFileSystem) ReadDir(out *DirEntryList, header *Context, input *raw.ReadIn) Status {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.ReadDir(out, header, input) return fs.RawFileSystem.ReadDir(out, header, input)
} }
func (fs *LockingRawFileSystem) FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status) { func (fs *LockingRawFileSystem) FsyncDir(header *Context, input *raw.FsyncIn) (code Status) {
defer fs.locked()() defer fs.locked()()
return fs.RawFileSystem.FsyncDir(header, input) return fs.RawFileSystem.FsyncDir(header, input)
} }
...@@ -116,7 +116,7 @@ func doInit(state *MountState, req *request) { ...@@ -116,7 +116,7 @@ func doInit(state *MountState, req *request) {
func doOpen(state *MountState, req *request) { func doOpen(state *MountState, req *request) {
out := (*raw.OpenOut)(req.outData) out := (*raw.OpenOut)(req.outData)
status := state.fileSystem.Open(out, req.inHeader, (*raw.OpenIn)(req.inData)) status := state.fileSystem.Open(out, &req.context, (*raw.OpenIn)(req.inData))
req.status = status req.status = status
if status != OK { if status != OK {
return return
...@@ -125,7 +125,7 @@ func doOpen(state *MountState, req *request) { ...@@ -125,7 +125,7 @@ func doOpen(state *MountState, req *request) {
func doCreate(state *MountState, req *request) { func doCreate(state *MountState, req *request) {
out := (*raw.CreateOut)(req.outData) out := (*raw.CreateOut)(req.outData)
status := state.fileSystem.Create(out, req.inHeader, (*raw.CreateIn)(req.inData), req.filenames[0]) status := state.fileSystem.Create(out, &req.context, (*raw.CreateIn)(req.inData), req.filenames[0])
req.status = status req.status = status
} }
...@@ -134,24 +134,24 @@ func doReadDir(state *MountState, req *request) { ...@@ -134,24 +134,24 @@ func doReadDir(state *MountState, req *request) {
buf := state.AllocOut(req, in.Size) buf := state.AllocOut(req, in.Size)
entries := NewDirEntryList(buf, uint64(in.Offset)) entries := NewDirEntryList(buf, uint64(in.Offset))
code := state.fileSystem.ReadDir(entries, req.inHeader, in) code := state.fileSystem.ReadDir(entries, &req.context, in)
req.flatData = entries.Bytes() req.flatData = entries.Bytes()
req.status = code req.status = code
} }
func doOpenDir(state *MountState, req *request) { func doOpenDir(state *MountState, req *request) {
out := (*raw.OpenOut)(req.outData) out := (*raw.OpenOut)(req.outData)
status := state.fileSystem.OpenDir(out, req.inHeader, (*raw.OpenIn)(req.inData)) status := state.fileSystem.OpenDir(out, &req.context, (*raw.OpenIn)(req.inData))
req.status = status req.status = status
} }
func doSetattr(state *MountState, req *request) { func doSetattr(state *MountState, req *request) {
out := (*raw.AttrOut)(req.outData) out := (*raw.AttrOut)(req.outData)
req.status = state.fileSystem.SetAttr(out, req.inHeader, (*raw.SetAttrIn)(req.inData)) req.status = state.fileSystem.SetAttr(out, &req.context, (*raw.SetAttrIn)(req.inData))
} }
func doWrite(state *MountState, req *request) { func doWrite(state *MountState, req *request) {
n, status := state.fileSystem.Write(req.inHeader, (*raw.WriteIn)(req.inData), req.arg) n, status := state.fileSystem.Write(&req.context, (*raw.WriteIn)(req.inData), req.arg)
o := (*raw.WriteOut)(req.outData) o := (*raw.WriteOut)(req.outData)
o.Size = n o.Size = n
req.status = status req.status = status
...@@ -177,14 +177,14 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -177,14 +177,14 @@ func doGetXAttr(state *MountState, req *request) {
out := (*raw.GetXAttrOut)(req.outData) out := (*raw.GetXAttrOut)(req.outData)
switch req.inHeader.Opcode { switch req.inHeader.Opcode {
case _OP_GETXATTR: case _OP_GETXATTR:
sz, code := state.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0]) sz, code := state.fileSystem.GetXAttrSize(&req.context, req.filenames[0])
if code.Ok() { if code.Ok() {
out.Size = uint32(sz) out.Size = uint32(sz)
} }
req.status = code req.status = code
return return
case _OP_LISTXATTR: case _OP_LISTXATTR:
data, code := state.fileSystem.ListXAttr(req.inHeader) data, code := state.fileSystem.ListXAttr(&req.context)
if code.Ok() { if code.Ok() {
out.Size = uint32(len(data)) out.Size = uint32(len(data))
} }
...@@ -197,9 +197,9 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -197,9 +197,9 @@ func doGetXAttr(state *MountState, req *request) {
var data []byte var data []byte
switch req.inHeader.Opcode { switch req.inHeader.Opcode {
case _OP_GETXATTR: case _OP_GETXATTR:
data, req.status = state.fileSystem.GetXAttrData(req.inHeader, req.filenames[0]) data, req.status = state.fileSystem.GetXAttrData(&req.context, req.filenames[0])
case _OP_LISTXATTR: case _OP_LISTXATTR:
data, req.status = state.fileSystem.ListXAttr(req.inHeader) data, req.status = state.fileSystem.ListXAttr(&req.context)
default: default:
log.Panicf("xattr opcode %v", req.inHeader.Opcode) log.Panicf("xattr opcode %v", req.inHeader.Opcode)
req.status = ENOSYS req.status = ENOSYS
...@@ -218,7 +218,7 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -218,7 +218,7 @@ func doGetXAttr(state *MountState, req *request) {
func doGetAttr(state *MountState, req *request) { func doGetAttr(state *MountState, req *request) {
attrOut := (*raw.AttrOut)(req.outData) attrOut := (*raw.AttrOut)(req.outData)
s := state.fileSystem.GetAttr(attrOut, req.inHeader, (*raw.GetAttrIn)(req.inData)) s := state.fileSystem.GetAttr(attrOut, &req.context, (*raw.GetAttrIn)(req.inData))
req.status = s req.status = s
} }
...@@ -246,12 +246,12 @@ func doBatchForget(state *MountState, req *request) { ...@@ -246,12 +246,12 @@ func doBatchForget(state *MountState, req *request) {
} }
func doReadlink(state *MountState, req *request) { func doReadlink(state *MountState, req *request) {
req.flatData, req.status = state.fileSystem.Readlink(req.inHeader) req.flatData, req.status = state.fileSystem.Readlink(&req.context)
} }
func doLookup(state *MountState, req *request) { func doLookup(state *MountState, req *request) {
lookupOut := (*raw.EntryOut)(req.outData) lookupOut := (*raw.EntryOut)(req.outData)
s := state.fileSystem.Lookup(lookupOut, req.inHeader, req.filenames[0]) s := state.fileSystem.Lookup(lookupOut, &req.context, req.filenames[0])
req.status = s req.status = s
req.outData = unsafe.Pointer(lookupOut) req.outData = unsafe.Pointer(lookupOut)
} }
...@@ -259,25 +259,25 @@ func doLookup(state *MountState, req *request) { ...@@ -259,25 +259,25 @@ func doLookup(state *MountState, req *request) {
func doMknod(state *MountState, req *request) { func doMknod(state *MountState, req *request) {
out := (*raw.EntryOut)(req.outData) out := (*raw.EntryOut)(req.outData)
req.status = state.fileSystem.Mknod(out, req.inHeader, (*raw.MknodIn)(req.inData), req.filenames[0]) req.status = state.fileSystem.Mknod(out, &req.context, (*raw.MknodIn)(req.inData), req.filenames[0])
} }
func doMkdir(state *MountState, req *request) { func doMkdir(state *MountState, req *request) {
out := (*raw.EntryOut)(req.outData) out := (*raw.EntryOut)(req.outData)
req.status = state.fileSystem.Mkdir(out, req.inHeader, (*raw.MkdirIn)(req.inData), req.filenames[0]) req.status = state.fileSystem.Mkdir(out, &req.context, (*raw.MkdirIn)(req.inData), req.filenames[0])
} }
func doUnlink(state *MountState, req *request) { func doUnlink(state *MountState, req *request) {
req.status = state.fileSystem.Unlink(req.inHeader, req.filenames[0]) req.status = state.fileSystem.Unlink(&req.context, req.filenames[0])
} }
func doRmdir(state *MountState, req *request) { func doRmdir(state *MountState, req *request) {
req.status = state.fileSystem.Rmdir(req.inHeader, req.filenames[0]) req.status = state.fileSystem.Rmdir(&req.context, req.filenames[0])
} }
func doLink(state *MountState, req *request) { func doLink(state *MountState, req *request) {
out := (*raw.EntryOut)(req.outData) out := (*raw.EntryOut)(req.outData)
req.status = state.fileSystem.Link(out, req.inHeader, (*raw.LinkIn)(req.inData), req.filenames[0]) req.status = state.fileSystem.Link(out, &req.context, (*raw.LinkIn)(req.inData), req.filenames[0])
} }
func doRead(state *MountState, req *request) { func doRead(state *MountState, req *request) {
...@@ -285,7 +285,7 @@ func doRead(state *MountState, req *request) { ...@@ -285,7 +285,7 @@ func doRead(state *MountState, req *request) {
buf := state.AllocOut(req, in.Size) buf := state.AllocOut(req, in.Size)
var r ReadResult var r ReadResult
r, req.status = state.fileSystem.Read(req.inHeader, in, buf) r, req.status = state.fileSystem.Read(&req.context, in, buf)
if fd, ok := r.(*ReadResultFd); ok { if fd, ok := r.(*ReadResultFd); ok {
req.fdData = fd req.fdData = fd
req.flatData = nil req.flatData = nil
...@@ -295,50 +295,50 @@ func doRead(state *MountState, req *request) { ...@@ -295,50 +295,50 @@ func doRead(state *MountState, req *request) {
} }
func doFlush(state *MountState, req *request) { func doFlush(state *MountState, req *request) {
req.status = state.fileSystem.Flush(req.inHeader, (*raw.FlushIn)(req.inData)) req.status = state.fileSystem.Flush(&req.context, (*raw.FlushIn)(req.inData))
} }
func doRelease(state *MountState, req *request) { func doRelease(state *MountState, req *request) {
state.fileSystem.Release(req.inHeader, (*raw.ReleaseIn)(req.inData)) state.fileSystem.Release(&req.context, (*raw.ReleaseIn)(req.inData))
} }
func doFsync(state *MountState, req *request) { func doFsync(state *MountState, req *request) {
req.status = state.fileSystem.Fsync(req.inHeader, (*raw.FsyncIn)(req.inData)) req.status = state.fileSystem.Fsync(&req.context, (*raw.FsyncIn)(req.inData))
} }
func doReleaseDir(state *MountState, req *request) { func doReleaseDir(state *MountState, req *request) {
state.fileSystem.ReleaseDir(req.inHeader, (*raw.ReleaseIn)(req.inData)) state.fileSystem.ReleaseDir(&req.context, (*raw.ReleaseIn)(req.inData))
} }
func doFsyncDir(state *MountState, req *request) { func doFsyncDir(state *MountState, req *request) {
req.status = state.fileSystem.FsyncDir(req.inHeader, (*raw.FsyncIn)(req.inData)) req.status = state.fileSystem.FsyncDir(&req.context, (*raw.FsyncIn)(req.inData))
} }
func doSetXAttr(state *MountState, req *request) { func doSetXAttr(state *MountState, req *request) {
splits := bytes.SplitN(req.arg, []byte{0}, 2) splits := bytes.SplitN(req.arg, []byte{0}, 2)
req.status = state.fileSystem.SetXAttr(req.inHeader, (*raw.SetXAttrIn)(req.inData), string(splits[0]), splits[1]) req.status = state.fileSystem.SetXAttr(&req.context, (*raw.SetXAttrIn)(req.inData), string(splits[0]), splits[1])
} }
func doRemoveXAttr(state *MountState, req *request) { func doRemoveXAttr(state *MountState, req *request) {
req.status = state.fileSystem.RemoveXAttr(req.inHeader, req.filenames[0]) req.status = state.fileSystem.RemoveXAttr(&req.context, req.filenames[0])
} }
func doAccess(state *MountState, req *request) { func doAccess(state *MountState, req *request) {
req.status = state.fileSystem.Access(req.inHeader, (*raw.AccessIn)(req.inData)) req.status = state.fileSystem.Access(&req.context, (*raw.AccessIn)(req.inData))
} }
func doSymlink(state *MountState, req *request) { func doSymlink(state *MountState, req *request) {
out := (*raw.EntryOut)(req.outData) out := (*raw.EntryOut)(req.outData)
req.status = state.fileSystem.Symlink(out, req.inHeader, req.filenames[1], req.filenames[0]) req.status = state.fileSystem.Symlink(out, &req.context, req.filenames[1], req.filenames[0])
} }
func doRename(state *MountState, req *request) { func doRename(state *MountState, req *request) {
req.status = state.fileSystem.Rename(req.inHeader, (*raw.RenameIn)(req.inData), req.filenames[0], req.filenames[1]) req.status = state.fileSystem.Rename(&req.context, (*raw.RenameIn)(req.inData), req.filenames[0], req.filenames[1])
} }
func doStatFs(state *MountState, req *request) { func doStatFs(state *MountState, req *request) {
stat := (*StatfsOut)(req.outData) stat := (*StatfsOut)(req.outData)
req.status = state.fileSystem.StatFs(stat, req.inHeader) req.status = state.fileSystem.StatFs(stat, &req.context)
} }
func doIoctl(state *MountState, req *request) { func doIoctl(state *MountState, req *request) {
......
...@@ -49,6 +49,8 @@ type request struct { ...@@ -49,6 +49,8 @@ type request struct {
// Input, if small enough to fit here. // Input, if small enough to fit here.
smallInputBuf [128]byte smallInputBuf [128]byte
context Context
} }
func (r *request) clear() { func (r *request) clear() {
...@@ -179,6 +181,8 @@ func (r *request) parse() { ...@@ -179,6 +181,8 @@ func (r *request) parse() {
copy(r.outBuf[:r.handler.OutputSize], zeroOutBuf[:r.handler.OutputSize]) copy(r.outBuf[:r.handler.OutputSize], zeroOutBuf[:r.handler.OutputSize])
r.outData = unsafe.Pointer(&r.outBuf[sizeOfOutHeader]) r.outData = unsafe.Pointer(&r.outBuf[sizeOfOutHeader])
r.context.Context = &r.inHeader.Context
r.context.NodeId = r.inHeader.NodeId
} }
func (r *request) serializeHeader(dataSize int) (header []byte) { func (r *request) serializeHeader(dataSize int) (header []byte) {
......
...@@ -45,6 +45,10 @@ type Attr raw.Attr ...@@ -45,6 +45,10 @@ type Attr raw.Attr
type Owner raw.Owner type Owner raw.Owner
type Context raw.Context // Context contains assorted per-request data
type Context struct {
NodeId uint64
*raw.Context
}
type StatfsOut raw.StatfsOut type StatfsOut raw.StatfsOut
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