Fixed some build errors.

geesefs-0-30-9
Aaron Jacobs 2015-07-24 14:36:59 +10:00
parent 3b9092aca5
commit 64f4827424
2 changed files with 12 additions and 5 deletions

View File

@ -50,7 +50,7 @@ func Convert(
var io internalOp var io internalOp
switch m.Header().Opcode { switch m.Header().Opcode {
case fusekernel.OpLookup: case fusekernel.OpLookup:
buf := m.Bytes() buf := m.ConsumeBytes(m.Len())
n := len(buf) n := len(buf)
if n == 0 || buf[n-1] != '\x00' { if n == 0 || buf[n-1] != '\x00' {
err = errors.New("Corrupt OpLookup") err = errors.New("Corrupt OpLookup")
@ -74,8 +74,9 @@ func Convert(
co = &to.commonOp co = &to.commonOp
case fusekernel.OpSetattr: case fusekernel.OpSetattr:
in := (*fusekernel.SetattrIn)(m.Data()) type input fusekernel.SetattrIn
if m.Len() < unsafe.Sizeof(*in) { in := (*input)(m.Consume(unsafe.Sizeof(input{})))
if in == nil {
err = errors.New("Corrupt OpSetattr") err = errors.New("Corrupt OpSetattr")
return return
} }
@ -109,8 +110,9 @@ func Convert(
co = &to.commonOp co = &to.commonOp
case fusekernel.OpForget: case fusekernel.OpForget:
in := (*fusekernel.ForgetIn)(m.Data()) type input fusekernel.ForgetIn
if m.Len() < unsafe.Sizeof(*in) { in := (*input)(m.Consume(unsafe.Sizeof(input{})))
if in == nil {
err = errors.New("Corrupt OpForget") err = errors.New("Corrupt OpForget")
return return
} }

View File

@ -41,6 +41,11 @@ func (m *InMessage) Header() (h *fusekernel.InHeader) {
panic("TODO") panic("TODO")
} }
// Return the number of bytes left to consume.
func (m *InMessage) Len() uintptr {
panic("TODO")
}
// Consume the next n bytes from the message, returning a nil pointer if there // Consume the next n bytes from the message, returning a nil pointer if there
// are fewer than n bytes available. // are fewer than n bytes available.
func (m *InMessage) Consume(n uintptr) (p unsafe.Pointer) { func (m *InMessage) Consume(n uintptr) (p unsafe.Pointer) {