From 0ca58b6fd2f95755db11daa08f3d25db6f5aeb6e Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Fri, 30 Aug 2024 14:51:09 +0100 Subject: [PATCH 1/2] fix(pkg/imagefs): add timespec declaration for 32-bit platforms --- pkg/imagefs/imagefs.go | 5 ----- pkg/imagefs/timespec_linux32.go | 12 ++++++++++++ pkg/imagefs/timespec_linux64.go | 12 ++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 pkg/imagefs/timespec_linux32.go create mode 100644 pkg/imagefs/timespec_linux64.go diff --git a/pkg/imagefs/imagefs.go b/pkg/imagefs/imagefs.go index dc148b3b31..7a90fdbfa0 100644 --- a/pkg/imagefs/imagefs.go +++ b/pkg/imagefs/imagefs.go @@ -28,7 +28,6 @@ import ( "strings" "sync" "syscall" - "time" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/pkg/errors" @@ -306,10 +305,6 @@ func tarHeaderToStat_t(hdr *tar.Header) *syscall.Stat_t { } } -func timespec(t time.Time) syscall.Timespec { - return syscall.Timespec{Sec: t.Unix(), Nsec: int64(t.Nanosecond())} -} - // hashFile hashes the gievn file, implementation must match util.CacheHasher. func hashFile(hdr *tar.Header, r io.Reader) ([]byte, error) { fi := hdr.FileInfo() diff --git a/pkg/imagefs/timespec_linux32.go b/pkg/imagefs/timespec_linux32.go new file mode 100644 index 0000000000..8a0c439fe7 --- /dev/null +++ b/pkg/imagefs/timespec_linux32.go @@ -0,0 +1,12 @@ +//go:build arm && linux + +package imagefs + +import ( + "syscall" + "time" +) + +func timespec(t time.Time) syscall.Timespec { + return syscall.Timespec{Sec: int32(t.Unix()), Nsec: int32(t.Nanosecond())} +} diff --git a/pkg/imagefs/timespec_linux64.go b/pkg/imagefs/timespec_linux64.go new file mode 100644 index 0000000000..5aef309d1d --- /dev/null +++ b/pkg/imagefs/timespec_linux64.go @@ -0,0 +1,12 @@ +//go:build !arm && linux + +package imagefs + +import ( + "syscall" + "time" +) + +func timespec(t time.Time) syscall.Timespec { + return syscall.Timespec{Sec: t.Unix(), Nsec: int64(t.Nanosecond())} +} From e30d9b70888d052a604d89478b0a80288fb1cac9 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Fri, 30 Aug 2024 14:58:39 +0100 Subject: [PATCH 2/2] boilerplate --- pkg/imagefs/timespec_linux32.go | 17 +++++++++++++++++ pkg/imagefs/timespec_linux64.go | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/pkg/imagefs/timespec_linux32.go b/pkg/imagefs/timespec_linux32.go index 8a0c439fe7..117240d566 100644 --- a/pkg/imagefs/timespec_linux32.go +++ b/pkg/imagefs/timespec_linux32.go @@ -1,4 +1,21 @@ //go:build arm && linux +// +build arm,linux + +/* +Copyright 2018 Google LLC + +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 imagefs diff --git a/pkg/imagefs/timespec_linux64.go b/pkg/imagefs/timespec_linux64.go index 5aef309d1d..cdfde7cd45 100644 --- a/pkg/imagefs/timespec_linux64.go +++ b/pkg/imagefs/timespec_linux64.go @@ -1,4 +1,21 @@ //go:build !arm && linux +// +build !arm,linux + +/* +Copyright 2018 Google LLC + +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 imagefs