Commit 75e419f3 authored by Aaron Jacobs's avatar Aaron Jacobs

OpenFileOp.kernelResponse

parent 5cc86afa
......@@ -18,7 +18,9 @@ import (
"fmt"
"os"
"time"
"unsafe"
"github.com/jacobsa/fuse/internal/fusekernel"
"github.com/jacobsa/fuse/internal/fuseshim"
"golang.org/x/net/context"
)
......@@ -622,7 +624,6 @@ func (o *ReleaseDirHandleOp) respond() {
// (cf.https://github.com/osxfuse/osxfuse/issues/199).
type OpenFileOp struct {
commonOp
bfReq *fuseshim.OpenRequest
// The ID of the inode to be opened.
Inode InodeID
......@@ -637,12 +638,12 @@ type OpenFileOp struct {
Handle HandleID
}
func (o *OpenFileOp) respond() {
resp := fuseshim.OpenResponse{
Handle: fuseshim.HandleID(o.Handle),
}
func (o *OpenFileOp) kernelResponse() (msg []byte) {
buf := fuseshim.NewBuffer(unsafe.Sizeof(fusekernel.OpenOut{}))
out := (*fusekernel.OpenOut)(buf.Alloc(unsafe.Sizeof(fusekernel.OpenOut{})))
out.Fh = uint64(o.Handle)
o.bfReq.Respond(&resp)
msg = buf
return
}
......
......@@ -6,13 +6,13 @@ import (
"github.com/jacobsa/fuse/internal/fusekernel"
)
// buffer provides a mechanism for constructing a message from
// multiple segments.
type buffer []byte
// Buffer provides a mechanism for constructing a message from multiple
// segments.
type Buffer []byte
// alloc allocates size bytes and returns a pointer to the new
// segment.
func (w *buffer) alloc(size uintptr) unsafe.Pointer {
func (w *Buffer) Alloc(size uintptr) unsafe.Pointer {
s := int(size)
if len(*w)+s > cap(*w) {
old := *w
......@@ -25,15 +25,15 @@ func (w *buffer) alloc(size uintptr) unsafe.Pointer {
}
// reset clears out the contents of the buffer.
func (w *buffer) reset() {
func (w *Buffer) reset() {
for i := range (*w)[:cap(*w)] {
(*w)[i] = 0
}
*w = (*w)[:0]
}
func newBuffer(extra uintptr) buffer {
func NewBuffer(extra uintptr) (buf Buffer) {
const hdrSize = unsafe.Sizeof(fusekernel.OutHeader{})
buf := make(buffer, hdrSize, hdrSize+extra)
return buf
buf = make(Buffer, hdrSize, hdrSize+extra)
return
}
This diff is collapsed.
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