vendor: github.com/cncf-tags/container-device-interface v0.6.1
Removes uses of the github.com/opencontainers/runc/libcontainer/devices package. full diff: https://github.com/cncf-tags/container-device-interface/compare/v0.6.0...v0.6.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
0434b653c8
commit
c44f8958f6
5 changed files with 45 additions and 14 deletions
|
@ -24,7 +24,7 @@ require (
|
|||
github.com/aws/smithy-go v1.13.5
|
||||
github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8
|
||||
github.com/cloudflare/cfssl v1.6.4
|
||||
github.com/container-orchestrated-devices/container-device-interface v0.6.0
|
||||
github.com/container-orchestrated-devices/container-device-interface v0.6.1
|
||||
github.com/containerd/cgroups/v3 v3.0.2
|
||||
github.com/containerd/containerd v1.6.22
|
||||
github.com/containerd/continuity v0.4.1
|
||||
|
|
|
@ -311,8 +311,8 @@ github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOi
|
|||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
|
||||
github.com/container-orchestrated-devices/container-device-interface v0.6.0 h1:aWwcz/Ep0Fd7ZuBjQGjU/jdPloM7ydhMW13h85jZNvk=
|
||||
github.com/container-orchestrated-devices/container-device-interface v0.6.0/go.mod h1:OQlgtJtDrOxSQ1BWODC8OZK1tzi9W69wek+Jy17ndzo=
|
||||
github.com/container-orchestrated-devices/container-device-interface v0.6.1 h1:mz77uJoP8im/4Zins+mPqt677ZMaflhoGaYrRAl5jvA=
|
||||
github.com/container-orchestrated-devices/container-device-interface v0.6.1/go.mod h1:40T6oW59rFrL/ksiSs7q45GzjGlbvxnA4xaK6cyq+kA=
|
||||
github.com/container-storage-interface/spec v1.5.0 h1:lvKxe3uLgqQeVQcrnL2CPQKISoKjTJxojEs9cBk+HXo=
|
||||
github.com/container-storage-interface/spec v1.5.0/go.mod h1:8K96oQNkJ7pFcC2R9Z1ynGGBB1I93kcS6PGg3SsOk8s=
|
||||
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
|
||||
|
|
|
@ -49,7 +49,7 @@ type Cache struct {
|
|||
}
|
||||
|
||||
// WithAutoRefresh returns an option to control automatic Cache refresh.
|
||||
// By default auto-refresh is enabled, the list of Spec directories are
|
||||
// By default, auto-refresh is enabled, the list of Spec directories are
|
||||
// monitored and the Cache is automatically refreshed whenever a change
|
||||
// is detected. This option can be used to disable this behavior when a
|
||||
// manually refreshed mode is preferable.
|
||||
|
@ -203,7 +203,7 @@ func (c *Cache) refresh() error {
|
|||
// RefreshIfRequired triggers a refresh if necessary.
|
||||
func (c *Cache) refreshIfRequired(force bool) (bool, error) {
|
||||
// We need to refresh if
|
||||
// - it's forced by an explicitly call to Refresh() in manual mode
|
||||
// - it's forced by an explicit call to Refresh() in manual mode
|
||||
// - a missing Spec dir appears (added to watch) in auto-refresh mode
|
||||
if force || (c.autoRefresh && c.watch.update(c.dirErrors)) {
|
||||
return true, c.refresh()
|
||||
|
@ -244,7 +244,7 @@ func (c *Cache) InjectDevices(ociSpec *oci.Spec, devices ...string) ([]string, e
|
|||
|
||||
if unresolved != nil {
|
||||
return unresolved, fmt.Errorf("unresolvable CDI devices %s",
|
||||
strings.Join(devices, ", "))
|
||||
strings.Join(unresolved, ", "))
|
||||
}
|
||||
|
||||
if err := edits.Apply(ociSpec); err != nil {
|
||||
|
|
|
@ -20,11 +20,42 @@
|
|||
package cdi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
runc "github.com/opencontainers/runc/libcontainer/devices"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
blockDevice = "b"
|
||||
charDevice = "c" // or "u"
|
||||
fifoDevice = "p"
|
||||
)
|
||||
|
||||
// deviceInfoFromPath takes the path to a device and returns its type,
|
||||
// major and minor device numbers.
|
||||
//
|
||||
// It was adapted from https://github.com/opencontainers/runc/blob/v1.1.9/libcontainer/devices/device_unix.go#L30-L69
|
||||
func deviceInfoFromPath(path string) (devType string, major, minor int64, _ error) {
|
||||
var stat unix.Stat_t
|
||||
err := unix.Lstat(path, &stat)
|
||||
if err != nil {
|
||||
return "", 0, 0, err
|
||||
}
|
||||
switch stat.Mode & unix.S_IFMT {
|
||||
case unix.S_IFBLK:
|
||||
devType = blockDevice
|
||||
case unix.S_IFCHR:
|
||||
devType = charDevice
|
||||
case unix.S_IFIFO:
|
||||
devType = fifoDevice
|
||||
default:
|
||||
return "", 0, 0, errors.New("not a device node")
|
||||
}
|
||||
devNumber := uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on e.g. MIPS.
|
||||
return devType, int64(unix.Major(devNumber)), int64(unix.Minor(devNumber)), nil
|
||||
}
|
||||
|
||||
// fillMissingInfo fills in missing mandatory attributes from the host device.
|
||||
func (d *DeviceNode) fillMissingInfo() error {
|
||||
if d.HostPath == "" {
|
||||
|
@ -35,22 +66,22 @@ func (d *DeviceNode) fillMissingInfo() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
hostDev, err := runc.DeviceFromPath(d.HostPath, "rwm")
|
||||
deviceType, major, minor, err := deviceInfoFromPath(d.HostPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to stat CDI host device %q: %w", d.HostPath, err)
|
||||
}
|
||||
|
||||
if d.Type == "" {
|
||||
d.Type = string(hostDev.Type)
|
||||
d.Type = deviceType
|
||||
} else {
|
||||
if d.Type != string(hostDev.Type) {
|
||||
if d.Type != deviceType {
|
||||
return fmt.Errorf("CDI device (%q, %q), host type mismatch (%s, %s)",
|
||||
d.Path, d.HostPath, d.Type, string(hostDev.Type))
|
||||
d.Path, d.HostPath, d.Type, deviceType)
|
||||
}
|
||||
}
|
||||
if d.Major == 0 && d.Type != "p" {
|
||||
d.Major = hostDev.Major
|
||||
d.Minor = hostDev.Minor
|
||||
d.Major = major
|
||||
d.Minor = minor
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -212,7 +212,7 @@ github.com/cloudflare/cfssl/log
|
|||
github.com/cloudflare/cfssl/ocsp/config
|
||||
github.com/cloudflare/cfssl/signer
|
||||
github.com/cloudflare/cfssl/signer/local
|
||||
# github.com/container-orchestrated-devices/container-device-interface v0.6.0
|
||||
# github.com/container-orchestrated-devices/container-device-interface v0.6.1
|
||||
## explicit; go 1.17
|
||||
github.com/container-orchestrated-devices/container-device-interface/internal/multierror
|
||||
github.com/container-orchestrated-devices/container-device-interface/internal/validation
|
||||
|
|
Loading…
Add table
Reference in a new issue