Skip to content

Commit f307586

Browse files
authored
fix(pkg/imagefs): add timespec declaration for 32-bit platforms (#27)
1 parent 0668f96 commit f307586

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

pkg/imagefs/imagefs.go

-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"strings"
2929
"sync"
3030
"syscall"
31-
"time"
3231

3332
v1 "github.com/google/go-containerregistry/pkg/v1"
3433
"github.com/pkg/errors"
@@ -306,10 +305,6 @@ func tarHeaderToStat_t(hdr *tar.Header) *syscall.Stat_t {
306305
}
307306
}
308307

309-
func timespec(t time.Time) syscall.Timespec {
310-
return syscall.Timespec{Sec: t.Unix(), Nsec: int64(t.Nanosecond())}
311-
}
312-
313308
// hashFile hashes the gievn file, implementation must match util.CacheHasher.
314309
func hashFile(hdr *tar.Header, r io.Reader) ([]byte, error) {
315310
fi := hdr.FileInfo()

pkg/imagefs/timespec_linux32.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build arm && linux
2+
// +build arm,linux
3+
4+
/*
5+
Copyright 2018 Google LLC
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package imagefs
21+
22+
import (
23+
"syscall"
24+
"time"
25+
)
26+
27+
func timespec(t time.Time) syscall.Timespec {
28+
return syscall.Timespec{Sec: int32(t.Unix()), Nsec: int32(t.Nanosecond())}
29+
}

pkg/imagefs/timespec_linux64.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build !arm && linux
2+
// +build !arm,linux
3+
4+
/*
5+
Copyright 2018 Google LLC
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package imagefs
21+
22+
import (
23+
"syscall"
24+
"time"
25+
)
26+
27+
func timespec(t time.Time) syscall.Timespec {
28+
return syscall.Timespec{Sec: t.Unix(), Nsec: int64(t.Nanosecond())}
29+
}

0 commit comments

Comments
 (0)