Merge pull request #9858 from w13915984028/fixdebug

Add file name to device type check failure message
This commit is contained in:
Kazuyoshi Kato 2024-07-26 21:20:38 +00:00 committed by GitHub
commit 2ddd3db952
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 != "" {