Re: Sharing a file through mmap
From: Måns Rullgård (mru_at_inprovide.com)
Date: Sat, 14 May 2005 19:54:21 +0200
"Peter Nolan" <firstname.lastname@example.org> writes:
> 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 ,
> (PROT_READ|PROT_WRITE), MAP_SHARED, fp_MemMapBuffer, 0)) == MAP_FAILED)
> // some error and return
> CALL_RETURNED_OK = False ;
> return CALL_RETURNED_OK ;
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 email@example.com