Skip to content

Commit 6065d8c

Browse files
w13915984028dbro86
authored andcommitted
Add file name to device type check failure message
Signed-off-by: Jian Wang <[email protected]>
1 parent 85aaa1a commit 6065d8c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/oci/utils_unix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
)
3131

3232
// ErrNotADevice denotes that a file is not a valid linux device.
33+
// When checking this error, use errors.Is(err, oci.ErrNotADevice)
3334
var ErrNotADevice = errors.New("not a device node")
3435

3536
// Testing dependencies
@@ -53,6 +54,10 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
5354
if !stat.IsDir() {
5455
dev, err := DeviceFromPath(path)
5556
if err != nil {
57+
// wrap error with detailed path and container path when it is ErrNotADevice
58+
if err == ErrNotADevice {
59+
return nil, fmt.Errorf("get device path: %q containerPath: %q error: %w", path, containerPath, err)
60+
}
5661
return nil, err
5762
}
5863
if containerPath != "" {

0 commit comments

Comments
 (0)