mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: update go-ceph to v0.5.0
as go-ceph is 0.5.0 is released updating the dependency to latest release. more info about release at https://github.com/ceph/go-ceph/releases/tag/v0.5.0 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
5f6fec5f0a
commit
2808d526bb
49
vendor/github.com/ceph/go-ceph/internal/cutil/splitbuf.go
generated
vendored
Normal file
49
vendor/github.com/ceph/go-ceph/internal/cutil/splitbuf.go
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
package cutil
|
||||
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
)
|
||||
|
||||
// SplitBuffer splits a byte-slice buffer, typically returned from C code,
|
||||
// into a slice of strings.
|
||||
// The contents of the buffer are assumed to be null-byte separated.
|
||||
// If the buffer contains a sequence of null-bytes it will assume that the
|
||||
// "space" between the bytes are meant to be empty strings.
|
||||
func SplitBuffer(b []byte) []string {
|
||||
return splitBufStrings(b, true)
|
||||
}
|
||||
|
||||
// SplitSparseBuffer splits a byte-slice buffer, typically returned from C code,
|
||||
// into a slice of strings.
|
||||
// The contents of the buffer are assumed to be null-byte separated.
|
||||
// This function assumes that buffer to be "sparse" such that only non-null-byte
|
||||
// strings will be returned, and no "empty" strings exist if null-bytes
|
||||
// are found adjacent to each other.
|
||||
func SplitSparseBuffer(b []byte) []string {
|
||||
return splitBufStrings(b, false)
|
||||
}
|
||||
|
||||
// If keepEmpty is true, empty substrings will be returned, by default they are
|
||||
// excluded from the results.
|
||||
// This is almost certainly a suboptimal implementation, especially for
|
||||
// keepEmpty=true case. Optimizing the functions is a job for another day.
|
||||
func splitBufStrings(b []byte, keepEmpty bool) []string {
|
||||
values := make([]string, 0)
|
||||
// the final null byte should be the terminating null in C
|
||||
// we never want to preserve the empty string after it
|
||||
if len(b) > 0 && b[len(b)-1] == 0 {
|
||||
b = b[:len(b)-1]
|
||||
}
|
||||
if len(b) == 0 {
|
||||
return values
|
||||
}
|
||||
for _, s := range bytes.Split(b, []byte{0}) {
|
||||
if !keepEmpty && len(s) == 0 {
|
||||
continue
|
||||
}
|
||||
values = append(values, string(s))
|
||||
}
|
||||
return values
|
||||
}
|
17
vendor/github.com/ceph/go-ceph/internal/errutil/strerror.go
generated
vendored
17
vendor/github.com/ceph/go-ceph/internal/errutil/strerror.go
generated
vendored
@ -14,6 +14,7 @@ package errutil
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@ -37,9 +38,15 @@ func FormatErrno(errno int) (int, string) {
|
||||
return errno, C.GoString((*C.char)(unsafe.Pointer(&buf[0])))
|
||||
}
|
||||
|
||||
// StrError returns a string describing the errno. The string will be empty if
|
||||
// the errno is not known.
|
||||
func StrError(errno int) string {
|
||||
_, s := FormatErrno(errno)
|
||||
return s
|
||||
// FormatErrorCode returns a string that describes the supplied error source
|
||||
// and error code as a string. Suitable to use in Error() methods. If the
|
||||
// error code maps to an errno the string will contain a description of the
|
||||
// error. Otherwise the string will only indicate the source and value if the
|
||||
// value does not map to a known errno.
|
||||
func FormatErrorCode(source string, errValue int) string {
|
||||
_, s := FormatErrno(errValue)
|
||||
if s == "" {
|
||||
return fmt.Sprintf("%s: ret=%d", source, errValue)
|
||||
}
|
||||
return fmt.Sprintf("%s: ret=%d, %s", source, errValue, s)
|
||||
}
|
||||
|
30
vendor/github.com/ceph/go-ceph/internal/timespec/timespec.go
generated
vendored
Normal file
30
vendor/github.com/ceph/go-ceph/internal/timespec/timespec.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
package timespec
|
||||
|
||||
/*
|
||||
#include <time.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Timespec behaves similarly to C's struct timespec.
|
||||
// Timespec is used to retain fidelity to the C based file systems
|
||||
// apis that could be lossy with the use of Go time types.
|
||||
type Timespec unix.Timespec
|
||||
|
||||
// CTimespecPtr is an unsafe pointer wrapping C's `struct timespec`.
|
||||
type CTimespecPtr unsafe.Pointer
|
||||
|
||||
// CStructToTimespec creates a new Timespec for the C 'struct timespec'.
|
||||
func CStructToTimespec(cts CTimespecPtr) Timespec {
|
||||
t := (*C.struct_timespec)(cts)
|
||||
|
||||
return Timespec{
|
||||
Sec: int64(t.tv_sec),
|
||||
Nsec: int64(t.tv_nsec),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user