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

raw,fuse: move Header into input data structure, remove Context

argument from raw FS API, and change parameter ordering to (input,
output).
parent 37690195
......@@ -79,52 +79,52 @@ type RawFileSystem interface {
// If called, provide debug output through the log package.
SetDebug(debug bool)
Lookup(out *raw.EntryOut, context *Context, name string) (status Status)
Lookup(header *raw.InHeader, name string, out *raw.EntryOut) (status Status)
Forget(nodeid, nlookup uint64)
// Attributes.
GetAttr(out *raw.AttrOut, context *Context, input *raw.GetAttrIn) (code Status)
SetAttr(out *raw.AttrOut, context *Context, input *raw.SetAttrIn) (code Status)
GetAttr(input *raw.GetAttrIn, out *raw.AttrOut) (code Status)
SetAttr(input *raw.SetAttrIn, out *raw.AttrOut) (code Status)
// Modifying structure.
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)
Mknod(input *raw.MknodIn, name string, out *raw.EntryOut) (code Status)
Mkdir(input *raw.MkdirIn, name string, out *raw.EntryOut) (code Status)
Unlink(header *raw.InHeader, name string) (code Status)
Rmdir(header *raw.InHeader, name string) (code Status)
Rename(input *raw.RenameIn, oldName string, newName string) (code Status)
Link(input *raw.LinkIn, filename string, out *raw.EntryOut) (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)
Symlink(header *raw.InHeader, pointedTo string, linkName string, out *raw.EntryOut) (code Status)
Readlink(header *raw.InHeader) (out []byte, code Status)
Access(input *raw.AccessIn) (code Status)
// Extended attributes.
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)
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(input *raw.SetXAttrIn, attr string, data []byte) Status
RemoveXAttr(header *raw.InHeader, attr string) (code Status)
// File handling.
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)
Create(input *raw.CreateIn, name string, out *raw.CreateOut) (code Status)
Open(input *raw.OpenIn, out *raw.OpenOut) (status Status)
Read(input *raw.ReadIn, buf []byte) (ReadResult, 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)
Fallocate(Context *Context, in *raw.FallocateIn) (code Status)
Release(input *raw.ReleaseIn)
Write(input *raw.WriteIn, data []byte) (written uint32, code Status)
Flush(input *raw.FlushIn) Status
Fsync(input *raw.FsyncIn) (code Status)
Fallocate(input *raw.FallocateIn) (code Status)
// Directory handling
OpenDir(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status)
ReadDir(out *DirEntryList, context *Context, input *raw.ReadIn) Status
ReadDirPlus(out *DirEntryList, context *Context, input *raw.ReadIn) Status
ReleaseDir(context *Context, input *raw.ReleaseIn)
FsyncDir(context *Context, input *raw.FsyncIn) (code Status)
OpenDir(input *raw.OpenIn, out *raw.OpenOut) (status Status)
ReadDir(input *raw.ReadIn, out *DirEntryList) Status
ReadDirPlus(input *raw.ReadIn, out *DirEntryList) Status
ReleaseDir(input *raw.ReleaseIn)
FsyncDir(input *raw.FsyncIn) (code Status)
//
StatFs(out *raw.StatfsOut, context *Context) (code Status)
StatFs(input *raw.InHeader, out *raw.StatfsOut) (code Status)
// This is called on processing the first request. The
// filesystem implementation can use the server argument to
......
......@@ -24,127 +24,127 @@ func (fs *defaultRawFileSystem) String() string {
func (fs *defaultRawFileSystem) SetDebug(dbg bool) {
}
func (fs *defaultRawFileSystem) StatFs(out *raw.StatfsOut, context *Context) Status {
func (fs *defaultRawFileSystem) StatFs(header *raw.InHeader, out *raw.StatfsOut) Status {
return ENOSYS
}
func (fs *defaultRawFileSystem) Lookup(out *raw.EntryOut, context *Context, name string) (code Status) {
func (fs *defaultRawFileSystem) Lookup(header *raw.InHeader, name string, out *raw.EntryOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Forget(nodeID, nlookup uint64) {
}
func (fs *defaultRawFileSystem) GetAttr(out *raw.AttrOut, context *Context, input *raw.GetAttrIn) (code Status) {
func (fs *defaultRawFileSystem) GetAttr(input *raw.GetAttrIn, out *raw.AttrOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Open(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status) {
func (fs *defaultRawFileSystem) Open(input *raw.OpenIn, out *raw.OpenOut) (status Status) {
return OK
}
func (fs *defaultRawFileSystem) SetAttr(out *raw.AttrOut, context *Context, input *raw.SetAttrIn) (code Status) {
func (fs *defaultRawFileSystem) SetAttr(input *raw.SetAttrIn, out *raw.AttrOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Readlink(context *Context) (out []byte, code Status) {
func (fs *defaultRawFileSystem) Readlink(header *raw.InHeader) (out []byte, code Status) {
return nil, ENOSYS
}
func (fs *defaultRawFileSystem) Mknod(out *raw.EntryOut, context *Context, input *raw.MknodIn, name string) (code Status) {
func (fs *defaultRawFileSystem) Mknod(input *raw.MknodIn, name string, out *raw.EntryOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Mkdir(out *raw.EntryOut, context *Context, input *raw.MkdirIn, name string) (code Status) {
func (fs *defaultRawFileSystem) Mkdir(input *raw.MkdirIn, name string, out *raw.EntryOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Unlink(context *Context, name string) (code Status) {
func (fs *defaultRawFileSystem) Unlink(header *raw.InHeader, name string) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Rmdir(context *Context, name string) (code Status) {
func (fs *defaultRawFileSystem) Rmdir(header *raw.InHeader, name string) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Symlink(out *raw.EntryOut, context *Context, pointedTo string, linkName string) (code Status) {
func (fs *defaultRawFileSystem) Symlink(header *raw.InHeader, pointedTo string, linkName string, out *raw.EntryOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Rename(context *Context, input *raw.RenameIn, oldName string, newName string) (code Status) {
func (fs *defaultRawFileSystem) Rename(input *raw.RenameIn, oldName string, newName string) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Link(out *raw.EntryOut, context *Context, input *raw.LinkIn, name string) (code Status) {
func (fs *defaultRawFileSystem) Link(input *raw.LinkIn, name string, out *raw.EntryOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) GetXAttrSize(context *Context, attr string) (size int, code Status) {
func (fs *defaultRawFileSystem) GetXAttrSize(header *raw.InHeader, attr string) (size int, code Status) {
return 0, ENOSYS
}
func (fs *defaultRawFileSystem) GetXAttrData(context *Context, attr string) (data []byte, code Status) {
func (fs *defaultRawFileSystem) GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status) {
return nil, ENOSYS
}
func (fs *defaultRawFileSystem) SetXAttr(context *Context, input *raw.SetXAttrIn, attr string, data []byte) Status {
func (fs *defaultRawFileSystem) SetXAttr(input *raw.SetXAttrIn, attr string, data []byte) Status {
return ENOSYS
}
func (fs *defaultRawFileSystem) ListXAttr(context *Context) (data []byte, code Status) {
func (fs *defaultRawFileSystem) ListXAttr(header *raw.InHeader) (data []byte, code Status) {
return nil, ENOSYS
}
func (fs *defaultRawFileSystem) RemoveXAttr(context *Context, attr string) Status {
func (fs *defaultRawFileSystem) RemoveXAttr(header *raw.InHeader, attr string) Status {
return ENOSYS
}
func (fs *defaultRawFileSystem) Access(context *Context, input *raw.AccessIn) (code Status) {
func (fs *defaultRawFileSystem) Access(input *raw.AccessIn) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Create(out *raw.CreateOut, context *Context, input *raw.CreateIn, name string) (code Status) {
func (fs *defaultRawFileSystem) Create(input *raw.CreateIn, name string, out *raw.CreateOut) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) OpenDir(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status) {
func (fs *defaultRawFileSystem) OpenDir(input *raw.OpenIn, out *raw.OpenOut) (status Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Read(context *Context, input *raw.ReadIn, buf []byte) (ReadResult, Status) {
func (fs *defaultRawFileSystem) Read(input *raw.ReadIn, buf []byte) (ReadResult, Status) {
return nil, ENOSYS
}
func (fs *defaultRawFileSystem) Release(context *Context, input *raw.ReleaseIn) {
func (fs *defaultRawFileSystem) Release(input *raw.ReleaseIn) {
}
func (fs *defaultRawFileSystem) Write(context *Context, input *raw.WriteIn, data []byte) (written uint32, code Status) {
func (fs *defaultRawFileSystem) Write(input *raw.WriteIn, data []byte) (written uint32, code Status) {
return 0, ENOSYS
}
func (fs *defaultRawFileSystem) Flush(context *Context, input *raw.FlushIn) Status {
func (fs *defaultRawFileSystem) Flush(input *raw.FlushIn) Status {
return OK
}
func (fs *defaultRawFileSystem) Fsync(context *Context, input *raw.FsyncIn) (code Status) {
func (fs *defaultRawFileSystem) Fsync(input *raw.FsyncIn) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) ReadDir(l *DirEntryList, context *Context, input *raw.ReadIn) Status {
func (fs *defaultRawFileSystem) ReadDir(input *raw.ReadIn, l *DirEntryList) Status {
return ENOSYS
}
func (fs *defaultRawFileSystem) ReadDirPlus(l *DirEntryList, context *Context, input *raw.ReadIn) Status {
func (fs *defaultRawFileSystem) ReadDirPlus(input *raw.ReadIn, l *DirEntryList) Status {
return ENOSYS
}
func (fs *defaultRawFileSystem) ReleaseDir(context *Context, input *raw.ReleaseIn) {
func (fs *defaultRawFileSystem) ReleaseDir(input *raw.ReleaseIn) {
}
func (fs *defaultRawFileSystem) FsyncDir(context *Context, input *raw.FsyncIn) (code Status) {
func (fs *defaultRawFileSystem) FsyncDir(input *raw.FsyncIn) (code Status) {
return ENOSYS
}
func (fs *defaultRawFileSystem) Fallocate(context *Context, in *raw.FallocateIn) (code Status) {
func (fs *defaultRawFileSystem) Fallocate(in *raw.FallocateIn) (code Status) {
return ENOSYS
}
......@@ -31,9 +31,9 @@ func (fs *lockingRawFileSystem) locked() func() {
return func() { fs.lock.Unlock() }
}
func (fs *lockingRawFileSystem) Lookup(out *raw.EntryOut, h *Context, name string) (code Status) {
func (fs *lockingRawFileSystem) Lookup(header *raw.InHeader, name string, out *raw.EntryOut) (code Status) {
defer fs.locked()()
return fs.RawFS.Lookup(out, h, name)
return fs.RawFS.Lookup(header, name, out)
}
func (fs *lockingRawFileSystem) SetDebug(dbg bool) {
......@@ -46,145 +46,145 @@ func (fs *lockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) {
fs.RawFS.Forget(nodeID, nlookup)
}
func (fs *lockingRawFileSystem) GetAttr(out *raw.AttrOut, header *Context, input *raw.GetAttrIn) (code Status) {
func (fs *lockingRawFileSystem) GetAttr(input *raw.GetAttrIn, out *raw.AttrOut) (code Status) {
defer fs.locked()()
return fs.RawFS.GetAttr(out, header, input)
return fs.RawFS.GetAttr(input, out)
}
func (fs *lockingRawFileSystem) Open(out *raw.OpenOut, header *Context, input *raw.OpenIn) (status Status) {
func (fs *lockingRawFileSystem) Open(input *raw.OpenIn, out *raw.OpenOut) (status Status) {
defer fs.locked()()
return fs.RawFS.Open(out, header, input)
return fs.RawFS.Open(input, out)
}
func (fs *lockingRawFileSystem) SetAttr(out *raw.AttrOut, header *Context, input *raw.SetAttrIn) (code Status) {
func (fs *lockingRawFileSystem) SetAttr(input *raw.SetAttrIn, out *raw.AttrOut) (code Status) {
defer fs.locked()()
return fs.RawFS.SetAttr(out, header, input)
return fs.RawFS.SetAttr(input, out)
}
func (fs *lockingRawFileSystem) Readlink(header *Context) (out []byte, code Status) {
func (fs *lockingRawFileSystem) Readlink(header *raw.InHeader) (out []byte, code Status) {
defer fs.locked()()
return fs.RawFS.Readlink(header)
}
func (fs *lockingRawFileSystem) Mknod(out *raw.EntryOut, header *Context, input *raw.MknodIn, name string) (code Status) {
func (fs *lockingRawFileSystem) Mknod(input *raw.MknodIn, name string, out *raw.EntryOut) (code Status) {
defer fs.locked()()
return fs.RawFS.Mknod(out, header, input, name)
return fs.RawFS.Mknod(input, name, out)
}
func (fs *lockingRawFileSystem) Mkdir(out *raw.EntryOut, header *Context, input *raw.MkdirIn, name string) (code Status) {
func (fs *lockingRawFileSystem) Mkdir(input *raw.MkdirIn, name string, out *raw.EntryOut) (code Status) {
defer fs.locked()()
return fs.RawFS.Mkdir(out, header, input, name)
return fs.RawFS.Mkdir(input, name, out)
}
func (fs *lockingRawFileSystem) Unlink(header *Context, name string) (code Status) {
func (fs *lockingRawFileSystem) Unlink(header *raw.InHeader, name string) (code Status) {
defer fs.locked()()
return fs.RawFS.Unlink(header, name)
}
func (fs *lockingRawFileSystem) Rmdir(header *Context, name string) (code Status) {
func (fs *lockingRawFileSystem) Rmdir(header *raw.InHeader, name string) (code Status) {
defer fs.locked()()
return fs.RawFS.Rmdir(header, name)
}
func (fs *lockingRawFileSystem) Symlink(out *raw.EntryOut, header *Context, pointedTo string, linkName string) (code Status) {
func (fs *lockingRawFileSystem) Symlink(header *raw.InHeader, pointedTo string, linkName string, out *raw.EntryOut) (code Status) {
defer fs.locked()()
return fs.RawFS.Symlink(out, header, pointedTo, linkName)
return fs.RawFS.Symlink(header, pointedTo, linkName, out)
}
func (fs *lockingRawFileSystem) Rename(header *Context, input *raw.RenameIn, oldName string, newName string) (code Status) {
func (fs *lockingRawFileSystem) Rename(input *raw.RenameIn, oldName string, newName string) (code Status) {
defer fs.locked()()
return fs.RawFS.Rename(header, input, oldName, newName)
return fs.RawFS.Rename(input, oldName, newName)
}
func (fs *lockingRawFileSystem) Link(out *raw.EntryOut, header *Context, input *raw.LinkIn, name string) (code Status) {
func (fs *lockingRawFileSystem) Link(input *raw.LinkIn, name string, out *raw.EntryOut) (code Status) {
defer fs.locked()()
return fs.RawFS.Link(out, header, input, name)
return fs.RawFS.Link(input, name, out)
}
func (fs *lockingRawFileSystem) SetXAttr(header *Context, input *raw.SetXAttrIn, attr string, data []byte) Status {
func (fs *lockingRawFileSystem) SetXAttr(input *raw.SetXAttrIn, attr string, data []byte) Status {
defer fs.locked()()
return fs.RawFS.SetXAttr(header, input, attr, data)
return fs.RawFS.SetXAttr(input, attr, data)
}
func (fs *lockingRawFileSystem) GetXAttrData(header *Context, attr string) (data []byte, code Status) {
func (fs *lockingRawFileSystem) GetXAttrData(header *raw.InHeader, attr string) (data []byte, code Status) {
defer fs.locked()()
return fs.RawFS.GetXAttrData(header, attr)
}
func (fs *lockingRawFileSystem) GetXAttrSize(header *Context, attr string) (sz int, code Status) {
func (fs *lockingRawFileSystem) GetXAttrSize(header *raw.InHeader, attr string) (sz int, code Status) {
defer fs.locked()()
return fs.RawFS.GetXAttrSize(header, attr)
}
func (fs *lockingRawFileSystem) ListXAttr(header *Context) (data []byte, code Status) {
func (fs *lockingRawFileSystem) ListXAttr(header *raw.InHeader) (data []byte, code Status) {
defer fs.locked()()
return fs.RawFS.ListXAttr(header)
}
func (fs *lockingRawFileSystem) RemoveXAttr(header *Context, attr string) Status {
func (fs *lockingRawFileSystem) RemoveXAttr(header *raw.InHeader, attr string) Status {
defer fs.locked()()
return fs.RawFS.RemoveXAttr(header, attr)
}
func (fs *lockingRawFileSystem) Access(header *Context, input *raw.AccessIn) (code Status) {
func (fs *lockingRawFileSystem) Access(input *raw.AccessIn) (code Status) {
defer fs.locked()()
return fs.RawFS.Access(header, input)
return fs.RawFS.Access(input)
}
func (fs *lockingRawFileSystem) Create(out *raw.CreateOut, header *Context, input *raw.CreateIn, name string) (code Status) {
func (fs *lockingRawFileSystem) Create(input *raw.CreateIn, name string, out *raw.CreateOut) (code Status) {
defer fs.locked()()
return fs.RawFS.Create(out, header, input, name)
return fs.RawFS.Create(input, name, out)
}
func (fs *lockingRawFileSystem) OpenDir(out *raw.OpenOut, header *Context, input *raw.OpenIn) (status Status) {
func (fs *lockingRawFileSystem) OpenDir(input *raw.OpenIn, out *raw.OpenOut) (status Status) {
defer fs.locked()()
return fs.RawFS.OpenDir(out, header, input)
return fs.RawFS.OpenDir(input, out)
}
func (fs *lockingRawFileSystem) Release(header *Context, input *raw.ReleaseIn) {
func (fs *lockingRawFileSystem) Release(input *raw.ReleaseIn) {
defer fs.locked()()
fs.RawFS.Release(header, input)
fs.RawFS.Release(input)
}
func (fs *lockingRawFileSystem) ReleaseDir(header *Context, h *raw.ReleaseIn) {
func (fs *lockingRawFileSystem) ReleaseDir(input *raw.ReleaseIn) {
defer fs.locked()()
fs.RawFS.ReleaseDir(header, h)
fs.RawFS.ReleaseDir(input)
}
func (fs *lockingRawFileSystem) Read(header *Context, input *raw.ReadIn, buf []byte) (ReadResult, Status) {
func (fs *lockingRawFileSystem) Read(input *raw.ReadIn, buf []byte) (ReadResult, Status) {
defer fs.locked()()
return fs.RawFS.Read(header, input, buf)
return fs.RawFS.Read(input, buf)
}
func (fs *lockingRawFileSystem) Write(header *Context, input *raw.WriteIn, data []byte) (written uint32, code Status) {
func (fs *lockingRawFileSystem) Write(input *raw.WriteIn, data []byte) (written uint32, code Status) {
defer fs.locked()()
return fs.RawFS.Write(header, input, data)
return fs.RawFS.Write(input, data)
}
func (fs *lockingRawFileSystem) Flush(header *Context, input *raw.FlushIn) Status {
func (fs *lockingRawFileSystem) Flush(input *raw.FlushIn) Status {
defer fs.locked()()
return fs.RawFS.Flush(header, input)
return fs.RawFS.Flush(input)
}
func (fs *lockingRawFileSystem) Fsync(header *Context, input *raw.FsyncIn) (code Status) {
func (fs *lockingRawFileSystem) Fsync(input *raw.FsyncIn) (code Status) {
defer fs.locked()()
return fs.RawFS.Fsync(header, input)
return fs.RawFS.Fsync(input)
}
func (fs *lockingRawFileSystem) ReadDir(out *DirEntryList, header *Context, input *raw.ReadIn) Status {
func (fs *lockingRawFileSystem) ReadDir(input *raw.ReadIn, out *DirEntryList) Status {
defer fs.locked()()
return fs.RawFS.ReadDir(out, header, input)
return fs.RawFS.ReadDir(input, out)
}
func (fs *lockingRawFileSystem) ReadDirPlus(out *DirEntryList, header *Context, input *raw.ReadIn) Status {
func (fs *lockingRawFileSystem) ReadDirPlus(input *raw.ReadIn, out *DirEntryList) Status {
defer fs.locked()()
return fs.RawFS.ReadDirPlus(out, header, input)
return fs.RawFS.ReadDirPlus(input, out)
}
func (fs *lockingRawFileSystem) FsyncDir(header *Context, input *raw.FsyncIn) (code Status) {
func (fs *lockingRawFileSystem) FsyncDir(input *raw.FsyncIn) (code Status) {
defer fs.locked()()
return fs.RawFS.FsyncDir(header, input)
return fs.RawFS.FsyncDir(input)
}
func (fs *lockingRawFileSystem) Init(s *Server) {
......@@ -192,14 +192,14 @@ func (fs *lockingRawFileSystem) Init(s *Server) {
fs.RawFS.Init(s)
}
func (fs *lockingRawFileSystem) StatFs(out *raw.StatfsOut, context *Context) (code Status) {
func (fs *lockingRawFileSystem) StatFs(header *raw.InHeader, out *raw.StatfsOut) (code Status) {
defer fs.locked()()
return fs.RawFS.StatFs(out, context)
return fs.RawFS.StatFs(header, out)
}
func (fs *lockingRawFileSystem) Fallocate(c *Context, in *raw.FallocateIn) (code Status) {
func (fs *lockingRawFileSystem) Fallocate(in *raw.FallocateIn) (code Status) {
defer fs.locked()()
return fs.RawFS.Fallocate(c, in)
return fs.RawFS.Fallocate(in)
}
func (fs *lockingRawFileSystem) String() string {
......
......@@ -15,14 +15,14 @@ type connectorDir struct {
lookups []raw.EntryOut
}
func (d *connectorDir) ReadDir(list *fuse.DirEntryList, input *raw.ReadIn, context *fuse.Context) (code fuse.Status) {
func (d *connectorDir) ReadDir(input *raw.ReadIn, out *fuse.DirEntryList) (code fuse.Status) {
if d.stream == nil {
return fuse.OK
}
// rewinddir() should be as if reopening directory.
// TODO - test this.
if d.lastOffset > 0 && input.Offset == 0 {
d.stream, code = d.node.OpenDir(context)
d.stream, code = d.node.OpenDir((*fuse.Context)(&input.Context))
if !code.Ok() {
return code
}
......@@ -34,7 +34,7 @@ func (d *connectorDir) ReadDir(list *fuse.DirEntryList, input *raw.ReadIn, conte
log.Printf("got emtpy directory entry, mode %o.", e.Mode)
continue
}
ok, off := list.AddDirEntry(e)
ok, off := out.AddDirEntry(e)
d.lastOffset = off
if !ok {
break
......@@ -43,14 +43,14 @@ func (d *connectorDir) ReadDir(list *fuse.DirEntryList, input *raw.ReadIn, conte
return fuse.OK
}
func (d *connectorDir) ReadDirPlus(list *fuse.DirEntryList, input *raw.ReadIn, context *fuse.Context) (code fuse.Status) {
func (d *connectorDir) ReadDirPlus(input *raw.ReadIn, out *fuse.DirEntryList) (code fuse.Status) {
if d.stream == nil {
return fuse.OK
}
// rewinddir() should be as if reopening directory.
if d.lastOffset > 0 && input.Offset == 0 {
d.stream, code = d.node.OpenDir(context)
d.stream, code = d.node.OpenDir((*fuse.Context)(&input.Context))
if !code.Ok() {
return code
}
......@@ -64,7 +64,7 @@ func (d *connectorDir) ReadDirPlus(list *fuse.DirEntryList, input *raw.ReadIn, c
continue
}
// We ignore the return value
code := d.rawFS.Lookup(&d.lookups[i], context, n.Name)
code := d.rawFS.Lookup(&input.InHeader, n.Name, &d.lookups[i])
if !code.Ok() {
d.lookups[i] = raw.EntryOut{}
}
......@@ -77,7 +77,7 @@ func (d *connectorDir) ReadDirPlus(list *fuse.DirEntryList, input *raw.ReadIn, c
log.Printf("got empty directory entry, mode %o.", e.Mode)
continue
}
ok, off := list.AddDirLookupEntry(e, &d.lookups[input.Offset+uint64(i)])
ok, off := out.AddDirLookupEntry(e, &d.lookups[input.Offset+uint64(i)])
d.lastOffset = off
if !ok {
break
......
......@@ -23,7 +23,7 @@ func (c *FileSystemConnector) RawFS() fuse.RawFileSystem {
type rawBridge FileSystemConnector
func (c *rawBridge) Fsync(context *fuse.Context, input *raw.FsyncIn) fuse.Status {
func (c *rawBridge) Fsync(input *raw.FsyncIn) fuse.Status {
return fuse.ENOSYS
}
......@@ -31,7 +31,7 @@ func (c *rawBridge) SetDebug(debug bool) {
c.fsConn().SetDebug(debug)
}
func (c *rawBridge) FsyncDir(context *fuse.Context, input *raw.FsyncIn) fuse.Status {
func (c *rawBridge) FsyncDir(input *raw.FsyncIn) fuse.Status {
return fuse.ENOSYS
}
......@@ -68,7 +68,7 @@ func (c *FileSystemConnector) lookupMountUpdate(out *fuse.Attr, mount *fileSyste
return mount.mountInode, fuse.OK
}
func (c *FileSystemConnector) internalLookup(out *fuse.Attr, parent *Inode, name string, context *fuse.Context) (node *Inode, code fuse.Status) {
func (c *FileSystemConnector) internalLookup(out *fuse.Attr, parent *Inode, name string, header *raw.InHeader) (node *Inode, code fuse.Status) {
child := parent.GetChild(name)
if child != nil && child.mountPoint != nil {
return c.lookupMountUpdate(out, child.mountPoint)
......@@ -79,10 +79,10 @@ func (c *FileSystemConnector) internalLookup(out *fuse.Attr, parent *Inode, name
}
var fsNode Node
if child != nil {
code = child.fsInode.GetAttr(out, nil, context)
code = child.fsInode.GetAttr(out, nil, context(header))
fsNode = child.Node()
} else {
fsNode, code = parent.fsInode.Lookup(out, name, context)
fsNode, code = parent.fsInode.Lookup(out, name, context(header))
}
if child == nil && fsNode != nil {
......@@ -95,14 +95,14 @@ func (c *FileSystemConnector) internalLookup(out *fuse.Attr, parent *Inode, name
return child, code
}
func (c *rawBridge) Lookup(out *raw.EntryOut, context *fuse.Context, name string) (code fuse.Status) {
parent := c.toInode(context.NodeId)
func (c *rawBridge) Lookup(header *raw.InHeader, name string, out *raw.EntryOut) (code fuse.Status) {
parent := c.toInode(header.NodeId)
if !parent.IsDir() {
log.Printf("Lookup %q called on non-Directory node %d", name, context.NodeId)
log.Printf("Lookup %q called on non-Directory node %d", name, header.NodeId)
return fuse.ENOTDIR
}
outAttr := (*fuse.Attr)(&out.Attr)
child, code := c.fsConn().internalLookup(outAttr, parent, name, context)
child, code := c.fsConn().internalLookup(outAttr, parent, name, header)
if code == fuse.ENOENT && parent.mount.negativeEntry(out) {
return fuse.OK
}
......@@ -125,8 +125,8 @@ func (c *rawBridge) Forget(nodeID, nlookup uint64) {
c.fsConn().forgetUpdate(nodeID, int(nlookup))
}
func (c *rawBridge) GetAttr(out *raw.AttrOut, context *fuse.Context, input *raw.GetAttrIn) (code fuse.Status) {
node := c.toInode(context.NodeId)
func (c *rawBridge) GetAttr(input *raw.GetAttrIn, out *raw.AttrOut) (code fuse.Status) {
node := c.toInode(input.NodeId)
var f File
if input.Flags()&raw.FUSE_GETATTR_FH != 0 {
......@@ -136,18 +136,18 @@ func (c *rawBridge) GetAttr(out *raw.AttrOut, context *fuse.Context, input *raw.
}
dest := (*fuse.Attr)(&out.Attr)
code = node.fsInode.GetAttr(dest, f, context)
code = node.fsInode.GetAttr(dest, f, context(&input.InHeader))
if !code.Ok() {
return code
}
node.mount.fillAttr(out, context.NodeId)
node.mount.fillAttr(out, input.NodeId)
return fuse.OK
}
func (c *rawBridge) OpenDir(out *raw.OpenOut, context *fuse.Context, input *raw.OpenIn) (code fuse.Status) {
node := c.toInode(context.NodeId)
stream, err := node.fsInode.OpenDir(context)
func (c *rawBridge) OpenDir(input *raw.OpenIn, out *raw.OpenOut) (code fuse.Status) {
node := c.toInode(input.NodeId)
stream, err := node.fsInode.OpenDir(context(&input.InHeader))
if err != fuse.OK {
return err
}
......@@ -165,21 +165,25 @@ func (c *rawBridge) OpenDir(out *raw.OpenOut, context *fuse.Context, input *raw.
return fuse.OK
}
func (c *rawBridge) ReadDir(l *fuse.DirEntryList, context *fuse.Context, input *raw.ReadIn) fuse.Status {
node := c.toInode(context.NodeId)
func (c *rawBridge) ReadDir(input *raw.ReadIn, out *fuse.DirEntryList) fuse.Status {
node := c.toInode(input.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
return opened.dir.ReadDir(l, input, context)
return opened.dir.ReadDir(input, out)
}
func (c *rawBridge) ReadDirPlus(l *fuse.DirEntryList, context *fuse.Context, input *raw.ReadIn) fuse.Status {
node := c.toInode(context.NodeId)
func (c *rawBridge) ReadDirPlus(input *raw.ReadIn, out *fuse.DirEntryList) fuse.Status {
node := c.toInode(input.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
return opened.dir.ReadDirPlus(l, input, context)
return opened.dir.ReadDirPlus(input, out)
}
func (c *rawBridge) Open(out *raw.OpenOut, context *fuse.Context, input *raw.OpenIn) (status fuse.Status) {
node := c.toInode(context.NodeId)
f, code := node.fsInode.Open(input.Flags, context)
func context(header *raw.InHeader) *fuse.Context {
return (*fuse.Context)(&header.Context)
}
func (c *rawBridge) Open(input *raw.OpenIn, out *raw.OpenOut) (status fuse.Status) {
node := c.toInode(input.NodeId)
f, code := node.fsInode.Open(input.Flags, context(&input.InHeader))
if !code.Ok() {
return code
}
......@@ -189,8 +193,11 @@ func (c *rawBridge) Open(out *raw.OpenOut, context *fuse.Context, input *raw.Ope
return fuse.OK
}
func (c *rawBridge) SetAttr(out *raw.AttrOut, context *fuse.Context, input *raw.SetAttrIn) (code fuse.Status) {
node := c.toInode(context.NodeId)
func (c *rawBridge) SetAttr(input *raw.SetAttrIn, out *raw.AttrOut) (code fuse.Status) {
node := c.toInode(input.NodeId)
ctx := context(&input.InHeader)
var f File
if input.Valid&raw.FATTR_FH != 0 {
opened := node.mount.getOpenedFile(input.Fh)
......@@ -199,13 +206,13 @@ func (c *rawBridge) SetAttr(out *raw.AttrOut, context *fuse.Context, input *raw.
if code.Ok() && input.Valid&raw.FATTR_MODE != 0 {
permissions := uint32(07777) & input.Mode
code = node.fsInode.Chmod(f, permissions, context)
code = node.fsInode.Chmod(f, permissions, ctx)
}
if code.Ok() && (input.Valid&(raw.FATTR_UID|raw.FATTR_GID) != 0) {
code = node.fsInode.Chown(f, uint32(input.Uid), uint32(input.Gid), context)
code = node.fsInode.Chown(f, uint32(input.Uid), uint32(input.Gid), ctx)
}
if code.Ok() && input.Valid&raw.FATTR_SIZE != 0 {
code = node.fsInode.Truncate(f, input.Size, context)
code = node.fsInode.Truncate(f, input.Size, ctx)
}
if code.Ok() && (input.Valid&(raw.FATTR_ATIME|raw.FATTR_MTIME|raw.FATTR_ATIME_NOW|raw.FATTR_MTIME_NOW) != 0) {
now := time.Now()
......@@ -230,7 +237,7 @@ func (c *rawBridge) SetAttr(out *raw.AttrOut, context *fuse.Context, input *raw.
}
}
code = node.fsInode.Utimens(f, atime, mtime, context)
code = node.fsInode.Utimens(f, atime, mtime, ctx)
}
if !code.Ok() {
......@@ -240,28 +247,28 @@ func (c *rawBridge) SetAttr(out *raw.AttrOut, context *fuse.Context, input *raw.
// Must call GetAttr(); the filesystem may override some of
// the changes we effect here.
attr := (*fuse.Attr)(&out.Attr)
code = node.fsInode.GetAttr(attr, nil, context)
code = node.fsInode.GetAttr(attr, nil, ctx)
if code.Ok() {
node.mount.fillAttr(out, context.NodeId)
node.mount.fillAttr(out, input.NodeId)
}
return code
}
func (c *rawBridge) Fallocate(context *fuse.Context, in *raw.FallocateIn) (code fuse.Status) {
n := c.toInode(context.NodeId)
func (c *rawBridge) Fallocate(in *raw.FallocateIn) (code fuse.Status) {
n := c.toInode(in.NodeId)
opened := n.mount.getOpenedFile(in.Fh)
return n.fsInode.Fallocate(opened, in.Offset, in.Length, in.Mode, context)
return n.fsInode.Fallocate(opened, in.Offset, in.Length, in.Mode, context(&in.InHeader))
}
func (c *rawBridge) Readlink(context *fuse.Context) (out []byte, code fuse.Status) {
n := c.toInode(context.NodeId)
return n.fsInode.Readlink(context)
func (c *rawBridge) Readlink(header *raw.InHeader) (out []byte, code fuse.Status) {
n := c.toInode(header.NodeId)
return n.fsInode.Readlink(context(header))
}
func (c *rawBridge) Mknod(out *raw.EntryOut, context *fuse.Context, input *raw.MknodIn, name string) (code fuse.Status) {
parent := c.toInode(context.NodeId)
ctx := context
func (c *rawBridge) Mknod(input *raw.MknodIn, name string, out *raw.EntryOut) (code fuse.Status) {
parent := c.toInode(input.NodeId)
ctx := context(&input.InHeader)
fsNode, code := parent.fsInode.Mknod(name, input.Mode, uint32(input.Rdev), ctx)
if code.Ok() {
c.childLookup(out, fsNode)
......@@ -270,9 +277,9 @@ func (c *rawBridge) Mknod(out *raw.EntryOut, context *fuse.Context, input *raw.M
return code
}
func (c *rawBridge) Mkdir(out *raw.EntryOut, context *fuse.Context, input *raw.MkdirIn, name string) (code fuse.Status) {
parent := c.toInode(context.NodeId)
ctx := context
func (c *rawBridge) Mkdir(input *raw.MkdirIn, name string, out *raw.EntryOut) (code fuse.Status) {
parent := c.toInode(input.NodeId)
ctx := context(&input.InHeader)
fsNode, code := parent.fsInode.Mkdir(name, input.Mode, ctx)
if code.Ok() {
c.childLookup(out, fsNode)
......@@ -281,19 +288,19 @@ func (c *rawBridge) Mkdir(out *raw.EntryOut, context *fuse.Context, input *raw.M
return code
}
func (c *rawBridge) Unlink(context *fuse.Context, name string) (code fuse.Status) {
parent := c.toInode(context.NodeId)
return parent.fsInode.Unlink(name, context)
func (c *rawBridge) Unlink(header *raw.InHeader, name string) (code fuse.Status) {
parent := c.toInode(header.NodeId)
return parent.fsInode.Unlink(name, context(header))
}
func (c *rawBridge) Rmdir(context *fuse.Context, name string) (code fuse.Status) {
parent := c.toInode(context.NodeId)
return parent.fsInode.Rmdir(name, context)
func (c *rawBridge) Rmdir(header *raw.InHeader, name string) (code fuse.Status) {
parent := c.toInode(header.NodeId)
return parent.fsInode.Rmdir(name, context(header))
}
func (c *rawBridge) Symlink(out *raw.EntryOut, context *fuse.Context, pointedTo string, linkName string) (code fuse.Status) {
parent := c.toInode(context.NodeId)
ctx := context
func (c *rawBridge) Symlink(header *raw.InHeader, pointedTo string, linkName string, out *raw.EntryOut) (code fuse.Status) {
parent := c.toInode(header.NodeId)
ctx := context(header)
fsNode, code := parent.fsInode.Symlink(linkName, pointedTo, ctx)
if code.Ok() {
c.childLookup(out, fsNode)
......@@ -302,8 +309,8 @@ func (c *rawBridge) Symlink(out *raw.EntryOut, context *fuse.Context, pointedTo
return code
}
func (c *rawBridge) Rename(context *fuse.Context, input *raw.RenameIn, oldName string, newName string) (code fuse.Status) {
oldParent := c.toInode(context.NodeId)
func (c *rawBridge) Rename(input *raw.RenameIn, oldName string, newName string) (code fuse.Status) {
oldParent := c.toInode(input.NodeId)
child := oldParent.GetChild(oldName)
if child.mountPoint != nil {
......@@ -315,17 +322,17 @@ func (c *rawBridge) Rename(context *fuse.Context, input *raw.RenameIn, oldName s
return fuse.EXDEV
}
return oldParent.fsInode.Rename(oldName, newParent.fsInode, newName, context)
return oldParent.fsInode.Rename(oldName, newParent.fsInode, newName, context(&input.InHeader))
}
func (c *rawBridge) Link(out *raw.EntryOut, context *fuse.Context, input *raw.LinkIn, name string) (code fuse.Status) {
func (c *rawBridge) Link(input *raw.LinkIn, name string, out *raw.EntryOut) (code fuse.Status) {
existing := c.toInode(input.Oldnodeid)
parent := c.toInode(context.NodeId)
parent := c.toInode(input.NodeId)
if existing.mount != parent.mount {
return fuse.EXDEV
}
ctx := context
ctx := context(&input.InHeader)
fsNode, code := parent.fsInode.Link(name, existing.fsInode, ctx)
if code.Ok() {
c.childLookup(out, fsNode)
......@@ -335,14 +342,14 @@ func (c *rawBridge) Link(out *raw.EntryOut, context *fuse.Context, input *raw.Li
return code
}
func (c *rawBridge) Access(context *fuse.Context, input *raw.AccessIn) (code fuse.Status) {
n := c.toInode(context.NodeId)
return n.fsInode.Access(input.Mask, context)
func (c *rawBridge) Access(input *raw.AccessIn) (code fuse.Status) {
n := c.toInode(input.NodeId)
return n.fsInode.Access(input.Mask, context(&input.InHeader))
}
func (c *rawBridge) Create(out *raw.CreateOut, context *fuse.Context, input *raw.CreateIn, name string) (code fuse.Status) {
parent := c.toInode(context.NodeId)
f, fsNode, code := parent.fsInode.Create(name, uint32(input.Flags), input.Mode, context)
func (c *rawBridge) Create(input *raw.CreateIn, name string, out *raw.CreateOut) (code fuse.Status) {
parent := c.toInode(input.NodeId)
f, fsNode, code := parent.fsInode.Create(name, uint32(input.Flags), input.Mode, context(&input.InHeader))
if !code.Ok() {
return code
}
......@@ -355,41 +362,41 @@ func (c *rawBridge) Create(out *raw.CreateOut, context *fuse.Context, input *raw
return code
}
func (c *rawBridge) Release(context *fuse.Context, input *raw.ReleaseIn) {
node := c.toInode(context.NodeId)
func (c *rawBridge) Release(input *raw.ReleaseIn) {
node := c.toInode(input.NodeId)
opened := node.mount.unregisterFileHandle(input.Fh, node)
opened.WithFlags.File.Release()
}
func (c *rawBridge) ReleaseDir(context *fuse.Context, input *raw.ReleaseIn) {
node := c.toInode(context.NodeId)
func (c *rawBridge) ReleaseDir(input *raw.ReleaseIn) {
node := c.toInode(input.NodeId)
node.mount.unregisterFileHandle(input.Fh, node)
}
func (c *rawBridge) GetXAttrSize(context *fuse.Context, attribute string) (sz int, code fuse.Status) {
node := c.toInode(context.NodeId)
data, errno := node.fsInode.GetXAttr(attribute, context)
func (c *rawBridge) GetXAttrSize(header *raw.InHeader, attribute string) (sz int, code fuse.Status) {
node := c.toInode(header.NodeId)
data, errno := node.fsInode.GetXAttr(attribute, context(header))
return len(data), errno
}
func (c *rawBridge) GetXAttrData(context *fuse.Context, attribute string) (data []byte, code fuse.Status) {
node := c.toInode(context.NodeId)
return node.fsInode.GetXAttr(attribute, context)
func (c *rawBridge) GetXAttrData(header *raw.InHeader, attribute string) (data []byte, code fuse.Status) {
node := c.toInode(header.NodeId)
return node.fsInode.GetXAttr(attribute, context(header))
}
func (c *rawBridge) RemoveXAttr(context *fuse.Context, attr string) fuse.Status {
node := c.toInode(context.NodeId)
return node.fsInode.RemoveXAttr(attr, context)
func (c *rawBridge) RemoveXAttr(header *raw.InHeader, attr string) fuse.Status {
node := c.toInode(header.NodeId)
return node.fsInode.RemoveXAttr(attr, context(header))
}
func (c *rawBridge) SetXAttr(context *fuse.Context, input *raw.SetXAttrIn, attr string, data []byte) fuse.Status {
node := c.toInode(context.NodeId)
return node.fsInode.SetXAttr(attr, data, int(input.Flags), context)
func (c *rawBridge) SetXAttr(input *raw.SetXAttrIn, attr string, data []byte) fuse.Status {
node := c.toInode(input.NodeId)
return node.fsInode.SetXAttr(attr, data, int(input.Flags), context(&input.InHeader))
}
func (c *rawBridge) ListXAttr(context *fuse.Context) (data []byte, code fuse.Status) {
node := c.toInode(context.NodeId)
attrs, code := node.fsInode.ListXAttr(context)
func (c *rawBridge) ListXAttr(header *raw.InHeader) (data []byte, code fuse.Status) {
node := c.toInode(header.NodeId)
attrs, code := node.fsInode.ListXAttr(context(header))
if code != fuse.OK {
return nil, code
}
......@@ -406,21 +413,21 @@ func (c *rawBridge) ListXAttr(context *fuse.Context) (data []byte, code fuse.Sta
////////////////
// files.
func (c *rawBridge) Write(context *fuse.Context, input *raw.WriteIn, data []byte) (written uint32, code fuse.Status) {
node := c.toInode(context.NodeId)
func (c *rawBridge) Write(input *raw.WriteIn, data []byte) (written uint32, code fuse.Status) {
node := c.toInode(input.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Write(data, int64(input.Offset))
}
func (c *rawBridge) Read(context *fuse.Context, input *raw.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status) {
node := c.toInode(context.NodeId)
func (c *rawBridge) Read(input *raw.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status) {
node := c.toInode(input.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Read(buf, int64(input.Offset))
}
func (c *rawBridge) StatFs(out *raw.StatfsOut, context *fuse.Context) fuse.Status {
node := c.toInode(context.NodeId)
func (c *rawBridge) StatFs(header *raw.InHeader, out *raw.StatfsOut) fuse.Status {
node := c.toInode(header.NodeId)
s := node.Node().StatFs()
if s == nil {
return fuse.ENOSYS
......@@ -429,8 +436,8 @@ func (c *rawBridge) StatFs(out *raw.StatfsOut, context *fuse.Context) fuse.Statu
return fuse.OK
}
func (c *rawBridge) Flush(context *fuse.Context, input *raw.FlushIn) fuse.Status {
node := c.toInode(context.NodeId)
func (c *rawBridge) Flush(input *raw.FlushIn) fuse.Status {
node := c.toInode(input.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Flush()
}
......@@ -109,7 +109,7 @@ func doInit(server *Server, req *request) {
func doOpen(server *Server, req *request) {
out := (*raw.OpenOut)(req.outData)
status := server.fileSystem.Open(out, &req.context, (*raw.OpenIn)(req.inData))
status := server.fileSystem.Open((*raw.OpenIn)(req.inData), out)
req.status = status
if status != OK {
return
......@@ -118,43 +118,43 @@ func doOpen(server *Server, req *request) {
func doCreate(server *Server, req *request) {
out := (*raw.CreateOut)(req.outData)
status := server.fileSystem.Create(out, &req.context, (*raw.CreateIn)(req.inData), req.filenames[0])
status := server.fileSystem.Create((*raw.CreateIn)(req.inData), req.filenames[0], out)
req.status = status
}
func doReadDir(server *Server, req *request) {
in := (*raw.ReadIn)(req.inData)
buf := server.allocOut(req, in.Size)
entries := NewDirEntryList(buf, uint64(in.Offset))
out := NewDirEntryList(buf, uint64(in.Offset))
code := server.fileSystem.ReadDir(entries, &req.context, in)
req.flatData = entries.bytes()
code := server.fileSystem.ReadDir(in, out)
req.flatData = out.bytes()
req.status = code
}
func doReadDirPlus(server *Server, req *request) {
in := (*raw.ReadIn)(req.inData)
buf := server.allocOut(req, in.Size)
entries := NewDirEntryList(buf, uint64(in.Offset))
out := NewDirEntryList(buf, uint64(in.Offset))
code := server.fileSystem.ReadDirPlus(entries, &req.context, in)
req.flatData = entries.bytes()
code := server.fileSystem.ReadDirPlus(in, out)
req.flatData = out.bytes()
req.status = code
}
func doOpenDir(server *Server, req *request) {
out := (*raw.OpenOut)(req.outData)
status := server.fileSystem.OpenDir(out, &req.context, (*raw.OpenIn)(req.inData))
status := server.fileSystem.OpenDir((*raw.OpenIn)(req.inData), out)
req.status = status
}
func doSetattr(server *Server, req *request) {
out := (*raw.AttrOut)(req.outData)
req.status = server.fileSystem.SetAttr(out, &req.context, (*raw.SetAttrIn)(req.inData))
req.status = server.fileSystem.SetAttr((*raw.SetAttrIn)(req.inData), out)
}
func doWrite(server *Server, req *request) {
n, status := server.fileSystem.Write(&req.context, (*raw.WriteIn)(req.inData), req.arg)
n, status := server.fileSystem.Write((*raw.WriteIn)(req.inData), req.arg)
o := (*raw.WriteOut)(req.outData)
o.Size = n
req.status = status
......@@ -180,14 +180,14 @@ func doGetXAttr(server *Server, req *request) {
out := (*raw.GetXAttrOut)(req.outData)
switch req.inHeader.Opcode {
case _OP_GETXATTR:
sz, code := server.fileSystem.GetXAttrSize(&req.context, req.filenames[0])
sz, code := server.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0])
if code.Ok() {
out.Size = uint32(sz)
}
req.status = code
return
case _OP_LISTXATTR:
data, code := server.fileSystem.ListXAttr(&req.context)
data, code := server.fileSystem.ListXAttr(req.inHeader)
if code.Ok() {
out.Size = uint32(len(data))
}
......@@ -200,9 +200,9 @@ func doGetXAttr(server *Server, req *request) {
var data []byte
switch req.inHeader.Opcode {
case _OP_GETXATTR:
data, req.status = server.fileSystem.GetXAttrData(&req.context, req.filenames[0])
data, req.status = server.fileSystem.GetXAttrData(req.inHeader, req.filenames[0])
case _OP_LISTXATTR:
data, req.status = server.fileSystem.ListXAttr(&req.context)
data, req.status = server.fileSystem.ListXAttr(req.inHeader)
default:
log.Panicf("xattr opcode %v", req.inHeader.Opcode)
req.status = ENOSYS
......@@ -220,8 +220,8 @@ func doGetXAttr(server *Server, req *request) {
}
func doGetAttr(server *Server, req *request) {
attrOut := (*raw.AttrOut)(req.outData)
s := server.fileSystem.GetAttr(attrOut, &req.context, (*raw.GetAttrIn)(req.inData))
out := (*raw.AttrOut)(req.outData)
s := server.fileSystem.GetAttr((*raw.GetAttrIn)(req.inData), out)
req.status = s
}
......@@ -233,7 +233,7 @@ func doForget(server *Server, req *request) {
func doBatchForget(server *Server, req *request) {
in := (*raw.BatchForgetIn)(req.inData)
wantBytes := uintptr(in.Count) * unsafe.Sizeof(raw.BatchForgetIn{})
wantBytes := uintptr(in.Count) * (unsafe.Sizeof(raw.ForgetIn{}) - unsafe.Sizeof(raw.InHeader{}))
if uintptr(len(req.arg)) < wantBytes {
// We have no return value to complain, so log an error.
log.Printf("Too few bytes for batch forget. Got %d bytes, want %d (%d entries)",
......@@ -249,45 +249,45 @@ func doBatchForget(server *Server, req *request) {
}
func doReadlink(server *Server, req *request) {
req.flatData, req.status = server.fileSystem.Readlink(&req.context)
req.flatData, req.status = server.fileSystem.Readlink(req.inHeader)
}
func doLookup(server *Server, req *request) {
lookupOut := (*raw.EntryOut)(req.outData)
s := server.fileSystem.Lookup(lookupOut, &req.context, req.filenames[0])
out := (*raw.EntryOut)(req.outData)
s := server.fileSystem.Lookup(req.inHeader, req.filenames[0], out)
req.status = s
req.outData = unsafe.Pointer(lookupOut)
req.outData = unsafe.Pointer(out)
}
func doMknod(server *Server, req *request) {
out := (*raw.EntryOut)(req.outData)
req.status = server.fileSystem.Mknod(out, &req.context, (*raw.MknodIn)(req.inData), req.filenames[0])
req.status = server.fileSystem.Mknod((*raw.MknodIn)(req.inData), req.filenames[0], out)
}
func doMkdir(server *Server, req *request) {
out := (*raw.EntryOut)(req.outData)
req.status = server.fileSystem.Mkdir(out, &req.context, (*raw.MkdirIn)(req.inData), req.filenames[0])
req.status = server.fileSystem.Mkdir((*raw.MkdirIn)(req.inData), req.filenames[0], out)
}
func doUnlink(server *Server, req *request) {
req.status = server.fileSystem.Unlink(&req.context, req.filenames[0])
req.status = server.fileSystem.Unlink(req.inHeader, req.filenames[0])
}
func doRmdir(server *Server, req *request) {
req.status = server.fileSystem.Rmdir(&req.context, req.filenames[0])
req.status = server.fileSystem.Rmdir(req.inHeader, req.filenames[0])
}
func doLink(server *Server, req *request) {
out := (*raw.EntryOut)(req.outData)
req.status = server.fileSystem.Link(out, &req.context, (*raw.LinkIn)(req.inData), req.filenames[0])
req.status = server.fileSystem.Link((*raw.LinkIn)(req.inData), req.filenames[0], out)
}
func doRead(server *Server, req *request) {
in := (*raw.ReadIn)(req.inData)
buf := server.allocOut(req, in.Size)
req.readResult, req.status = server.fileSystem.Read(&req.context, in, buf)
req.readResult, req.status = server.fileSystem.Read(in, buf)
if fd, ok := req.readResult.(*readResultFd); ok {
req.fdData = fd
req.flatData = nil
......@@ -297,50 +297,50 @@ func doRead(server *Server, req *request) {
}
func doFlush(server *Server, req *request) {
req.status = server.fileSystem.Flush(&req.context, (*raw.FlushIn)(req.inData))
req.status = server.fileSystem.Flush((*raw.FlushIn)(req.inData))
}
func doRelease(server *Server, req *request) {
server.fileSystem.Release(&req.context, (*raw.ReleaseIn)(req.inData))
server.fileSystem.Release((*raw.ReleaseIn)(req.inData))
}
func doFsync(server *Server, req *request) {
req.status = server.fileSystem.Fsync(&req.context, (*raw.FsyncIn)(req.inData))
req.status = server.fileSystem.Fsync((*raw.FsyncIn)(req.inData))
}
func doReleaseDir(server *Server, req *request) {
server.fileSystem.ReleaseDir(&req.context, (*raw.ReleaseIn)(req.inData))
server.fileSystem.ReleaseDir((*raw.ReleaseIn)(req.inData))
}
func doFsyncDir(server *Server, req *request) {
req.status = server.fileSystem.FsyncDir(&req.context, (*raw.FsyncIn)(req.inData))
req.status = server.fileSystem.FsyncDir((*raw.FsyncIn)(req.inData))
}
func doSetXAttr(server *Server, req *request) {
splits := bytes.SplitN(req.arg, []byte{0}, 2)
req.status = server.fileSystem.SetXAttr(&req.context, (*raw.SetXAttrIn)(req.inData), string(splits[0]), splits[1])
req.status = server.fileSystem.SetXAttr((*raw.SetXAttrIn)(req.inData), string(splits[0]), splits[1])
}
func doRemoveXAttr(server *Server, req *request) {
req.status = server.fileSystem.RemoveXAttr(&req.context, req.filenames[0])
req.status = server.fileSystem.RemoveXAttr(req.inHeader, req.filenames[0])
}
func doAccess(server *Server, req *request) {
req.status = server.fileSystem.Access(&req.context, (*raw.AccessIn)(req.inData))
req.status = server.fileSystem.Access((*raw.AccessIn)(req.inData))
}
func doSymlink(server *Server, req *request) {
out := (*raw.EntryOut)(req.outData)
req.status = server.fileSystem.Symlink(out, &req.context, req.filenames[1], req.filenames[0])
req.status = server.fileSystem.Symlink(req.inHeader, req.filenames[1], req.filenames[0], out)
}
func doRename(server *Server, req *request) {
req.status = server.fileSystem.Rename(&req.context, (*raw.RenameIn)(req.inData), req.filenames[0], req.filenames[1])
req.status = server.fileSystem.Rename((*raw.RenameIn)(req.inData), req.filenames[0], req.filenames[1])
}
func doStatFs(server *Server, req *request) {
stat := (*raw.StatfsOut)(req.outData)
req.status = server.fileSystem.StatFs(stat, &req.context)
out := (*raw.StatfsOut)(req.outData)
req.status = server.fileSystem.StatFs(req.inHeader, out)
}
func doIoctl(server *Server, req *request) {
......@@ -352,7 +352,7 @@ func doDestroy(server *Server, req *request) {
}
func doFallocate(server *Server, req *request) {
req.status = server.fileSystem.Fallocate(&req.context, (*raw.FallocateIn)(req.inData))
req.status = server.fileSystem.Fallocate((*raw.FallocateIn)(req.inData))
}
////////////////////////////////////////////////////////////////
......
......@@ -141,7 +141,7 @@ func (r *request) parse() {
}
r.inHeader = (*raw.InHeader)(unsafe.Pointer(&r.inputBuf[0]))
r.arg = r.inputBuf[inHSize:]
r.arg = r.inputBuf[:]
r.handler = getHandler(r.inHeader.Opcode)
if r.handler == nil {
......@@ -159,6 +159,8 @@ func (r *request) parse() {
if r.handler.InputSize > 0 {
r.inData = unsafe.Pointer(&r.arg[0])
r.arg = r.arg[r.handler.InputSize:]
} else {
r.arg = r.arg[inHSize:]
}
count := r.handler.FileNames
......@@ -180,8 +182,6 @@ 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) {
......
......@@ -47,7 +47,4 @@ type Attr raw.Attr
type Owner raw.Owner
// Context contains assorted per-request data
type Context struct {
NodeId uint64
*raw.Context
}
type Context raw.Context
......@@ -4,6 +4,8 @@
package raw
type ForgetIn struct {
InHeader
Nlookup uint64
}
......@@ -13,24 +15,29 @@ type ForgetOne struct {
}
type BatchForgetIn struct {
InHeader
Count uint32
Dummy uint32
}
type MkdirIn struct {
InHeader
Mode uint32
Umask uint32
}
type RenameIn struct {
InHeader
Newdir uint64
}
type LinkIn struct {
InHeader
Oldnodeid uint64
}
type MknodIn struct {
InHeader
Mode uint32
Rdev uint32
Umask uint32
......@@ -56,6 +63,8 @@ const ( // SetAttrIn.Valid
)
type SetAttrInCommon struct {
InHeader
Valid uint32
Padding uint32
Fh uint64
......@@ -76,6 +85,7 @@ type SetAttrInCommon struct {
const RELEASE_FLUSH = (1 << 0)
type ReleaseIn struct {
InHeader
Fh uint64
Flags uint32
ReleaseFlags uint32
......@@ -83,6 +93,7 @@ type ReleaseIn struct {
}
type OpenIn struct {
InHeader
Flags uint32
Unused uint32
}
......@@ -120,6 +131,8 @@ const (
)
type InitIn struct {
InHeader
Major uint32
Minor uint32
MaxReadAhead uint32
......@@ -137,6 +150,7 @@ type InitOut struct {
}
type CuseInitIn struct {
InHeader
Major uint32
Minor uint32
Unused uint32
......@@ -156,10 +170,12 @@ type CuseInitOut struct {
}
type InterruptIn struct {
InHeader
Unique uint64
}
type BmapIn struct {
InHeader
Block uint64
Blocksize uint32
Padding uint32
......@@ -176,6 +192,7 @@ const (
)
type IoctlIn struct {
InHeader
Fh uint64
Flags uint32
Cmd uint32
......@@ -192,6 +209,7 @@ type IoctlOut struct {
}
type PollIn struct {
InHeader
Fh uint64
Kh uint64
Flags uint32
......@@ -213,11 +231,13 @@ type WriteOut struct {
}
type SetXAttrIn struct {
InHeader
Size uint32
Flags uint32
}
type GetXAttrIn struct {
InHeader
Size uint32
Padding uint32
}
......@@ -235,6 +255,7 @@ type FileLock struct {
}
type LkIn struct {
InHeader
Fh uint64
Owner uint64
Lk FileLock
......@@ -255,11 +276,13 @@ const (
)
type AccessIn struct {
InHeader
Mask uint32
Padding uint32
}
type FsyncIn struct {
InHeader
Fh uint64
FsyncFlags uint32
Padding uint32
......@@ -272,6 +295,7 @@ type OutHeader struct {
}
type CreateIn struct {
InHeader
Flags uint32
Mode uint32
Umask uint32
......@@ -308,6 +332,7 @@ const (
)
type FlushIn struct {
InHeader
Fh uint64
Unused uint32
Padding uint32
......@@ -380,6 +405,7 @@ const (
)
type FallocateIn struct {
InHeader
Fh uint64
Offset uint64
Length uint64
......
......@@ -62,6 +62,8 @@ func (g *GetAttrIn) Fh() uint64 {
}
type ReadIn struct {
InHeader
Fh uint64
Offset uint64
Size uint32
......@@ -69,6 +71,7 @@ type ReadIn struct {
}
type WriteIn struct {
InHeader
Fh uint64
Offset uint64
Size uint32
......@@ -89,6 +92,7 @@ type GetxtimesOut struct {
}
type ExchangeIn struct {
InHeader
Olddir uint64
Newdir uint64
Options uint64
......
......@@ -28,6 +28,8 @@ const (
)
type GetAttrIn struct {
InHeader
Flags_ uint32
Dummy uint32
Fh_ uint64
......@@ -46,6 +48,7 @@ func (g *GetAttrIn) Fh() uint64 {
}
type ReadIn struct {
InHeader
Fh uint64
Offset uint64
Size uint32
......@@ -56,6 +59,7 @@ type ReadIn struct {
}
type WriteIn struct {
InHeader
Fh uint64
Offset uint64
Size 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