mirror of
https://github.com/ceph/go-ceph
synced 2024-12-27 16:52:06 +00:00
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:
parent
1bbd6edb4b
commit
d044f177c3
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user