Re: Open file descriptor within a kext
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com User-agent: KMail/1.9.5
While you may open, read and close files inside a kext, there are no KPI for dealing with file descriptors. You should try to design a way to read the data inside the kext, and pass it to the userspace process instead of passing a file descriptor.
This idea sounds great, I think reading the data and passing it to userspace is indeed the best (and probably the only sane) solution.
Look into vnode_open/vnode_close, and then uio_create, uio_addiov and VNOP_READ for reading the data. Don't forget uio_free. vnode_open should handle any path issues for you. Be prepared to be blocked in any of these functions.
You might want to know the size of a file. Use this kind of code to do that:
struct vnode_attr ap;
VATTR_INIT(&ap); VATTR_WANTED(&ap, va_data_size ); VATTR_WANTED(&ap, va_total_size ); int res = vnode_getattr(vp, &ap, context);
For other vnode_* see the vnode.h header.
Paul Nelson
Thank you very much for these hints! I didnt know that it is possible to read files from within a kext. This is exactly what i was looking for. Thx and best regards, Luciano _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Luciano