Commit 6ed7e494 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Integrate en/decode for printing into array approach.

parent c44a5101
......@@ -178,10 +178,10 @@ func (me *MountState) readRequest(req *request) os.Error {
}
func (me *MountState) discardRequest(req *request) {
if me.RecordStatistics {
endNs := time.Nanoseconds()
dt := endNs - req.startNs
if me.RecordStatistics {
me.statisticsMutex.Lock()
defer me.statisticsMutex.Unlock()
......
......@@ -14,6 +14,14 @@ import (
"io/ioutil"
)
func (code Status) String() string {
if code == OK {
return "OK"
}
return fmt.Sprintf("%d=%v", int(code), os.Errno(code))
}
// Make a temporary directory securely.
func MakeTempDir() string {
nm, err := ioutil.TempDir("", "go-fuse")
......
......@@ -3,24 +3,14 @@ package fuse
import (
"bytes"
"fmt"
"os"
"unsafe"
)
func (code Status) String() string {
if code == OK {
return "OK"
}
return fmt.Sprintf("%d=%v", int(code), os.Errno(code))
}
func replyString(opcode Opcode, ptr unsafe.Pointer) string {
h := getHandler(opcode)
var val interface{}
switch opcode {
case FUSE_LOOKUP:
val = (*EntryOut)(ptr)
case FUSE_OPEN:
val = (*OpenOut)(ptr)
if h.DecodeOut != nil {
val = h.DecodeOut(ptr)
}
if val != nil {
return fmt.Sprintf("%v", val)
......@@ -45,7 +35,6 @@ func doOpen(state *MountState, req *request) {
req.outData = unsafe.Pointer(out)
}
func doCreate(state *MountState, req *request) {
flags, handle, entry, status := state.fileSystem.Create(req.inHeader, (*CreateIn)(req.inData), req.filename())
req.status = status
......@@ -238,6 +227,8 @@ type operationHandler struct {
Func operationFunc
InputSize int
OutputSize int
DecodeIn func(unsafe.Pointer) interface{}
DecodeOut func(unsafe.Pointer) interface{}
}
var operationHandlers []*operationHandler
......@@ -394,4 +385,12 @@ func init() {
} {
operationHandlers[op].Func = v
}
operationHandlers[FUSE_LOOKUP].DecodeOut = func(ptr unsafe.Pointer) interface{} {
return (*EntryOut)(ptr)
}
operationHandlers[FUSE_OPEN].DecodeOut = func(ptr unsafe.Pointer) interface{} {
return (*EntryOut)(ptr)
}
}
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