From 380b52652cb5c1a3918907ffc136acd56cc916f0 Mon Sep 17 00:00:00 2001 From: Muhammad Kaisar Arkhan Date: Fri, 18 Dec 2020 21:39:43 +0100 Subject: [PATCH] Bring OpenBSD support Signed-off-by: Muhammad Kaisar Arkhan --- content/local/store_unix.go | 2 +- sys/stat_openbsd.go | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 sys/stat_openbsd.go diff --git a/content/local/store_unix.go b/content/local/store_unix.go index 270b8db7df12..3aff65e5333a 100644 --- a/content/local/store_unix.go +++ b/content/local/store_unix.go @@ -1,4 +1,4 @@ -// +build linux solaris darwin freebsd netbsd +// +build linux solaris darwin freebsd netbsd openbsd /* Copyright The containerd Authors. diff --git a/sys/stat_openbsd.go b/sys/stat_openbsd.go new file mode 100644 index 000000000000..ec3b9df69aa2 --- /dev/null +++ b/sys/stat_openbsd.go @@ -0,0 +1,45 @@ +// +build openbsd + +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package sys + +import ( + "syscall" + "time" +) + +// StatAtime returns the Atim +func StatAtime(st *syscall.Stat_t) syscall.Timespec { + return st.Atim +} + +// StatCtime returns the Ctim +func StatCtime(st *syscall.Stat_t) syscall.Timespec { + return st.Ctim +} + +// StatMtime returns the Mtim +func StatMtime(st *syscall.Stat_t) syscall.Timespec { + return st.Mtim +} + +// StatATimeAsTime returns st.Atim as a time.Time +func StatATimeAsTime(st *syscall.Stat_t) time.Time { + // The int64 conversions ensure the line compiles for 32-bit systems as well. + return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) // nolint: unconvert +}