Skip to content

Commit

Permalink
Merge pull request containerd#9858 from w13915984028/fixdebug
Browse files Browse the repository at this point in the history
Add file name to device type check failure message
  • Loading branch information
kzys authored Jul 26, 2024
2 parents 7a1f6b2 + 98544a3 commit 2ddd3db
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/oci/utils_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

// 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")

// Testing dependencies
Expand All @@ -53,6 +54,10 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
if !stat.IsDir() {
dev, err := DeviceFromPath(path)
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
}
if containerPath != "" {
Expand Down

0 comments on commit 2ddd3db

Please sign in to comment.