mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Update archive to use unix.Mknod directly
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"github.com/moby/sys/userns"
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -55,7 +54,7 @@ func setupOverlayTestDir(t *testing.T, src string) {
|
||||
err = os.Mkdir(filepath.Join(src, "d3"), 0o700)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = system.Mknod(filepath.Join(src, "d3", "f1"), unix.S_IFCHR, 0)
|
||||
err = unix.Mknod(filepath.Join(src, "d3", "f1"), unix.S_IFCHR, 0)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -109,7 +108,7 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
|
||||
mode |= unix.S_IFIFO
|
||||
}
|
||||
|
||||
return system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor)))
|
||||
return mknod(path, mode, unix.Mkdev(uint32(hdr.Devmajor), uint32(hdr.Devminor)))
|
||||
}
|
||||
|
||||
func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/moby/sys/userns"
|
||||
"golang.org/x/sys/unix"
|
||||
"gotest.tools/v3/assert"
|
||||
@@ -199,11 +198,11 @@ func TestTarWithBlockCharFifo(t *testing.T) {
|
||||
err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0o700)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = system.Mknod(filepath.Join(origin, "2"), unix.S_IFBLK, int(system.Mkdev(int64(12), int64(5))))
|
||||
err = mknod(filepath.Join(origin, "2"), unix.S_IFBLK, unix.Mkdev(uint32(12), uint32(5)))
|
||||
assert.NilError(t, err)
|
||||
err = system.Mknod(filepath.Join(origin, "3"), unix.S_IFCHR, int(system.Mkdev(int64(12), int64(5))))
|
||||
err = mknod(filepath.Join(origin, "3"), unix.S_IFCHR, unix.Mkdev(uint32(12), uint32(5)))
|
||||
assert.NilError(t, err)
|
||||
err = system.Mknod(filepath.Join(origin, "4"), unix.S_IFIFO, int(system.Mkdev(int64(12), int64(5))))
|
||||
err = mknod(filepath.Join(origin, "4"), unix.S_IFIFO, unix.Mkdev(uint32(12), uint32(5)))
|
||||
assert.NilError(t, err)
|
||||
|
||||
dest, err := os.MkdirTemp("", "docker-test-tar-hardlink-dest")
|
||||
|
||||
7
pkg/archive/dev_freebsd.go
Normal file
7
pkg/archive/dev_freebsd.go
Normal file
@@ -0,0 +1,7 @@
|
||||
//go:build freebsd
|
||||
|
||||
package archive // import "github.com/docker/docker/pkg/archive"
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
var mknod = unix.Mknod
|
||||
9
pkg/archive/dev_unix.go
Normal file
9
pkg/archive/dev_unix.go
Normal file
@@ -0,0 +1,9 @@
|
||||
//go:build !windows && !freebsd
|
||||
|
||||
package archive // import "github.com/docker/docker/pkg/archive"
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
func mknod(path string, mode uint32, dev uint64) error {
|
||||
return unix.Mknod(path, mode, int(dev))
|
||||
}
|
||||
Reference in New Issue
Block a user