Commit 384f32c2 authored by Aaron Jacobs's avatar Aaron Jacobs

Connection.kernelResponseForOp

parent 5238806c
...@@ -419,29 +419,28 @@ func (c *Connection) kernelResponse( ...@@ -419,29 +419,28 @@ func (c *Connection) kernelResponse(
// Like kernelResponse, but assumes the user replied with a nil error to the // Like kernelResponse, but assumes the user replied with a nil error to the
// op. Returns a nil response if no response is required. // op. Returns a nil response if no response is required.
func kernelResponseForOp( func (c *Connection) kernelResponseForOp(
op interface{}, op interface{}) (m *buffer.OutMessage) {
protocol fusekernel.Protocol) (b buffer.OutMessage) {
// Create the appropriate output message // Create the appropriate output message
switch o := op.(type) { switch o := op.(type) {
case *fuseops.LookUpInodeOp: case *fuseops.LookUpInodeOp:
size := fusekernel.EntryOutSize(protocol) size := fusekernel.EntryOutSize(c.protocol)
b = buffer.NewOutMessage(size) m = c.getOutMessage()
out := (*fusekernel.EntryOut)(b.Grow(size)) out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out) convertChildInodeEntry(&o.Entry, out)
case *fuseops.GetInodeAttributesOp: case *fuseops.GetInodeAttributesOp:
size := fusekernel.AttrOutSize(protocol) size := fusekernel.AttrOutSize(c.protocol)
b = buffer.NewOutMessage(size) m = c.getOutMessage()
out := (*fusekernel.AttrOut)(b.Grow(size)) out := (*fusekernel.AttrOut)(m.Grow(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime( out.AttrValid, out.AttrValidNsec = convertExpirationTime(
o.AttributesExpiration) o.AttributesExpiration)
convertAttributes(o.Inode, &o.Attributes, &out.Attr) convertAttributes(o.Inode, &o.Attributes, &out.Attr)
case *fuseops.SetInodeAttributesOp: case *fuseops.SetInodeAttributesOp:
size := fusekernel.AttrOutSize(protocol) size := fusekernel.AttrOutSize(c.protocol)
b = buffer.NewOutMessage(size) m = c.getOutMessage()
out := (*fusekernel.AttrOut)(b.Grow(size)) out := (*fusekernel.AttrOut)(m.Grow(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime( out.AttrValid, out.AttrValidNsec = convertExpirationTime(
o.AttributesExpiration) o.AttributesExpiration)
convertAttributes(o.Inode, &o.Attributes, &out.Attr) convertAttributes(o.Inode, &o.Attributes, &out.Attr)
...@@ -450,85 +449,85 @@ func kernelResponseForOp( ...@@ -450,85 +449,85 @@ func kernelResponseForOp(
// No response. // No response.
case *fuseops.MkDirOp: case *fuseops.MkDirOp:
size := fusekernel.EntryOutSize(protocol) size := fusekernel.EntryOutSize(c.protocol)
b = buffer.NewOutMessage(size) m = c.getOutMessage()
out := (*fusekernel.EntryOut)(b.Grow(size)) out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out) convertChildInodeEntry(&o.Entry, out)
case *fuseops.CreateFileOp: case *fuseops.CreateFileOp:
eSize := fusekernel.EntryOutSize(protocol) eSize := fusekernel.EntryOutSize(c.protocol)
b = buffer.NewOutMessage(eSize + unsafe.Sizeof(fusekernel.OpenOut{})) m = c.getOutMessage()
e := (*fusekernel.EntryOut)(b.Grow(eSize)) e := (*fusekernel.EntryOut)(m.Grow(eSize))
convertChildInodeEntry(&o.Entry, e) convertChildInodeEntry(&o.Entry, e)
oo := (*fusekernel.OpenOut)(b.Grow(unsafe.Sizeof(fusekernel.OpenOut{}))) oo := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
oo.Fh = uint64(o.Handle) oo.Fh = uint64(o.Handle)
case *fuseops.CreateSymlinkOp: case *fuseops.CreateSymlinkOp:
size := fusekernel.EntryOutSize(protocol) size := fusekernel.EntryOutSize(c.protocol)
b = buffer.NewOutMessage(size) m = c.getOutMessage()
out := (*fusekernel.EntryOut)(b.Grow(size)) out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out) convertChildInodeEntry(&o.Entry, out)
case *fuseops.RenameOp: case *fuseops.RenameOp:
b = buffer.NewOutMessage(0) m = c.getOutMessage()
case *fuseops.RmDirOp: case *fuseops.RmDirOp:
b = buffer.NewOutMessage(0) m = c.getOutMessage()
case *fuseops.UnlinkOp: case *fuseops.UnlinkOp:
b = buffer.NewOutMessage(0) m = c.getOutMessage()
case *fuseops.OpenDirOp: case *fuseops.OpenDirOp:
b = buffer.NewOutMessage(unsafe.Sizeof(fusekernel.OpenOut{})) m = c.getOutMessage()
out := (*fusekernel.OpenOut)(b.Grow(unsafe.Sizeof(fusekernel.OpenOut{}))) out := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
out.Fh = uint64(o.Handle) out.Fh = uint64(o.Handle)
case *fuseops.ReadDirOp: case *fuseops.ReadDirOp:
b = buffer.NewOutMessage(uintptr(len(o.Data))) m = c.getOutMessage()
b.Append(o.Data) m.Append(o.Data)
case *fuseops.ReleaseDirHandleOp: case *fuseops.ReleaseDirHandleOp:
b = buffer.NewOutMessage(0) m = c.getOutMessage()
case *fuseops.OpenFileOp: case *fuseops.OpenFileOp:
b = buffer.NewOutMessage(unsafe.Sizeof(fusekernel.OpenOut{})) m = c.getOutMessage()
out := (*fusekernel.OpenOut)(b.Grow(unsafe.Sizeof(fusekernel.OpenOut{}))) out := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
out.Fh = uint64(o.Handle) out.Fh = uint64(o.Handle)
case *fuseops.ReadFileOp: case *fuseops.ReadFileOp:
b = buffer.NewOutMessage(uintptr(len(o.Data))) m = c.getOutMessage()
b.Append(o.Data) m.Append(o.Data)
case *fuseops.WriteFileOp: case *fuseops.WriteFileOp:
b = buffer.NewOutMessage(unsafe.Sizeof(fusekernel.WriteOut{})) m = c.getOutMessage()
out := (*fusekernel.WriteOut)(b.Grow(unsafe.Sizeof(fusekernel.WriteOut{}))) out := (*fusekernel.WriteOut)(m.Grow(unsafe.Sizeof(fusekernel.WriteOut{})))
out.Size = uint32(len(o.Data)) out.Size = uint32(len(o.Data))
case *fuseops.SyncFileOp: case *fuseops.SyncFileOp:
b = buffer.NewOutMessage(0) m = c.getOutMessage()
case *fuseops.FlushFileOp: case *fuseops.FlushFileOp:
b = buffer.NewOutMessage(0) m = c.getOutMessage()
case *fuseops.ReleaseFileHandleOp: case *fuseops.ReleaseFileHandleOp:
b = buffer.NewOutMessage(0) m = c.getOutMessage()
case *fuseops.ReadSymlinkOp: case *fuseops.ReadSymlinkOp:
b = buffer.NewOutMessage(uintptr(len(o.Target))) m = c.getOutMessage()
b.AppendString(o.Target) m.AppendString(o.Target)
case *statFSOp: case *statFSOp:
b = buffer.NewOutMessage(unsafe.Sizeof(fusekernel.StatfsOut{})) m = c.getOutMessage()
b.Grow(unsafe.Sizeof(fusekernel.StatfsOut{})) m.Grow(unsafe.Sizeof(fusekernel.StatfsOut{}))
case *interruptOp: case *interruptOp:
// No response. // No response.
case *initOp: case *initOp:
b = buffer.NewOutMessage(unsafe.Sizeof(fusekernel.InitOut{})) m = c.getOutMessage()
out := (*fusekernel.InitOut)(b.Grow(unsafe.Sizeof(fusekernel.InitOut{}))) out := (*fusekernel.InitOut)(m.Grow(unsafe.Sizeof(fusekernel.InitOut{})))
out.Major = o.Library.Major out.Major = o.Library.Major
out.Minor = o.Library.Minor out.Minor = o.Library.Minor
......
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