Re: Sharing a file through mmap

From: Måns Rullgård (
Date: 05/14/05

Date: Sat, 14 May 2005 19:54:21 +0200

"Peter Nolan" <> writes:

> Hi,
> I am new to mmap on unix....I have written some ETL software and
> introduced memory mapped IO for my win2000+ version..I am now trying to
> introduce memory mapped IO for my unix version.....
> I have written code that will (I hope) load the data I want into memory
> mapped IO...however, when writing the code to gain access to the map I
> have a question....I have the statement below...
> IF ((ptr_MemMapBuffer = (char *) mmap((caddr_t) 0, 0 ,
> // some error and return
> END_

What language is that?

> At this point in this program I do not know the size of the file
> pointed to by fp_MemMapBuffer. In the win2000 equivalent call when you
> ask for the mapping to be made if you specify 0 as a length it will
> allow the program access to the entire file in memory. I've searched
> in the documentation but I cannot see if mmap defaults to allowing
> access to the entire file or if I need to run some function to find the
> size of the entire file before I call mmap.....And if I do, does anyone
> know the function to call against a file pointer opened with the 'open'
> statement to get the size in bytes of the file?


Måns Rullgård