commit 3c2e7eadcc0ed083e94f5c4c62663772869a3038 Author: Oswald Buddenhagen <o...@kde.org> Date: Sun Sep 9 12:18:14 2012 +0200
call fdatasync() after updating .uidvalidity files they must be flushed before the file system meta data, as otherwise we may end up with duplicate UIDs after a system crash. src/drv_maildir.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index a9f5790..771cf48 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -42,6 +42,10 @@ # define LEGACY_FLOCK 1 #endif +#ifndef _POSIX_SYNCHRONIZED_IO +# define fdatasync fsync +#endif + #ifdef USE_DB #include <db.h> #endif /* USE_DB */ @@ -428,7 +432,7 @@ maildir_store_uid( maildir_store_t *ctx ) n = sprintf( buf, "%d\n%d\n", ctx->gen.uidvalidity, ctx->nuid ); lseek( ctx->uvfd, 0, SEEK_SET ); - if (write( ctx->uvfd, buf, n ) != n || ftruncate( ctx->uvfd, n )) { + if (write( ctx->uvfd, buf, n ) != n || ftruncate( ctx->uvfd, n ) || fdatasync( ctx->uvfd )) { error( "Maildir error: cannot write UIDVALIDITY.\n" ); return DRV_BOX_BAD; } ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel