6 ms·
Writing a NetBSD Kernel Module
- userbinator 5y agoas that would end up copying the \0 along with the rest of the string into the driver What? echo definitely doesn't append null terminators. It does append a newline, which you can omit with the -n option or ending the string with \c, depending on which standard it follows.
- jmmv 5y agoThis reminded me of https://mveg.es/posts/writing-a-device-driver-for-unix-v6/ https://mveg.es/posts/writing-a-device-driver-for-unix-v6/, which was recently discussed here under https://news.ycombinator.com/item?id=30679923 https://news.ycombinator.com/item?id=30679923 Also... have you considered contributing this content to the NetBSD Internals book? https://www.netbsd.org/docs/internals/en/netbsd-internals.html https://www.netbsd.org/docs/internals/en/netbsd-internals.ht... :)
- jayp1418 5y agoCool. Thanks for links
- ggm 5y ago... as long as you don't want to do fancy IOCTL() work. basically, its the jump table model from 1980s with a few extra twists like templating. "here, steal this mknod number" is dangerous. It pays to check nothing else is using that value. Thats what registries are for in the end.
- trasz 5y agoThat's why FreeBSD doesn't use mknod(8) - or device numbers - at all. You can kind of work around this obsolete idea instead - that's what Linux is doing - but it's not optimal.
- yjftsjthsd-h 5y agoWait, how can you do it without any device numbers? Are they binding drivers directly to file names?
- trasz 5y agoPrecisely. That's one of the reasons devfs isn't optional in FreeBSD. (Note that FreeBSD devfs is very different from the one that's been there in Linux years ago, and doesn't have its deficiencies.)
- kingabc 5y ago[flagged]
- dgan 5y agoWhy would one want to write a module instead of using a library to achieve the same?