mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
Merge pull request #26022 from giuseppe/test-do-not-set-limits-on-dev-zero
test: use block devices for I/O limit tests
This commit is contained in:
@ -33,7 +33,8 @@ func GetContainerPidInformationDescriptors() ([]string, error) {
|
||||
// [major:minor] is the device's major and minor numbers formatted as, for
|
||||
// example, 2:0 and path is the path to the device node.
|
||||
// Symlinks to nodes are ignored.
|
||||
func FindDeviceNodes() (map[string]string, error) {
|
||||
// If onlyBlockDevices is specified, character devices are ignored.
|
||||
func FindDeviceNodes(onlyBlockDevices bool) (map[string]string, error) {
|
||||
nodes := make(map[string]string)
|
||||
err := filepath.WalkDir("/dev", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
@ -44,7 +45,13 @@ func FindDeviceNodes() (map[string]string, error) {
|
||||
}
|
||||
|
||||
// If we aren't a device node, do nothing.
|
||||
if d.Type()&(os.ModeDevice|os.ModeCharDevice) == 0 {
|
||||
if d.Type()&os.ModeDevice == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ignore character devices, because it is not possible to set limits on them.
|
||||
// os.ModeCharDevice is usable only when os.ModeDevice is set.
|
||||
if onlyBlockDevices && d.Type()&os.ModeCharDevice != 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,6 @@ package util
|
||||
import "errors"
|
||||
|
||||
// FindDeviceNodes is not implemented anywhere except Linux.
|
||||
func FindDeviceNodes() (map[string]string, error) {
|
||||
func FindDeviceNodes(onlyBlockDevices bool) (map[string]string, error) {
|
||||
return nil, errors.New("not supported on non-Linux OSes")
|
||||
}
|
||||
|
Reference in New Issue
Block a user