Skip to content

Commit db0a0da

Browse files
committed
Add getAccessString function to DeviceNode type
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 651c13c commit db0a0da

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

pkg/cdi/container-edits.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,19 +374,21 @@ func (d *DeviceNode) addToGenerator(specgen *ocigen.Generator, spec *oci.Spec) e
374374
specgen.AddDevice(dev)
375375

376376
if dev.Type == "b" || dev.Type == "c" {
377-
access := d.Permissions
378-
switch access {
379-
case "":
380-
access = "rwm"
381-
case NoPermissions:
382-
access = ""
383-
}
384-
specgen.AddLinuxResourcesDevice(true, dev.Type, &dev.Major, &dev.Minor, access)
377+
specgen.AddLinuxResourcesDevice(true, dev.Type, &dev.Major, &dev.Minor, d.getAccessString())
385378
}
386379
return nil
387380
}
388381

382+
func (d *DeviceNode) getAccessString() string {
383+
switch d.Permissions {
384+
case "":
385+
return "rwm"
386+
case NoPermissions:
387+
return ""
388+
default:
389+
return d.Permissions
389390
}
391+
}
390392
return nil
391393
}
392394
// Hook is a CDI Spec Hook wrapper, used for validating hooks.

0 commit comments

Comments
 (0)