Communicating from a KEXT to a userland process
Communicating from a KEXT to a userland process
- Subject: Communicating from a KEXT to a userland process
- From: "Bruce Fancher" <email@hidden>
- Date: Sun, 28 May 2006 11:33:28 -0400
I'm trying to write a small Kext that uses the Kauth apis to register for
file events and then notifies a userland program to take action when files
of certain types appear. Using Kauth itself seems to be no problem. I just
followed the instructions and examples here:
http://developer.apple.com/technotes/tn2005/tn2127.html
and
http://developer.apple.com/samplecode/KauthORama/index.html
The problem I'm having is figuring out how to communicate back out from my
Kext to userland. TN2127 uses the example of an anti-virus program, which
is conceptually similar to what I'm trying to do, and specifically suggests
having the Kext pass a request to a user space daemon. However it doesn't
provide any suggestion or example wrt exactly how I might go about
communicating from the Kext to said daemon.
This document:
http://developer.apple.com/documentation/Darwin/Conceptual/KernelProgramming
/boundaries/chapter_14_section_1.html
describes a number of mechanisms for communication between the kernel and
userland, but is oriented towards calling from userland into the kernel,
which is exactly the opposite of what I'm trying to do.
Meanwhile, this document:
http://developer.apple.com/documentation/Darwin/Conceptual/NKEConceptual/con
trol/chapter_3_section_3.html
suggests using kev_message_post to send notifications from an NKE to a
userland process. However it doesn't provide any examples or documentation
for using said API, and a Google search for "kev_message_post" returns
exactly one result: the same document on Apple's web site.
I also looked at using BSD sockets, but the only documentation I could find
on opening a socket from the kernel is here:
http://developer.apple.com/documentation/Darwin/Reference/KPI_Reference/kpi_
socket/index.html
Doesn't really explain how to use the apis or fill in the structs you need
to pass in, just lists the methods and the parameters they take. I did find
one example using this api, here:
http://darwinsource.opendarwin.org/10.4.2/webdavfs-214.1/webdav_fs.kextproj/
webdav_fs.kmodproj/webdav_vnops.c
But it's pretty obscure for someone who's experience with bsd networking is
limited to bind(), listen(), accept(), read(), etc. I have no idea what a
msghdr or an iovec is, and there doesn't seem to be much in the way of
documentation or examples out there.
Oh, and I also tried looking into using Mach ports, but again I couldn't
find any examples or documentation.
So, first of all what mechanism should I be using, and second, how do I use
I use it? Any example code anyone can provide would be very welcome.
Thanks,
Bruce Fancher
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden