Using IOKit with a VFS Kext

I develop a kernel extension for a network filesystem. Currently, the kernel extension is firmly rooted in the BSD layer of the kernel. All the boundary crossings and kernel calls are to the BSD layer. There are a few features that I'd like to use in IOKit. I vaguely remember hearing that mixing and matching IOKit and BSD drivers was not recommended. However, I've made a prototype kext that uses the IOKit entry points. The prototype seems to work. Since the prototype is not a device driver, I've put it in the IORegistry as an IOResource. Is registering a filesystem as an IOResource inappropriate?

Accepted Answer

I vaguely remember hearing that mixing and matching IOKit and BSD drivers was not recommended.

I wouldn’t say “not recommended”, rather I’d say “tricky”. When your KEXT spans multiple kernel environments you have to be careful to follow the rules of each environment. Back in the day that was particularly tricky because the BSD side of the world was controlled by giant man-eating locks (the kernel funnels). That problem is long gone but various other issues remain. You still have two threading models, two memory management models, two locking models, and so on, and you have to follow the rules of both.

Having said that, there are plenty of kernel components that do that—the most obvious example in this context being IOMediaBSDClient—so it’s fine to do as long as your careful.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Alright, that's good news. I can dive into it in earnest now. Thanks!

Using IOKit with a VFS Kext
 
 
Q