From 5a0beaefbb64190696f8e634d037bc9047e6f4ac Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 23 Jun 2021 00:08:49 +0200 Subject: [PATCH] sys: remove StatAtime(), StatCtime(), StatMtime() and StatATimeAsTime() utils This removes the StatAtime(), StatCtime(), StatMtime() and StatATimeAsTime() utilities from the sys package. These utilities are not currently used in the containerd codebase, and a copy of these utilities can be found in github.com/containerd/continuity/fs; - https://github.com/containerd/continuity/blob/fa7d1622372f1a787bfe51d59183b598813ce9d9/fs/stat_darwinbsd.go - https://github.com/containerd/continuity/blob/fa7d1622372f1a787bfe51d59183b598813ce9d9/fs/stat_linuxopenbsd.go Given that the containerd/sys package is not designed for external consumption, I'm not adding "deprecated" comments (or aliases to their new location). Signed-off-by: Sebastiaan van Stijn --- sys/stat_bsd.go | 44 -------------------------------------------- sys/stat_openbsd.go | 45 --------------------------------------------- sys/stat_unix.go | 44 -------------------------------------------- 3 files changed, 133 deletions(-) delete mode 100644 sys/stat_bsd.go delete mode 100644 sys/stat_openbsd.go delete mode 100644 sys/stat_unix.go diff --git a/sys/stat_bsd.go b/sys/stat_bsd.go deleted file mode 100644 index 4f03cd6cb..000000000 --- a/sys/stat_bsd.go +++ /dev/null @@ -1,44 +0,0 @@ -// +build darwin freebsd netbsd - -/* - 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 access time from a stat struct -func StatAtime(st *syscall.Stat_t) syscall.Timespec { - return st.Atimespec -} - -// StatCtime returns the created time from a stat struct -func StatCtime(st *syscall.Stat_t) syscall.Timespec { - return st.Ctimespec -} - -// StatMtime returns the modified time from a stat struct -func StatMtime(st *syscall.Stat_t) syscall.Timespec { - return st.Mtimespec -} - -// StatATimeAsTime returns the access time as a time.Time -func StatATimeAsTime(st *syscall.Stat_t) time.Time { - return time.Unix(int64(st.Atimespec.Sec), int64(st.Atimespec.Nsec)) // nolint: unconvert -} diff --git a/sys/stat_openbsd.go b/sys/stat_openbsd.go deleted file mode 100644 index ec3b9df69..000000000 --- a/sys/stat_openbsd.go +++ /dev/null @@ -1,45 +0,0 @@ -// +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 -} diff --git a/sys/stat_unix.go b/sys/stat_unix.go deleted file mode 100644 index 21a666dff..000000000 --- a/sys/stat_unix.go +++ /dev/null @@ -1,44 +0,0 @@ -// +build linux solaris - -/* - 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 { - return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) // nolint: unconvert -}