vendor: update github.com/containerd/continuity

Signed-off-by: Edward Pilatowicz <edward.pilatowicz@oracle.com>
This commit is contained in:
Edward Pilatowicz
2017-07-25 16:55:47 -07:00
parent 0fa76584f8
commit 47637f2aa2
29 changed files with 423 additions and 104 deletions

View File

@@ -0,0 +1,5 @@
package devices
import "fmt"
var ErrNotSupported = fmt.Errorf("not supported")

View File

@@ -0,0 +1,15 @@
package devices
// from /usr/include/sys/types.h
func getmajor(dev int32) uint64 {
return (uint64(dev) >> 24) & 0xff
}
func getminor(dev int32) uint64 {
return uint64(dev) & 0xffffff
}
func makedev(major int, minor int) int {
return ((major << 24) | minor)
}

View File

@@ -0,0 +1,23 @@
// +build solaris,!cgo
//
// Implementing the functions below requires cgo support. Non-cgo stubs
// versions are defined below to enable cross-compilation of source code
// that depends on these functions, but the resultant cross-compiled
// binaries cannot actually be used. If the stub function(s) below are
// actually invoked they will cause the calling process to exit.
//
package devices
func getmajor(dev uint64) uint64 {
panic("getmajor() support requires cgo.")
}
func getminor(dev uint64) uint64 {
panic("getminor() support requires cgo.")
}
func makedev(major int, minor int) int {
panic("makedev() support requires cgo.")
}

View File

@@ -0,0 +1,15 @@
package devices
// from /usr/include/sys/types.h
func getmajor(dev uint32) uint64 {
return (uint64(dev) >> 24) & 0xff
}
func getminor(dev uint32) uint64 {
return uint64(dev) & 0xffffff
}
func makedev(major int, minor int) int {
return ((major << 24) | minor)
}

View File

@@ -0,0 +1,15 @@
package devices
// from /usr/include/linux/kdev_t.h
func getmajor(dev uint64) uint64 {
return dev >> 8
}
func getminor(dev uint64) uint64 {
return dev & 0xff
}
func makedev(major int, minor int) int {
return ((major << 8) | minor)
}

View File

@@ -0,0 +1,18 @@
// +build cgo
package devices
//#include <sys/mkdev.h>
import "C"
func getmajor(dev uint64) uint64 {
return uint64(C.major(C.dev_t(dev)))
}
func getminor(dev uint64) uint64 {
return uint64(C.minor(C.dev_t(dev)))
}
func makedev(major int, minor int) int {
return int(C.makedev(C.major_t(major), C.minor_t(minor)))
}

View File

@@ -0,0 +1,55 @@
// +build linux darwin freebsd solaris
package devices
import (
"fmt"
"os"
"syscall"
)
func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) {
sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return 0, 0, fmt.Errorf("cannot extract device from os.FileInfo")
}
return getmajor(sys.Rdev), getminor(sys.Rdev), nil
}
// mknod provides a shortcut for syscall.Mknod
func Mknod(p string, mode os.FileMode, maj, min int) error {
var (
m = syscallMode(mode.Perm())
dev int
)
if mode&os.ModeDevice != 0 {
dev = makedev(maj, min)
if mode&os.ModeCharDevice != 0 {
m |= syscall.S_IFCHR
} else {
m |= syscall.S_IFBLK
}
} else if mode&os.ModeNamedPipe != 0 {
m |= syscall.S_IFIFO
}
return syscall.Mknod(p, m, dev)
}
// syscallMode returns the syscall-specific mode bits from Go's portable mode bits.
func syscallMode(i os.FileMode) (o uint32) {
o |= uint32(i.Perm())
if i&os.ModeSetuid != 0 {
o |= syscall.S_ISUID
}
if i&os.ModeSetgid != 0 {
o |= syscall.S_ISGID
}
if i&os.ModeSticky != 0 {
o |= syscall.S_ISVTX
}
return
}

View File

@@ -0,0 +1,11 @@
package devices
import (
"os"
"github.com/pkg/errors"
)
func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) {
return 0, 0, errors.Wrap(ErrNotSupported, "cannot get device info on windows")
}