Add SupportedIoctls() to nvproxy.

This allows callers to get all the ioctl/command/class numbers that nvproxy
supports.

PiperOrigin-RevId: 599298654
This commit is contained in:
Ayush Ranjan
2024-01-17 14:59:53 -08:00
committed by gVisor bot
parent 4596265605
commit 1ae5fca498
+27
View File
@@ -377,3 +377,30 @@ func ExpectedDriverChecksum(version DriverVersion) (string, bool) {
}
return abi.checksum, true
}
// SupportedIoctls returns the ioctl numbers that are supported by nvproxy at
// a given version.
func SupportedIoctls(version DriverVersion) (frontendIoctls map[uint32]struct{}, uvmIoctls map[uint32]struct{}, controlCmds map[uint32]struct{}, allocClasses map[uint32]struct{}, ok bool) {
abiCons, ok := abis[version]
if !ok {
return nil, nil, nil, nil, false
}
abi := abiCons.cons()
frontendIoctls = make(map[uint32]struct{})
for ioc := range abi.frontendIoctl {
frontendIoctls[ioc] = struct{}{}
}
uvmIoctls = make(map[uint32]struct{})
for ioc := range abi.uvmIoctl {
uvmIoctls[ioc] = struct{}{}
}
controlCmds = make(map[uint32]struct{})
for cmd := range abi.controlCmd {
controlCmds[cmd] = struct{}{}
}
allocClasses = make(map[uint32]struct{})
for class := range abi.allocationClass {
allocClasses[class] = struct{}{}
}
return
}