DEVCTL(4)
π DEVCTL(4) π
okay bestie, so this one lives in the Kernel Interfaces Manual β it's DEVCTL(4), the device event reporting and device control interface. buckle up π
β¨ NAME β¨
devctl β device event reporting and device control interface π¦
πΈ DESCRIPTION πΈ
so the devctl device is what the kernel uses to report device events. that's its whole job rn. and likeβ¦ future versions will allow for some device control too, but that part isn't here yet. it's giving "coming soon" energy β¨
π IMPLEMENTATION NOTES π
okay so this design only allows one reader for /dev/devctl. literally one. and yeah, that's not desirable in the long run, but it will get a lot of hair out of this implementation, so. maybe we should make this device a clonable device?? just a thought π
also note: we specifically do not attach a device to the device_t tree, to avoid potential chicken and egg problems. one could argue that all of this belongs to the root node. one could also further argue that the sysctl(3) interface that we have now might more properly be an ioctl(2) interface. we're just saying things, fr fr π
SIGIO support is included in the driver. however β and this is the tea β the author is not sure that the SIGIO support is done correctly. it was copied from a driver that had SIGIO support that likely has not been tested since FreeBSD 3.4 or FreeBSD 2.2.8! ππ
the read channel for this device is used to report changes to userland in realtime. we return one record at a time. and listen β if you try to read this device a character at a time, you will lose the rest of the data. listening programs are expected to cope. no cap, that's on you π«Ά
the sysctl hw.bus.devctl_queue can be used to control queue length. it is set to 0 to disable devctl when no devd(8) is running.
π PROTOCOL π
the devctl device uses an ASCII protocol. the driver returns one record at a time to its readers. each record is terminated with a newline. the first character of the record is the event type. slay, simple β¨
!β a notify event, such as a link state change. π+β device node in tree attached.-β device node in tree detached.?β unknown device detected.
π Message Formats π
except for the first character in the record, attach and detach messages have the same format. iconic, honestly:
Tdev at parent on location
here's what every piece means:
Tβ+or-devβ the device name that was attached/detached.parentβ the device name of the parent bus that attached the device.locationβ bus specific location information.
the nomatch messages can be used to load devices driver. so if you load a device driver, then one of two things can happen. if the device driver attaches to something, you will get a device attached message. if it does not, then nothing will happen. that's it. that's the whole thing π€·
β οΈ okay important: the attach and detach messages arrive after the event. which means you cannot use the attach message to load an alternate driver β the attach message driver has already claimed this device. and you cannot use the detach messages to flush data to the device either β the device is already gone. bye bestie π
π¦ SEE ALSO π¦
and that's the whole page, bestie!! this one's from the Debian crew, dated March 26, 2014 β so like, vintage but still serving π mwah, go read it again if you forgot something, ily π«Άπβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2002 M. Warner Losh
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms