go-ceph/cephfs/timespec.go
John Mulligan d4079e3949 cephfs: add path based Statx function implmenting ceph_statx
Add a Statx wrapper for ceph_statx.
Add a type wrapping the statx status info that exposes the various
fields from the C-struct.
Add a type wrapping struct timespec, based on golang's x/sys, for the
time fields in the struct.
Note that the ceph struct is not the same as the linux statx struct.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-07 13:44:19 -04:00

23 lines
427 B
Go

package cephfs
/*
#include <time.h>
*/
import "C"
import (
"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
func cStructToTimespec(t C.struct_timespec) Timespec {
return Timespec{
Sec: int64(t.tv_sec),
Nsec: int64(t.tv_nsec),
}
}