On 02.04.2020 02:56, Mouse wrote: >> $ ioctldecode 2148554498 >> _IOW('W',0x2,0x10) > >> $ ioctlname 2148554498 >> WSKBDIO_COMPLEXBELL > > Where would you get the mapping between the ioctl value and the name? > Would this be just a huge switch statement (or compiled-in table), or > would it search /usr/include/sys at runtime, or what? > > In particular, would any special action need to be taken upon adding a > new ioctl for it to be recognized? >
Everything is already done in kdump and reused in other tools like ktruss. Please check: src/usr.bin/kdump/Makefile.ioctl-c. > What about collisions, two ioctls having the same numeric value? (I'm > not aware of any offhand, but I'd be astonished if it never happened.) > There are some collisions, but not that many of them. In these cases we try to pick the more interesting device. In sanitizers there are around 2000 individual ioctls and 51 collisions. Some of them are gone as we remove old unmaintained device drivers.