Commit 9dac968e authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Cleanup debug printing, and expose InitIn in MountState.

parent 9c6ab192
...@@ -58,21 +58,17 @@ func (me *request) filenames(count int) []string { ...@@ -58,21 +58,17 @@ func (me *request) filenames(count int) []string {
} }
func (me *request) InputDebug(h *operationHandler) string { func (me *request) InputDebug(h *operationHandler) string {
var val interface{} val := " "
if h.DecodeIn != nil { if h.DecodeIn != nil {
val = h.DecodeIn(me.inData) val = fmt.Sprintf(" data: %v ", h.DecodeIn(me.inData))
} else {
val = ""
} }
var names interface{} names := ""
if h.FileNames > 0 { if h.FileNames > 0 {
names = me.filenames(h.FileNames) names = fmt.Sprintf("names: %v", me.filenames(h.FileNames))
} else { }
names = ""
}
return fmt.Sprintf("Dispatch: %v, NodeId: %v. Data: %v Names: %v", return fmt.Sprintf("Dispatch: %v, NodeId: %v.%v%v",
me.inHeader.opcode, me.inHeader.NodeId, val, names) me.inHeader.opcode, me.inHeader.NodeId, val, names)
} }
...@@ -118,6 +114,12 @@ type MountState struct { ...@@ -118,6 +114,12 @@ type MountState struct {
buffers *BufferPool buffers *BufferPool
*LatencyMap *LatencyMap
kernelSettings InitIn
}
func (me *MountState) KernelSettings() InitIn {
return me.kernelSettings
} }
// Mount filesystem on mountPoint. // Mount filesystem on mountPoint.
......
...@@ -71,11 +71,13 @@ func doInit(state *MountState, req *request) { ...@@ -71,11 +71,13 @@ func doInit(state *MountState, req *request) {
return return
} }
state.kernelSettings = *input
state.kernelSettings.Flags = input.Flags & (CAP_ASYNC_READ | CAP_BIG_WRITES)
out := &InitOut{ out := &InitOut{
Major: FUSE_KERNEL_VERSION, Major: FUSE_KERNEL_VERSION,
Minor: FUSE_KERNEL_MINOR_VERSION, Minor: FUSE_KERNEL_MINOR_VERSION,
MaxReadAhead: input.MaxReadAhead, MaxReadAhead: input.MaxReadAhead,
Flags: CAP_ASYNC_READ | CAP_POSIX_LOCKS | CAP_BIG_WRITES, Flags: state.kernelSettings.Flags,
MaxWrite: maxRead, MaxWrite: maxRead,
CongestionThreshold: _BACKGROUND_TASKS * 3 / 4, CongestionThreshold: _BACKGROUND_TASKS * 3 / 4,
MaxBackground: _BACKGROUND_TASKS, MaxBackground: _BACKGROUND_TASKS,
...@@ -136,7 +138,6 @@ func doOpenDir(state *MountState, req *request) { ...@@ -136,7 +138,6 @@ func doOpenDir(state *MountState, req *request) {
} }
func doSetattr(state *MountState, req *request) { func doSetattr(state *MountState, req *request) {
// TODO - if Fh != 0, we should do a FSetAttr instead.
o, s := state.fileSystem.SetAttr(req.inHeader, (*SetAttrIn)(req.inData)) o, s := state.fileSystem.SetAttr(req.inHeader, (*SetAttrIn)(req.inData))
req.outData = unsafe.Pointer(o) req.outData = unsafe.Pointer(o)
req.status = s req.status = s
...@@ -461,12 +462,14 @@ func init() { ...@@ -461,12 +462,14 @@ func init() {
_OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, _OP_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) },
_OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, _OP_OPEN: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) },
_OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) }, _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) },
_OP_CREATE: func(ptr unsafe.Pointer) interface{} { return (*CreateOut)(ptr) },
} { } {
operationHandlers[op].DecodeOut = f operationHandlers[op].DecodeOut = f
} }
for op, f := range map[opcode]castPointerFunc{ for op, f := range map[opcode]castPointerFunc{
_OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*GetAttrIn)(ptr) }, _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*GetAttrIn)(ptr) },
_OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*SetAttrIn)(ptr) }, _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*SetAttrIn)(ptr) },
_OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*InitIn)(ptr) },
} { } {
operationHandlers[op].DecodeIn = f operationHandlers[op].DecodeIn = f
} }
......
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