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