Skip to contentSkip to conversation

About mmap

DISCUSSION Sebastien Morand 1 participant 1 message Oct 31, 2002

lore
Share & tools
lore
#0 lore raw

I'm implementing a cache for a database file system. Using mmap I would like to know how mmap works.

For instance if my file is open in read/write and I'm mapping in read/write but I use only the block in write, is the kernel going to read on the disk?

Here is a sample code:
int h = open(file, O_RDWR | O_SYNC);
void * memory =
mmap(0, pageSize, PROT_WRITE | PROT_READ, MAP_SHARED, handle, 0);

I'm actually using the same code to get read or write block, so if I'm using the block in write only I would like to know if this code is correct or if I'd better change the flags according to writing or reading access.

Sincerely,
Sebastien Morand.

NB: I'm not on the mailing list, can you put my e-mail in CC to reply please.