Files
runc/libcontainer/devices/device_deprecated_unix.go
T
Sebastiaan van Stijn ba83c7c7d7 libcontainer/devices: add '//go:fix inline' directives
This allows users to automaticaly migrate to the new location
using `go fix`. It has some limitations, but can help smoothen
the transition; for example, taking this file;

```
package main

import (
	"github.com/opencontainers/runc/libcontainer/devices"
)

func main() {
	_, _ = devices.DeviceFromPath("a", "b")
	_, _ = devices.HostDevices()
	_, _ = devices.GetDevices("a")
}
```

Running `go fix -mod=readonly ./...` will migrate the code;

```
package main

import (
	devices0 "github.com/moby/sys/devices"
)

func main() {
	_, _ = devices0.DeviceFromPath("a", "b")
	_, _ = devices0.HostDevices()
	_, _ = devices0.GetDevices("a")
}
```

updates b345c78dca

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-04-04 19:36:43 +02:00

56 lines
1.7 KiB
Go

//go:build !windows
// Package devices provides some helper functions for constructing device
// configurations for runc. These are exclusively used by higher-level runtimes
// that need to configure runc's device list based on existing devices.
//
// Deprecated: Use github.com/moby/sys/devices instead. This package will be
// removed in runc 1.6.
package devices
import (
"github.com/moby/sys/devices"
"github.com/opencontainers/cgroups/devices/config"
)
// ErrNotADevice denotes that a file is not a valid linux device.
//
// Deprecated: Use [devices.ErrNotADevice] instead. This package will be
// removed in runc 1.6.
//
//go:fix inline
var ErrNotADevice = devices.ErrNotADevice
// DeviceFromPath takes the path to a device and its cgroup_permissions (which
// cannot be easily queried) to look up the information about a linux device
// and returns that information as a Device struct.
//
// Deprecated: Use [devices.DeviceFromPath] instead. This package will be
// removed in runc 1.6.
//
//go:fix inline
func DeviceFromPath(path, permissions string) (*config.Device, error) {
return devices.DeviceFromPath(path, permissions)
}
// HostDevices returns all devices that can be found under /dev directory.
//
// Deprecated: Use [devices.HostDevices] instead. This package will be
// removed in runc 1.6.
//
//go:fix inline
func HostDevices() ([]*config.Device, error) {
return devices.HostDevices()
}
// GetDevices recursively traverses a directory specified by path
// and returns all devices found there.
//
// Deprecated: Use [devices.GetDevices] instead. This package will be
// removed in runc 1.6.
//
//go:fix inline
func GetDevices(path string) ([]*config.Device, error) {
return devices.GetDevices(path)
}