@@ -38,6 +38,26 @@ func deviceCgroup(d *devices.Device) specs.LinuxDeviceCgroup {
38
38
func DevicesFromPath (pathOnHost , pathInContainer , cgroupPermissions string ) (devs []specs.LinuxDevice , devPermissions []specs.LinuxDeviceCgroup , err error ) {
39
39
resolvedPathOnHost := pathOnHost
40
40
41
+ // Only wildcard * is supported
42
+ if strings .HasSuffix (resolvedPathOnHost , "*" ) {
43
+ devicePaths , _ := filepath .Glob (resolvedPathOnHost )
44
+ var err error
45
+ var dev * devices.Device
46
+ for _ , devicePath := range devicePaths {
47
+ dev , err = devices .DeviceFromPath (devicePath , cgroupPermissions )
48
+ if err != nil {
49
+ return nil , nil , fmt .Errorf ("no device %q %s" , devicePath , err )
50
+ }
51
+ devs = append (devs , Device (dev ))
52
+ devPermissions = append (devPermissions , deviceCgroup (dev ))
53
+ }
54
+ if len (devs ) > 0 {
55
+ return devs , devPermissions , nil
56
+ } else {
57
+ return devs , devPermissions , fmt .Errorf ("error gathering device information while adding custom device %q: %s" , pathOnHost , err )
58
+ }
59
+ }
60
+
41
61
// check if it is a symbolic link
42
62
if src , e := os .Lstat (pathOnHost ); e == nil && src .Mode ()& os .ModeSymlink == os .ModeSymlink {
43
63
if linkedPathOnHost , e := filepath .EvalSymlinks (pathOnHost ); e == nil {
0 commit comments