write to file from kext

D

dr_springfield

Guest
kernel programming

Trying to get my kext to write to a file... does anyone know how to do this? I've discovered I can only use the headers in the Kernel framework, and sys/fcntl.h should be able to open up a file at least, but I can't seem to get it to be recognized by the compiler (I include it and I get an error that open is undeclared, as well as write and close).

This should be entirely possible (but I don't know). I know I can write to the syslog with printf, but this isn't the desired behavior. Thanks for any help.

dr_springfield


Edit: well, problem not really solved. If anyone know what's wrong with this, please let me know, because it causes kernel panics and I can't figure it out:

char pathBuf[]="/my_dir";
struct nameidata *ndp=(struct nameidata*)_MALLOC(sizeof(struct nameidata),M_FREE,M_WAITOK); NDINIT(ndp,CREATE,LOCKLEAF,UIO_USERSPACE,pathBuf,current_proc());error = namei(ndp);
printf("namei returns %u\n",error);
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top