Re: Open file descriptor within a kext
Re: Open file descriptor within a kext
- Subject: Re: Open file descriptor within a kext
- From: Luciano <email@hidden>
- Date: Mon, 26 Apr 2010 10:56:56 +0200
> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden