From: Xavier Roche <roche+kml2@exalead.com>
To: linux-kernel@vger.kernel.org
Subject: Timestamp of file modified through mmap are not changed in 2.6
Date: Fri, 08 Apr 2005 17:17:00 +0200 [thread overview]
Message-ID: <4256A06C.8020304@exalead.com> (raw)
Timestamp of file modified through mmap are not changed in 2.6 (even
after msync()). Observations on 2.4 and 2.6 kernels:
- on 2.4, timestamps are altered a few seconds after the program exits.
- on 2.6, timestamps are never altered.
Is this behaviour a normal behaviour ?
Program example to reproduce the bug (you need to create a "test" file
in the current directory first):
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main(void) {
int fd = open("test", O_RDWR);
struct stat st;
char* file;
if (fd == -1) {
printf("error opening file\n");
return 1;
}
if (fstat(fd, &st) != 0) {
printf("error fstating file\n");
return 1;
}
if (st.st_size == 0) {
printf("error empty file\n");
return 1;
}
printf("Modified date before change: %u\n", st.st_mtime);
file = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (file == NULL) {
printf("error mmaping file");
return 1;
}
file[0] = file[0] + 1;
if (msync((void*) file, st.st_size, MS_SYNC) != 0) {
printf("error syncing file");
return 1;
}
if (munmap(file, st.st_size) != 0) {
printf("error closing file");
return 1;
}
if (fstat(fd, &st) != 0) {
printf("error fstating file\n");
return 1;
}
printf("Modified date after change: %u\n", st.st_mtime);
return 0;
}
next reply other threads:[~2005-04-08 15:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-08 15:17 Xavier Roche [this message]
2005-04-08 15:46 ` Alexander Nyberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4256A06C.8020304@exalead.com \
--to=roche+kml2@exalead.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®