1/*
2   Copyright The containerd Authors.
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15*/
16
17package fs
18
19import (
20	"syscall"
21	"time"
22)
23
24// StatAtime returns the Atim
25func StatAtime(st *syscall.Stat_t) syscall.Timespec {
26	return st.Atim
27}
28
29// StatCtime returns the Ctim
30func StatCtime(st *syscall.Stat_t) syscall.Timespec {
31	return st.Ctim
32}
33
34// StatMtime returns the Mtim
35func StatMtime(st *syscall.Stat_t) syscall.Timespec {
36	return st.Mtim
37}
38
39// StatATimeAsTime returns st.Atim as a time.Time
40func StatATimeAsTime(st *syscall.Stat_t) time.Time {
41	// The int64 conversions ensure the line compiles for 32-bit systems as well.
42	return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) // nolint: unconvert
43}
44