Merge pull request #9858 from w13915984028/fixdebug
Add file name to device type check failure message
This commit is contained in:
commit
2ddd3db952
@ -30,6 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ErrNotADevice denotes that a file is not a valid linux device.
|
// ErrNotADevice denotes that a file is not a valid linux device.
|
||||||
|
// When checking this error, use errors.Is(err, oci.ErrNotADevice)
|
||||||
var ErrNotADevice = errors.New("not a device node")
|
var ErrNotADevice = errors.New("not a device node")
|
||||||
|
|
||||||
// Testing dependencies
|
// Testing dependencies
|
||||||
@ -53,6 +54,10 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
|
|||||||
if !stat.IsDir() {
|
if !stat.IsDir() {
|
||||||
dev, err := DeviceFromPath(path)
|
dev, err := DeviceFromPath(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// wrap error with detailed path and container path when it is ErrNotADevice
|
||||||
|
if err == ErrNotADevice {
|
||||||
|
return nil, fmt.Errorf("get device path: %q containerPath: %q error: %w", path, containerPath, err)
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if containerPath != "" {
|
if containerPath != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user