Mapping user buffers to kernel space
Mapping user buffers to kernel space
- Subject: Mapping user buffers to kernel space
- From: Ken Hornstein <email@hidden>
- Date: Fri, 23 Apr 2010 10:03:06 -0400
(I'm not sure if this should be on filesystem-dev or here; I'm sticking with
this list for now).
I'm porting a network filesystem to MacOS X. Right now when I get
VNOP_READ()/VNOP_WRITE() calls to my filesystem, I copy the network data
using uiomove() into a kernel buffer I allocate, then I send the data
out over the network via sock_* (reverse that order for reads ... you
know what I mean).
I am wondering if it is possible to avoid that copy from userspace to
kernel. The socket I/O functions take struct iov[] which have pointers
to kernel address space, so I can't just give it the uio structure I
get as part of the VNOP_READ/VNOP_WRITE arguments. And I haven't yet
found a function which maps an arbitrary userspace address into kernel
address space. If the answer is "you can't", then that's fine (but
unfortunate); I'm just trying to make sure I'm not missing something.
To answer some obvious questions:
- Yes, I should be using the buffer cache. Pretend that I'm just caring
about the DIRECT_IO case right now.
- I know about the IOMemoryDescriptor calls, but from what I can see the
way they work is that you have to allocate the buffer using them and
then give that buffer to userspace. I don't see how to use
IOMemoryDescriptor on a struct uio.
--Ken
_______________________________________________
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