replace sys Sequential funcs with moby/sys/sequential

These functions were originally copied from the docker / moby repository in
4a7a8efc2d. Migrating these functions to use the
github.com/moby/sys/sequential module allows them being shared between moby,
docker/cli, and containerd, and to allow using them without importing all of sys
which also depends on hcsshim and more.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2022-08-27 14:25:07 +02:00
parent bf8cdc2918
commit 93342d637c
12 changed files with 490 additions and 110 deletions

View File

@@ -23,7 +23,7 @@ import (
"os"
"strings"
"github.com/containerd/containerd/sys"
"github.com/moby/sys/sequential"
)
// tarName returns platform-specific filepath
@@ -57,15 +57,15 @@ func setHeaderForSpecialDevice(*tar.Header, string, os.FileInfo) error {
}
func open(p string) (*os.File, error) {
// We use sys.OpenSequential to ensure we use sequential file
// access on Windows to avoid depleting the standby list.
return sys.OpenSequential(p)
// We use sequential file access to avoid depleting the standby list on
// Windows.
return sequential.Open(p)
}
func openFile(name string, flag int, perm os.FileMode) (*os.File, error) {
// Source is regular file. We use sys.OpenFileSequential to use sequential
// file access to avoid depleting the standby list on Windows.
return sys.OpenFileSequential(name, flag, perm)
// Source is regular file. We use sequential file access to avoid depleting
// the standby list on Windows.
return sequential.OpenFile(name, flag, perm)
}
func mkdir(path string, perm os.FileMode) error {