Fixed a panic.

geesefs-0-30-9
Aaron Jacobs 2015-07-24 11:54:56 +10:00
parent 0f1a471c06
commit d9c8d95df7
3 changed files with 21 additions and 12 deletions

View File

@ -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,17 +150,19 @@ 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.
h := (*fusekernel.OutHeader)(unsafe.Pointer(&msg[0])) if msg != nil {
h.Unique = o.fuseID h := (*fusekernel.OutHeader)(unsafe.Pointer(&msg[0]))
h.Len = uint32(len(msg)) h.Unique = o.fuseID
if err != nil { h.Len = uint32(len(msg))
errno := fuseshim.EIO if err != nil {
if ferr, ok := err.(fuseshim.ErrorNumber); ok { errno := fuseshim.EIO
errno = ferr.Errno() if ferr, ok := err.(fuseshim.ErrorNumber); ok {
} errno = ferr.Errno()
}
h.Error = -int32(errno) h.Error = -int32(errno)
}
} }
// Reply. // Reply.

View File

@ -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
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

View File

@ -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)