Skip to content

Commit 86f080c

Browse files
committed
Use Mkdev, Major and Minor functions from golang.org/x/sys/unix
Update golang.org/x/sys to 8dbc5d05d6edcc104950cc299a1ce6641235bc86 in order to get the Major, Minor and Mkdev functions for every unix-like OS. Use them instead of the locally defined versions which currently use the Linux specific device major/minor encoding. This means that the device number should now be properly encoded on e.g. Darwin, FreeBSD or Solaris. Also, the SIGUNUSED constant was removed from golang.org/x/sys/unix in https://go-review.googlesource.com/61771 as it is also removed from the respective glibc headers. Remove it from signal.SignalMap as well after the golang.org/x/sys re-vendoring. Signed-off-by: Tobias Klauser <[email protected]>
1 parent 239d61f commit 86f080c

94 files changed

Lines changed: 2991 additions & 411 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pkg/archive/archive_unix.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, stat interface{}) (
5050
// Currently go does not fill in the major/minors
5151
if s.Mode&unix.S_IFBLK != 0 ||
5252
s.Mode&unix.S_IFCHR != 0 {
53-
hdr.Devmajor = int64(major(uint64(s.Rdev))) // nolint: unconvert
54-
hdr.Devminor = int64(minor(uint64(s.Rdev))) // nolint: unconvert
53+
hdr.Devmajor = int64(unix.Major(uint64(s.Rdev))) // nolint: unconvert
54+
hdr.Devminor = int64(unix.Minor(uint64(s.Rdev))) // nolint: unconvert
5555
}
5656
}
5757

@@ -77,14 +77,6 @@ func getFileUIDGID(stat interface{}) (idtools.IDPair, error) {
7777
return idtools.IDPair{UID: int(s.Uid), GID: int(s.Gid)}, nil
7878
}
7979

80-
func major(device uint64) uint64 {
81-
return (device >> 8) & 0xfff
82-
}
83-
84-
func minor(device uint64) uint64 {
85-
return (device & 0xff) | ((device >> 12) & 0xfff00)
86-
}
87-
8880
// handleTarTypeBlockCharFifo is an OS-specific helper function used by
8981
// createTarFile to handle the following types of header: Block; Char; Fifo
9082
func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {

pkg/archive/changes_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func OverlayChanges(layers []string, rw string) ([]Change, error) {
294294
func overlayDeletedFile(root, path string, fi os.FileInfo) (string, error) {
295295
if fi.Mode()&os.ModeCharDevice != 0 {
296296
s := fi.Sys().(*syscall.Stat_t)
297-
if major(s.Rdev) == 0 && minor(s.Rdev) == 0 {
297+
if unix.Major(uint64(s.Rdev)) == 0 && unix.Minor(uint64(s.Rdev)) == 0 { // nolint: unconvert
298298
return path, nil
299299
}
300300
}

pkg/signal/signal_linux.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ var SignalMap = map[string]syscall.Signal{
4040
"TSTP": unix.SIGTSTP,
4141
"TTIN": unix.SIGTTIN,
4242
"TTOU": unix.SIGTTOU,
43-
"UNUSED": unix.SIGUNUSED,
4443
"URG": unix.SIGURG,
4544
"USR1": unix.SIGUSR1,
4645
"USR2": unix.SIGUSR2,

pkg/system/mknod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ func Mknod(path string, mode uint32, dev int) error {
1818
// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
1919
// then the top 12 bits of the minor.
2020
func Mkdev(major int64, minor int64) uint32 {
21-
return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
21+
return uint32(unix.Mkdev(uint32(major), uint32(minor)))
2222
}

vendor.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ github.com/sirupsen/logrus v1.0.3
1414
github.com/tchap/go-patricia v2.2.6
1515
github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3
1616
golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6
17-
golang.org/x/sys 07c182904dbd53199946ba614a412c61d3c548f5
17+
golang.org/x/sys 8dbc5d05d6edcc104950cc299a1ce6641235bc86
1818
github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
1919
github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
2020
golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756

vendor/golang.org/x/sys/README

Lines changed: 0 additions & 3 deletions
This file was deleted.

vendor/golang.org/x/sys/README.md

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/dev_darwin.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/dev_dragonfly.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/dev_freebsd.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)