bool mode_auto;
bool have_dirs;
bool disable_fsync;
+ bool accurate_mtime;
};
struct posix_fs_file {
fs->have_dirs = TRUE;
} else if (strcmp(arg, "no-fsync") == 0) {
fs->disable_fsync = TRUE;
+ } else if (strcmp(arg, "accurate-mtime") == 0) {
+ fs->accurate_mtime = TRUE;
} else if (strncmp(arg, "mode=", 5) == 0) {
unsigned int mode;
if (str_to_uint_oct(arg+5, &mode) < 0) {
return -1;
}
}
+ if (fs->accurate_mtime) {
+ /* Linux updates the mtime timestamp only on timer interrupts.
+ This isn't anywhere close to being microsecond precision.
+ If requested, use utimes() to explicitly set a more accurate
+ mtime. */
+ struct timeval tv[2];
+ if (gettimeofday(&tv[0], NULL) < 0)
+ i_fatal("gettimeofday() failed: %m");
+ tv[1] = tv[0];
+ if ((utimes(file->temp_path, tv)) < 0) {
+ fs_set_error(file->file.fs, "utimes(%s) failed: %m",
+ file->temp_path);
+ return -1;
+ }
+ }
fs_posix_write_rename_if_needed(file);
switch (file->open_mode) {