mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
libct: devices: drop deprecated cgroup types
These were all marked deprecated in commit a75076b4a4 ("Switch to
opencontainers/cgroups") when we switched maintenance of our cgroup code
to opencontainers/cgroups.
Users have had ample time to switch to opencontainers/cgroups
themselves, so we can finally remove this.
Note that the whole libcontainer/devices package will be moved to
moby/sys in the near future, so this whole package will be marked
deprecated soon.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -29,6 +29,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `libcontainer/configs.NewThrottleDevice`
|
||||
- `libcontainer/configs.HookList.RunHooks`. (#5141)
|
||||
- `libcontainer/configs.MPOL_*` (#5414)
|
||||
- All of the types in `libcontainer/devices` which are now maintained in
|
||||
`github.com/opencontainers/cgroups/devices/config` (#5141):
|
||||
- `libcontainer/devices.Wildcard`
|
||||
- `libcontainer/devices.WildcardDevice`
|
||||
- `libcontainer/devices.BlockDevice`
|
||||
- `libcontainer/devices.CharDevice`
|
||||
- `libcontainer/devices.FifoDevice`
|
||||
- `libcontainer/devices.Device`
|
||||
- `libcontainer/devices.Permissions`
|
||||
- `libcontainer/devices.Type`
|
||||
- `libcontainer/devices.Rule`
|
||||
|
||||
## [1.4.0] - 2025-11-27
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package devices
|
||||
|
||||
import "github.com/opencontainers/cgroups/devices/config"
|
||||
|
||||
// Deprecated: use [github.com/opencontainers/cgroups/devices/config].
|
||||
const (
|
||||
Wildcard = config.Wildcard
|
||||
WildcardDevice = config.WildcardDevice
|
||||
BlockDevice = config.BlockDevice
|
||||
CharDevice = config.CharDevice
|
||||
FifoDevice = config.FifoDevice
|
||||
)
|
||||
|
||||
// Deprecated: use [github.com/opencontainers/cgroups/devices/config].
|
||||
type (
|
||||
Device = config.Device
|
||||
Permissions = config.Permissions
|
||||
Type = config.Type
|
||||
Rule = config.Rule
|
||||
)
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/opencontainers/cgroups/devices/config"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,7 @@ var (
|
||||
// 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.
|
||||
func DeviceFromPath(path, permissions string) (*Device, error) {
|
||||
func DeviceFromPath(path, permissions string) (*config.Device, error) {
|
||||
var stat unix.Stat_t
|
||||
err := unixLstat(path, &stat)
|
||||
if err != nil {
|
||||
@@ -30,7 +31,7 @@ func DeviceFromPath(path, permissions string) (*Device, error) {
|
||||
}
|
||||
|
||||
var (
|
||||
devType Type
|
||||
devType config.Type
|
||||
mode = stat.Mode
|
||||
devNumber = uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on e.g. MIPS.
|
||||
major = unix.Major(devNumber)
|
||||
@@ -38,20 +39,20 @@ func DeviceFromPath(path, permissions string) (*Device, error) {
|
||||
)
|
||||
switch mode & unix.S_IFMT {
|
||||
case unix.S_IFBLK:
|
||||
devType = BlockDevice
|
||||
devType = config.BlockDevice
|
||||
case unix.S_IFCHR:
|
||||
devType = CharDevice
|
||||
devType = config.CharDevice
|
||||
case unix.S_IFIFO:
|
||||
devType = FifoDevice
|
||||
devType = config.FifoDevice
|
||||
default:
|
||||
return nil, ErrNotADevice
|
||||
}
|
||||
return &Device{
|
||||
Rule: Rule{
|
||||
return &config.Device{
|
||||
Rule: config.Rule{
|
||||
Type: devType,
|
||||
Major: int64(major),
|
||||
Minor: int64(minor),
|
||||
Permissions: Permissions(permissions),
|
||||
Permissions: config.Permissions(permissions),
|
||||
},
|
||||
Path: path,
|
||||
FileMode: os.FileMode(mode &^ unix.S_IFMT),
|
||||
@@ -61,18 +62,18 @@ func DeviceFromPath(path, permissions string) (*Device, error) {
|
||||
}
|
||||
|
||||
// HostDevices returns all devices that can be found under /dev directory.
|
||||
func HostDevices() ([]*Device, error) {
|
||||
func HostDevices() ([]*config.Device, error) {
|
||||
return GetDevices("/dev")
|
||||
}
|
||||
|
||||
// GetDevices recursively traverses a directory specified by path
|
||||
// and returns all devices found there.
|
||||
func GetDevices(path string) ([]*Device, error) {
|
||||
func GetDevices(path string) ([]*config.Device, error) {
|
||||
files, err := osReadDir(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out []*Device
|
||||
var out []*config.Device
|
||||
for _, f := range files {
|
||||
switch {
|
||||
case f.IsDir():
|
||||
@@ -103,7 +104,7 @@ func GetDevices(path string) ([]*Device, error) {
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if device.Type == FifoDevice {
|
||||
if device.Type == config.FifoDevice {
|
||||
continue
|
||||
}
|
||||
out = append(out, device)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/opencontainers/cgroups/devices/config"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -85,8 +86,8 @@ func TestHostDevicesAllValid(t *testing.T) {
|
||||
t.Errorf("device entry %+v has zero major number", device)
|
||||
}
|
||||
switch device.Type {
|
||||
case BlockDevice, CharDevice:
|
||||
case FifoDevice:
|
||||
case config.BlockDevice, config.CharDevice:
|
||||
case config.FifoDevice:
|
||||
t.Logf("fifo devices shouldn't show up from HostDevices")
|
||||
fallthrough
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user