mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
86f080cff0
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 <tklauser@distanz.ch>
29 lines
918 B
Go
29 lines
918 B
Go
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Functions to access/create device major and minor numbers matching the
|
|
// encoding used in OpenBSD's sys/types.h header.
|
|
|
|
package unix
|
|
|
|
// Major returns the major component of an OpenBSD device number.
|
|
func Major(dev uint64) uint32 {
|
|
return uint32((dev & 0x0000ff00) >> 8)
|
|
}
|
|
|
|
// Minor returns the minor component of an OpenBSD device number.
|
|
func Minor(dev uint64) uint32 {
|
|
minor := uint32((dev & 0x000000ff) >> 0)
|
|
minor |= uint32((dev & 0xffff0000) >> 8)
|
|
return minor
|
|
}
|
|
|
|
// Mkdev returns an OpenBSD device number generated from the given major and minor
|
|
// components.
|
|
func Mkdev(major, minor uint32) uint64 {
|
|
dev := (uint64(major) << 8) & 0x0000ff00
|
|
dev |= (uint64(minor) << 8) & 0xffff0000
|
|
dev |= (uint64(minor) << 0) & 0x000000ff
|
|
return dev
|
|
}
|