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{}
type RawFileSystem interface {
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)
// Attributes.
GetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.GetAttrIn) (code Status)
SetAttr(out *raw.AttrOut, header *raw.InHeader, input *raw.SetAttrIn) (code Status)
GetAttr(out *raw.AttrOut, context *Context, input *raw.GetAttrIn) (code Status)
SetAttr(out *raw.AttrOut, context *Context, input *raw.SetAttrIn) (code Status)
// Modifying structure.
Mknod(out *raw.EntryOut, header *raw.InHeader, input *raw.MknodIn, name string) (code Status)
Mkdir(out *raw.EntryOut, header *raw.InHeader, input *raw.MkdirIn, name string) (code Status)
Unlink(header *raw.InHeader, name string) (code Status)
Rmdir(header *raw.InHeader, name string) (code Status)
Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status)
Link(out *raw.EntryOut, header *raw.InHeader, input *raw.LinkIn, filename string) (code Status)
Mknod(out *raw.EntryOut, context *Context, input *raw.MknodIn, name string) (code Status)
Mkdir(out *raw.EntryOut, context *Context, input *raw.MkdirIn, name string) (code Status)
Unlink(context *Context, name string) (code Status)
Rmdir(context *Context, name string) (code Status)
Rename(context *Context, input *raw.RenameIn, oldName string, newName 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)
Readlink(header *raw.InHeader) (out []byte, code Status)
Access(header *raw.InHeader, input *raw.AccessIn) (code Status)
Symlink(out *raw.EntryOut, context *Context, pointedTo string, linkName string) (code Status)
Readlink(context *Context) (out []byte, code Status)
Access(context *Context, input *raw.AccessIn) (code Status)
// Extended attributes.
GetXAttrSize(header *raw.InHeader, attr string) (sz int, code Status)
GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status)
ListXAttr(header *raw.InHeader) (attributes []byte, code Status)
SetXAttr(header *raw.InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status
RemoveXAttr(header *raw.InHeader, attr string) (code Status)
GetXAttrSize(context *Context, attr string) (sz int, code Status)
GetXAttrData(context *Context, attr string) (data []byte, code Status)
ListXAttr(context *Context) (attributes []byte, code Status)
SetXAttr(context *Context, input *raw.SetXAttrIn, attr string, data []byte) Status
RemoveXAttr(context *Context, attr string) (code Status)
// File handling.
Create(out *raw.CreateOut, header *raw.InHeader, input *raw.CreateIn, name string) (code Status)
Open(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status)
Read(*raw.InHeader, *raw.ReadIn, []byte) (ReadResult, Status)
Create(out *raw.CreateOut, context *Context, input *raw.CreateIn, name string) (code Status)
Open(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status)
Read(*Context, *raw.ReadIn, []byte) (ReadResult, Status)
Release(header *raw.InHeader, input *raw.ReleaseIn)
Write(*raw.InHeader, *raw.WriteIn, []byte) (written uint32, code Status)
Flush(header *raw.InHeader, input *raw.FlushIn) Status
Fsync(*raw.InHeader, *raw.FsyncIn) (code Status)
Release(context *Context, input *raw.ReleaseIn)
Write(*Context, *raw.WriteIn, []byte) (written uint32, code Status)
Flush(context *Context, input *raw.FlushIn) Status
Fsync(*Context, *raw.FsyncIn) (code Status)
// Directory handling
OpenDir(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status)
ReadDir(out *DirEntryList, header *raw.InHeader, input *raw.ReadIn) Status
ReleaseDir(header *raw.InHeader, input *raw.ReleaseIn)
FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status)
OpenDir(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status)
ReadDir(out *DirEntryList, context *Context, input *raw.ReadIn) Status
ReleaseDir(context *Context, input *raw.ReleaseIn)
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.
Init(params *RawFsInit)
......
......@@ -15,119 +15,119 @@ func (fs *DefaultRawFileSystem) String() string {
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
}
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
}
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
}
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
}
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
}
func (fs *DefaultRawFileSystem) Readlink(header *raw.InHeader) (out []byte, code Status) {
func (fs *DefaultRawFileSystem) Readlink(context *Context) (out []byte, code Status) {
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
}
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
}
func (fs *DefaultRawFileSystem) Unlink(header *raw.InHeader, name string) (code Status) {
func (fs *DefaultRawFileSystem) Unlink(context *Context, name string) (code Status) {
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
}
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
}
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
}
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
}
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
}
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
}
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
}
func (fs *DefaultRawFileSystem) ListXAttr(header *raw.InHeader) (data []byte, code Status) {
func (fs *DefaultRawFileSystem) ListXAttr(context *Context) (data []byte, code Status) {
return nil, ENOSYS
}
func (fs *DefaultRawFileSystem) RemoveXAttr(header *raw.InHeader, attr string) Status {
func (fs *DefaultRawFileSystem) RemoveXAttr(context *Context, attr string) Status {
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
}
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
}
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
}
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
}
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
}
func (fs *DefaultRawFileSystem) Flush(header *raw.InHeader, input *raw.FlushIn) Status {
func (fs *DefaultRawFileSystem) Flush(context *Context, input *raw.FlushIn) Status {
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
}
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
}
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
}
This diff is collapsed.
......@@ -163,7 +163,7 @@ func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem {
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()()
return fs.RawFileSystem.Lookup(out, h, name)
}
......@@ -173,138 +173,138 @@ func (fs *LockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) {
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
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()()
return fs.RawFileSystem.FsyncDir(header, input)
}
......@@ -116,7 +116,7 @@ func doInit(state *MountState, req *request) {
func doOpen(state *MountState, req *request) {
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
if status != OK {
return
......@@ -125,7 +125,7 @@ func doOpen(state *MountState, req *request) {
func doCreate(state *MountState, req *request) {
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
}
......@@ -134,24 +134,24 @@ func doReadDir(state *MountState, req *request) {
buf := state.AllocOut(req, in.Size)
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.status = code
}
func doOpenDir(state *MountState, req *request) {
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
}
func doSetattr(state *MountState, req *request) {
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) {
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.Size = n
req.status = status
......@@ -177,14 +177,14 @@ func doGetXAttr(state *MountState, req *request) {
out := (*raw.GetXAttrOut)(req.outData)
switch req.inHeader.Opcode {
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() {
out.Size = uint32(sz)
}
req.status = code
return
case _OP_LISTXATTR:
data, code := state.fileSystem.ListXAttr(req.inHeader)
data, code := state.fileSystem.ListXAttr(&req.context)
if code.Ok() {
out.Size = uint32(len(data))
}
......@@ -197,9 +197,9 @@ func doGetXAttr(state *MountState, req *request) {
var data []byte
switch req.inHeader.Opcode {
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:
data, req.status = state.fileSystem.ListXAttr(req.inHeader)
data, req.status = state.fileSystem.ListXAttr(&req.context)
default:
log.Panicf("xattr opcode %v", req.inHeader.Opcode)
req.status = ENOSYS
......@@ -218,7 +218,7 @@ func doGetXAttr(state *MountState, req *request) {
func doGetAttr(state *MountState, req *request) {
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
}
......@@ -246,12 +246,12 @@ func doBatchForget(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) {
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.outData = unsafe.Pointer(lookupOut)
}
......@@ -259,25 +259,25 @@ func doLookup(state *MountState, req *request) {
func doMknod(state *MountState, req *request) {
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) {
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) {
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) {
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) {
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) {
......@@ -285,7 +285,7 @@ func doRead(state *MountState, req *request) {
buf := state.AllocOut(req, in.Size)
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 {
req.fdData = fd
req.flatData = nil
......@@ -295,50 +295,50 @@ func doRead(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) {
state.fileSystem.Release(req.inHeader, (*raw.ReleaseIn)(req.inData))
state.fileSystem.Release(&req.context, (*raw.ReleaseIn)(req.inData))
}
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) {
state.fileSystem.ReleaseDir(req.inHeader, (*raw.ReleaseIn)(req.inData))
state.fileSystem.ReleaseDir(&req.context, (*raw.ReleaseIn)(req.inData))
}
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) {
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) {
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) {
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) {
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) {
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) {
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) {
......
......@@ -49,6 +49,8 @@ type request struct {
// Input, if small enough to fit here.
smallInputBuf [128]byte
context Context
}
func (r *request) clear() {
......@@ -179,6 +181,8 @@ func (r *request) parse() {
copy(r.outBuf[:r.handler.OutputSize], zeroOutBuf[:r.handler.OutputSize])
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) {
......
......@@ -45,6 +45,10 @@ type Attr raw.Attr
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
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