mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* modification time not set correctly after mmap updates
@ 2003-10-26 19:28 Sean Estabrooks
  0 siblings, 0 replies; only message in thread
From: Sean Estabrooks @ 2003-10-26 19:28 UTC (permalink / raw)
  To: linux-kernel


mtime is not being updated after changes to files via mmap, at least not
on 2.6.0-test7.   Problem shows up on both ext3 and reiserfs.

Below is an ugly little program which updates a test file without
affecting its modification time.

I tried this on 2.4.23 and got the same behavior so perhaps i'm
misinterpreting this passage from the mmap man page:

 The  st_ctime  and st_mtime field for a file mapped with PROT_WRITE
 and MAP_SHARED will be updated after a write  to  the  mapped region, 
 and before  a  subsequent msync() with the MS_SYNC or MS_ASYNC
 flag, if one occurs.

Cheers,
Sean



#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
/* You'll need a file "test.txt" with a few bytes in it */
/* After running this proggy: file is changed but its mtime isn't */
#define SIZE 20
int main()
{
        int fd;
        char *mbuf;
 
        fd = open("test.txt", O_RDWR);
        mbuf = mmap(0, SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
        mbuf[1]='x';
        msync(mbuf, SIZE, MS_SYNC);
        munmap(mbuf, SIZE);
        fsync(fd);
        close(fd);
 
        return 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-10-26 19:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-26 19:28 modification time not set correctly after mmap updates Sean Estabrooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®