diff options
author | Nicolas Lacasse <nlacasse@google.com> | 2020-01-15 16:31:24 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-15 16:32:55 -0800 |
commit | d6fb1ec6c7c76040dd20e915b32f9ed795ae7077 (patch) | |
tree | f5f3d37e086161c00bc5b3437b6c09603de8aca3 /pkg/abi/linux | |
parent | 7b7ce29af326ccd247ee5225e9b5b55a9d0330ce (diff) |
Add timestamps to VFS2 tmpfs, and implement some of SetStat.
PiperOrigin-RevId: 289962040
Diffstat (limited to 'pkg/abi/linux')
-rw-r--r-- | pkg/abi/linux/time.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/abi/linux/time.go b/pkg/abi/linux/time.go index 546668bca..5c5a58cd4 100644 --- a/pkg/abi/linux/time.go +++ b/pkg/abi/linux/time.go @@ -234,6 +234,19 @@ type StatxTimestamp struct { _ int32 } +// ToNsec returns the nanosecond representation. +func (sxts StatxTimestamp) ToNsec() int64 { + return int64(sxts.Sec)*1e9 + int64(sxts.Nsec) +} + +// ToNsecCapped returns the safe nanosecond representation. +func (sxts StatxTimestamp) ToNsecCapped() int64 { + if sxts.Sec > maxSecInDuration { + return math.MaxInt64 + } + return sxts.ToNsec() +} + // NsecToStatxTimestamp translates nanoseconds to StatxTimestamp. func NsecToStatxTimestamp(nsec int64) (ts StatxTimestamp) { return StatxTimestamp{ |