Commit d98de7e2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Cleanups for XAttr functions.

parent 03081e9d
...@@ -160,23 +160,28 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -160,23 +160,28 @@ func doGetXAttr(state *MountState, req *request) {
} }
input := (*raw.GetXAttrIn)(req.inData) input := (*raw.GetXAttrIn)(req.inData)
var data []byte
switch { if req.inHeader.Opcode == _OP_GETXATTR && input.Size == 0 {
case req.inHeader.Opcode == _OP_GETXATTR && input.Size == 0:
out := (*raw.GetXAttrOut)(req.outData) out := (*raw.GetXAttrOut)(req.outData)
sz, code := state.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0]) sz, code := state.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0])
if code.Ok() { if code.Ok() {
out.Size = uint32(sz) out.Size = uint32(sz)
req.status = ERANGE req.status = ERANGE
return
} }
req.status = code req.status = code
case req.inHeader.Opcode == _OP_GETXATTR: return
req.outData = nil }
req.outData = nil
var data []byte
switch req.inHeader.Opcode {
case _OP_GETXATTR:
data, req.status = state.fileSystem.GetXAttrData(req.inHeader, req.filenames[0]) data, req.status = state.fileSystem.GetXAttrData(req.inHeader, req.filenames[0])
default: case _OP_LISTXATTR:
req.outData = nil
data, req.status = state.fileSystem.ListXAttr(req.inHeader) data, req.status = state.fileSystem.ListXAttr(req.inHeader)
default:
log.Panicf("xattr opcode %v", req.inHeader.Opcode)
req.status = ENOSYS
} }
if len(data) > int(input.Size) { if len(data) > int(input.Size) {
...@@ -511,6 +516,8 @@ func init() { ...@@ -511,6 +516,8 @@ func init() {
for op, f := range map[int32]castPointerFunc{ for op, f := range map[int32]castPointerFunc{
_OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*raw.FlushIn)(ptr) }, _OP_FLUSH: func(ptr unsafe.Pointer) interface{} { return (*raw.FlushIn)(ptr) },
_OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.GetAttrIn)(ptr) }, _OP_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.GetAttrIn)(ptr) },
_OP_GETXATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.GetXAttrIn)(ptr) },
_OP_LISTXATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.GetXAttrIn)(ptr) },
_OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.SetAttrIn)(ptr) }, _OP_SETATTR: func(ptr unsafe.Pointer) interface{} { return (*raw.SetAttrIn)(ptr) },
_OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*raw.InitIn)(ptr) }, _OP_INIT: func(ptr unsafe.Pointer) interface{} { return (*raw.InitIn)(ptr) },
_OP_IOCTL: func(ptr unsafe.Pointer) interface{} { return (*raw.IoctlIn)(ptr) }, _OP_IOCTL: func(ptr unsafe.Pointer) interface{} { return (*raw.IoctlIn)(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