cephfs: use new SplitSparseBuffer call in ListXattr function

Use the newly added SplitSparseBuffer cutil function to break the buffer
cephfs returns into a slice of strings with xattr names.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-07-24 09:59:36 -04:00 committed by John Mulligan
parent 1bbd6edb4b
commit d044f177c3
1 changed files with 2 additions and 8 deletions

View File

@ -12,9 +12,9 @@ package cephfs
import "C"
import (
"bytes"
"unsafe"
"github.com/ceph/go-ceph/internal/cutil"
"github.com/ceph/go-ceph/internal/retry"
)
@ -132,13 +132,7 @@ func (f *File) ListXattr() ([]string, error) {
return nil, err
}
names := make([]string, 0)
for _, s := range bytes.Split(buf[:ret], []byte{0}) {
if len(s) > 0 {
name := C.GoString((*C.char)(unsafe.Pointer(&s[0])))
names = append(names, name)
}
}
names := cutil.SplitSparseBuffer(buf[:ret])
return names, nil
}