Newsgroups: comp.sys.mips
Path: utzoo!utgpu!watserv1!watdragon!daisy.waterloo.edu!drclark
From: drclark@daisy.waterloo.edu (David R. Clark)
Subject: mmap
Message-ID: <1991Jun3.151307.20857@watdragon.waterloo.edu>
Sender: news@watdragon.waterloo.edu (News Owner)
Organization: University of Waterloo
Distribution: na
Date: Mon, 3 Jun 1991 15:13:07 GMT
Lines: 24

The following program (actually a slight variation of it) works on one of
our local systems (Sequent).  On an M2000 running 4.51 the call to mmap fails
(invalid arguments).  Any ideas?  What I really want to do is choose an arbitrary
region of memory that does not overlap the current program or data space and then
map data into the region.  Until I get the simple version working though, I am stuck.

#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
main() {

	int f;
	int t;
	char *s;

	f = open("AND",O_RDWR,0);

	if (f == -1) perror("open");

	s = malloc(getpagesize());
	if (mmap(s,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,f,0) == -1)
		perror("mmap");
	printf("%s",s);
}
