problem appending data to Memory mapped File in Unix 
Author Message
 problem appending data to Memory mapped File in Unix

Hi

I have  memory  mapped a file using
mmap() and if i write something in the file i can see the changes
but if itry to write at the end of the file i can't see the changes.

The program goes this way.

int fd = open(filename, O_RDWR);
struct stat sbuf;

stat(filename, &sbuf);

char * data = mmap((caddr_t)0,  sbuf.st_size, PROT_READ|PROT_WRITE,
MAP_SHARED,
         fd, 0);

Everything goes fine like i can write  within sbuf.st_size, but
if i do something like this

for(int i = sbuf.st_size; i < sbuf.st_size + 100 ; i++) data[i] = 'p';
msync((void *)data,  sbuf.st_size + 100 );

I can't see any changes in the file, i mean on the disk.

Any help will be appreciated.

rgds

minnam



Sat, 13 Jan 2001 03:00:00 GMT  
 problem appending data to Memory mapped File in Unix


Quote:
>Hi

>I have  memory  mapped a file using
>mmap() and if i write something in the file i can see the changes
>but if itry to write at the end of the file i can't see the changes.

The C language doesn't define any function called mmap(). If you are
referring to the function commonly provided on Unix platforms the appropriate
place to discuss this would be comp.unix.programmer.

--
-----------------------------------------


-----------------------------------------



Sat, 13 Jan 2001 03:00:00 GMT  
 problem appending data to Memory mapped File in Unix

Quote:

> I have  memory  mapped a file using
> mmap() and if i write something in the file i can see the changes
> but if itry to write at the end of the file i can't see the changes.

Hi Srikanth Minnam,

Your problem is very Unix specific and quite outside the bounds of
the standard C language. You might want to ask the Unix programming
experts for advice on Unix specific topics:

Stephan
(initiator of the campaign against grumpiness in c.l.c)



Sat, 13 Jan 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Memory-mapped files - pros and cons of mapping view on whole file

2. Reading data from a memory mapped file

3. Reading data from a memory mapped file

4. IPC: Shared memory via dll vs memory map file

5. copying CObject-derived-classes to shared memory (created using Memory-Mapped file)

6. Appending data in a file

7. Appending data in a file

8. Appending data in a file

9. Append Data to exe or dll file

10. FTP: Append data to existing file

11. FTP: Append data to an existing file

12. Appending Data to a file

 

 
Powered by phpBB® Forum Software