Commit d9c8d95d authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed a panic.

parent 0f1a471c
...@@ -34,6 +34,9 @@ type internalOp interface { ...@@ -34,6 +34,9 @@ type internalOp interface {
// Create a response message for the kernel, with leading pading for a // Create a response message for the kernel, with leading pading for a
// fusekernel.OutHeader struct. // fusekernel.OutHeader struct.
//
// Special case: a return value of nil means that the kernel is not expecting
// a response.
kernelResponse() []byte kernelResponse() []byte
} }
...@@ -147,7 +150,8 @@ func (o *commonOp) Respond(err error) { ...@@ -147,7 +150,8 @@ func (o *commonOp) Respond(err error) {
msg = fuseshim.NewBuffer(0) msg = fuseshim.NewBuffer(0)
} }
// Fill in the header. // Fill in the header if a reply is needed.
if msg != nil {
h := (*fusekernel.OutHeader)(unsafe.Pointer(&msg[0])) h := (*fusekernel.OutHeader)(unsafe.Pointer(&msg[0]))
h.Unique = o.fuseID h.Unique = o.fuseID
h.Len = uint32(len(msg)) h.Len = uint32(len(msg))
...@@ -159,6 +163,7 @@ func (o *commonOp) Respond(err error) { ...@@ -159,6 +163,7 @@ func (o *commonOp) Respond(err error) {
h.Error = -int32(errno) h.Error = -int32(errno)
} }
}
// Reply. // Reply.
replyErr := o.sendReply(o.op, o.fuseID, msg, err) replyErr := o.sendReply(o.op, o.fuseID, msg, err)
......
...@@ -217,7 +217,8 @@ type ForgetInodeOp struct { ...@@ -217,7 +217,8 @@ type ForgetInodeOp struct {
} }
func (o *ForgetInodeOp) kernelResponse() (msg []byte) { func (o *ForgetInodeOp) kernelResponse() (msg []byte) {
panic("TODO: Signal that no response should happen here.") // No response.
return
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -1061,10 +1061,13 @@ func errorString(err error) string { ...@@ -1061,10 +1061,13 @@ func errorString(err error) string {
return err.Error() return err.Error()
} }
func (c *Conn) WriteToKernel(msg []byte) error { func (c *Conn) writeToKernel(msg []byte) error {
out := (*fusekernel.OutHeader)(unsafe.Pointer(&msg[0])) out := (*fusekernel.OutHeader)(unsafe.Pointer(&msg[0]))
out.Len = uint32(len(msg)) out.Len = uint32(len(msg))
return c.WriteToKernel(msg)
}
func (c *Conn) WriteToKernel(msg []byte) error {
c.wio.RLock() c.wio.RLock()
defer c.wio.RUnlock() defer c.wio.RUnlock()
_, err := syscall.Write(c.fd(), msg) _, err := syscall.Write(c.fd(), msg)
......
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