A Hare code generator for finding ioctl numbers

4 · Drew DeVault · May 14, 2022, 1:46 p.m.
Modern Unix derivatives have this really bad idea called ioctl. It’s a function which performs arbitrary operations on a file descriptor. It is essentially the kitchen sink of modern Unix derivatives, particularly Linux, in which they act almost like a second set of extra syscalls. For example, to get the size of the terminal window, you use an ioctl specific to TTY file descriptors: let wsz = rt::winsize { ... }; match (rt::ioctl(fd, rt::TIOCGWINSZ, &wsz: *void)) { case let e: rt::errno => swi...