lkml.org 
[lkml]   [1999]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: mmap, /dev/zero, and MAP_SHARED
ncherry@home.net wrote:
> a = mmap (0, 8192, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FILE, fd, 0);
>
> a always returns as -1 and errno is 22 (EINVAL). I've changed all the
> EINVAL's to EINVAL+n (n is a constant not a variable) I've replaced n by
> 1 - 22 in the mm directory and the above code still returns -1/EINVAL.
>
> Why?

Because shared anonymous mappings (MAP_ANON could be used instead of
/dev/zero) are not implemented.

Use MAP_PRIVATE instead of MAP_SHARED and it succeeds of course, but
probably doesn't do what you want.

You best solutions are to use a temporary file instead of /dev/zero
(unlink it straight after opening if you like), or use shared memory
(shmget et al.).

-- Jamie

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

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.024 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site