Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
write to file from kext
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="dr_springfield" data-source="post: 47625"><p><strong>kernel programming</strong></p><p></p><p>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).</p><p></p><p>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.</p><p></p><p>dr_springfield</p><p></p><p></p><p>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:</p><p></p><p>char pathBuf[]="/my_dir";</p><p>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);</p><p>printf("namei returns %u\n",error);</p></blockquote><p></p>
[QUOTE="dr_springfield, post: 47625"] [b]kernel programming[/b] 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); [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
write to file from kext
Top