Re: Having problem with mmap system call!!!

From: Richard B. Johnson
Date: Thu Sep 16 2004 - 09:58:04 EST


On Thu, 16 Sep 2004, Alan Cox wrote:

> On Iau, 2004-09-16 at 15:07, Richard B. Johnson wrote:
> > if((vp = mmap((caddr_t) HINT, len, PROT, FLAGS, fd, addr)) == SHM_FAIL)
> > {
> > fprintf(stderr, "Can't access shared memory\n");
> > exit(EXIT_FAILURE);
>
> SHM_FAIL is the wrong error check btw.
>

MAP_FAILED only appeared in real late 'C' runtime library headers.
That's why the code defines SHM_FAIL, which is also correct, but
doesn't cause a redefinition error.

> It is much better to do this in the driver than do nasty user mode hacks
> using /dev/mem. When you do it kernel driver side you end up with a
> cleaner mmap interface, a sensible permissions model and the hardware
> device pages mapped directly and nicely into the app
>

Well that's really nice. Now, how do you do that? The kernel DS
is not the user DS so you end up with a kernel hack instead of
a user hack?

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/