Skip to content

Commit

Permalink
fix(pkg/imagefs): add timespec declaration for 32-bit platforms (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstcn authored Aug 30, 2024
1 parent 0668f96 commit f307586
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
5 changes: 0 additions & 5 deletions pkg/imagefs/imagefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"strings"
"sync"
"syscall"
"time"

v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/pkg/errors"
Expand Down Expand Up @@ -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()
Expand Down
29 changes: 29 additions & 0 deletions pkg/imagefs/timespec_linux32.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//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

import (
"syscall"
"time"
)

func timespec(t time.Time) syscall.Timespec {
return syscall.Timespec{Sec: int32(t.Unix()), Nsec: int32(t.Nanosecond())}
}
29 changes: 29 additions & 0 deletions pkg/imagefs/timespec_linux64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//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

import (
"syscall"
"time"
)

func timespec(t time.Time) syscall.Timespec {
return syscall.Timespec{Sec: t.Unix(), Nsec: int64(t.Nanosecond())}
}

0 comments on commit f307586

Please sign in to comment.