mmap, /dev/zero, and MAP_SHARED

ncherry@home.net
Fri, 26 Nov 1999 14:07:27 -0500


Has anyone been able to get the mmap example from Stevens APUE to work
under Linux? I've used search engines but found nothing of use. Here is
the code snippet:

if ((fd = open("/dev/zero", O_RDWR)) == -1) {
perror("open of /dev/zero failed");
exit(EXIT_FAILURE);
}
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?

-- 
Linux Home Automation           Neil Cherry             ncherry@home.net
http://members.home.net/ncherry                         (Text only)
http://meltingpot.fortunecity.com/lightsey/52           (Graphics GB)

- 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/