BIOs are for BLOCK devices we want sth. like this for CHARACTER
devices.
I just want sth. along the lines of this:
/* Pin down (COMPLETE!) user pages and put them into a scatter gather list */
int sg_map_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
unsigned long uaddr, int rw) {
int res, i;
struct page *pages[nr_pages];
down_read(¤t->mm->mmap_sem);
res = get_user_pages(
current,
current->mm,
uaddr,
nr_pages,
rw == READ, /* logic is perversed^Wreversed here :-( */
0, /* don't force */
&pages[0],
NULL);
up_read(¤t->mm->mmap_sem);
/* Errors and no page mapped should return here */
if (res <= 0) return res;
for (i=1; i < res; i++) {
sgl[i].page = pages[i];
}
return res;
}
/* And unmap them... */
int sg_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages) {
int i;
for (i=0; i < nr_pages; i++)
page_cache_release(sgl[i].page);
return 0;
}
Possibly more complicated and less error prone, but you get the
idea ;-)
Regards
Ingo Oeser
-- Science is what we can tell a computer. Art is everything else. --- D.E.Knuth - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/