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
......
This diff is collapsed.
......@@ -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