Added support for init ops.

geesefs-0-30-9
Aaron Jacobs 2015-07-24 16:35:14 +10:00
parent 6a25a1071c
commit a07a396c6a
3 changed files with 46 additions and 3 deletions

View File

@ -112,9 +112,9 @@ func (c *Connection) Init() (err error) {
return
}
initOp, ok := op.(*fuseops.InitOp)
initOp, ok := op.(*fuseops.InternalInitOp)
if !ok {
err = fmt.Errorf("Expected *fuseops.InitOp, got %T", op)
err = fmt.Errorf("Expected *fuseops.InternalInitOp, got %T", op)
return
}
@ -137,7 +137,7 @@ func (c *Connection) Init() (err error) {
}
if initOp.Kernel.LT(c.protocol) {
c.protocol = r.Kernel
c.protocol = initOp.Kernel
}
// Respond to the init op.

View File

@ -418,6 +418,22 @@ func Convert(
io = to
co = &to.commonOp
case fusekernel.OpInit:
type input fusekernel.InitIn
in := (*input)(m.Consume(unsafe.Sizeof(input{})))
if in == nil {
err = errors.New("Corrupt OpInit")
return
}
to := &InternalInitOp{
Kernel: fusekernel.Protocol{in.Major, in.Minor},
MaxReadahead: in.MaxReadahead,
Flags: fusekernel.InitFlags(in.Flags),
}
io = to
co = &to.commonOp
default:
to := &unknownOp{
opCode: m.Header().Opcode,

View File

@ -945,3 +945,30 @@ type InternalInterruptOp struct {
func (o *InternalInterruptOp) kernelResponse() (b buffer.OutMessage) {
panic("Shouldn't get here.")
}
// Do not use this struct directly. See the TODO in fuseops/ops.go.
type InternalInitOp struct {
commonOp
// In
Kernel fusekernel.Protocol
// Out
Library fusekernel.Protocol
MaxReadahead uint32
Flags fusekernel.InitFlags
MaxWrite uint32
}
func (o *InternalInitOp) kernelResponse() (b buffer.OutMessage) {
b = buffer.NewOutMessage(unsafe.Sizeof(fusekernel.InitOut{}))
out := (*fusekernel.InitOut)(b.Grow(unsafe.Sizeof(fusekernel.InitOut{})))
out.Major = o.Library.Major
out.Minor = o.Library.Minor
out.MaxReadahead = o.MaxReadahead
out.Flags = uint32(o.Flags)
out.MaxWrite = o.MaxWrite
return
}