Skip to content

Instantly share code, notes, and snippets.

@NSAntoine
Last active December 18, 2021 19:03
Show Gist options
  • Save NSAntoine/a79f01e71cb62044fac504f2ea68c3df to your computer and use it in GitHub Desktop.
Save NSAntoine/a79f01e71cb62044fac504f2ea68c3df to your computer and use it in GitHub Desktop.
import Foundation
/// Returns a ioctl number from a specified group and number
func getIoctlNumber(group: Character, number n:UInt) -> UInt {
let void = UInt(IOC_VOID)
let g: UInt = UInt(group.asciiValue!) << 8
return void | g | n
}
// Example:
// DKIOCEJECT (atleast for Darwin platforms) is the 21th of group d
// let DKIOCEJECT = getIoctlNumber(group: "d", number: 21)
// print("DKIOEject Ioctl Code: \(DKIOCEJECT)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment