Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7329:d2b10facb504 HEAD
Moved fdatasync_path() to a global function.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 04 Mar 2008 03:47:57 +0200 |
parents | e0e212e7deeb |
children | 93f67b71476c |
files | src/lib-storage/index/maildir/maildir-save.c src/lib/Makefile.am src/lib/fdatasync-path.c src/lib/fdatasync-path.h |
diffstat | 4 files changed, 38 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-save.c Mon Mar 03 08:59:07 2008 +0200 +++ b/src/lib-storage/index/maildir/maildir-save.c Tue Mar 04 03:47:57 2008 +0200 @@ -7,6 +7,7 @@ #include "istream.h" #include "istream-crlf.h" #include "ostream.h" +#include "fdatasync-path.h" #include "str.h" #include "index-mail.h" #include "maildir-storage.h" @@ -571,25 +572,6 @@ ctx->files = pos; } -static int fdatasync_path(const char *path) -{ - int fd, ret = 0; - - /* Directories need to be opened as read-only. - fsync() doesn't appear to care about it. */ - fd = open(path, O_RDONLY); - if (fd == -1) { - i_error("open(%s) failed: %m", path); - return -1; - } - if (fdatasync(fd) < 0) { - i_error("fdatasync(%s) failed: %m", path); - ret = -1; - } - (void)close(fd); - return ret; -} - static int maildir_transaction_fsync_dirs(struct maildir_save_context *ctx, bool new_changed, bool cur_changed) { @@ -597,12 +579,16 @@ return 0; if (new_changed) { - if (fdatasync_path(ctx->newdir) < 0) + if (fdatasync_path(ctx->newdir) < 0) { + i_error("fdatasync_path(%s) failed: %m", ctx->newdir); return -1; + } } if (cur_changed) { - if (fdatasync_path(ctx->curdir) < 0) + if (fdatasync_path(ctx->curdir) < 0) { + i_error("fdatasync_path(%s) failed: %m", ctx->curdir); return -1; + } } return 0; }
--- a/src/lib/Makefile.am Mon Mar 03 08:59:07 2008 +0200 +++ b/src/lib/Makefile.am Tue Mar 04 03:47:57 2008 +0200 @@ -22,6 +22,7 @@ failures.c \ fd-close-on-exec.c \ fd-set-nonblock.c \ + fdatasync-path.c \ fdpass.c \ file-cache.c \ file-copy.c \ @@ -120,6 +121,7 @@ failures.h \ fd-close-on-exec.h \ fd-set-nonblock.h \ + fdatasync-path.h \ fdpass.h \ file-cache.h \ file-copy.h \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/fdatasync-path.c Tue Mar 04 03:47:57 2008 +0200 @@ -0,0 +1,22 @@ +/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "fdatasync-path.h" + +#include <fcntl.h> +#include <unistd.h> + +int fdatasync_path(const char *path) +{ + int fd, ret = 0; + + /* Directories need to be opened as read-only. + fsync() doesn't appear to care about it. */ + fd = open(path, O_RDONLY); + if (fd == -1) + return -1; + if (fdatasync(fd) < 0) + ret = -1; + (void)close(fd); + return ret; +}