forked from moby/buildkit
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MountStubsCleaner: preserve timestamps
Fix issue 3148 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
- Loading branch information
1 parent
f771330
commit 0b5a315
Showing
4 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package system | ||
|
||
import ( | ||
"fmt" | ||
iofs "io/fs" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/containerd/continuity/fs" | ||
) | ||
|
||
func Atime(st iofs.FileInfo) (time.Time, error) { | ||
stSys, ok := st.Sys().(*syscall.Stat_t) | ||
if !ok { | ||
return time.Time{}, fmt.Errorf("expected st.Sys() to be *syscall.Stat_t, got %T", st.Sys()) | ||
} | ||
return fs.StatATimeAsTime(stSys), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package system | ||
|
||
import ( | ||
"fmt" | ||
iofs "io/fs" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func Atime(st iofs.FileInfo) (time.Time, error) { | ||
stSys, ok := st.Sys().(*syscall.Win32FileAttributeData) | ||
if !ok { | ||
return time.Time{}, fmt.Errorf("expected st.Sys() to be *syscall.Win32FileAttributeData, got %T", st.Sys()) | ||
} | ||
// ref: https://github.com/golang/go/blob/go1.19.2/src/os/types_windows.go#L230 | ||
return time.Unix(0, stSys.LastAccessTime.Nanoseconds()), nil | ||
} |