]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fdatasync_path(): Ignore EBADF errors, it probably means directory fsyncing
authorTimo Sirainen <tss@iki.fi>
Sun, 20 Jul 2008 12:24:05 +0000 (15:24 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 20 Jul 2008 12:24:05 +0000 (15:24 +0300)
isn't allowed (e.g. NetBSD).

--HG--
branch : HEAD

src/lib/fdatasync-path.c

index 55d2ec2eaa84b2399dd676031d7086a5eb06d3c6..45593b9cf86fdca860502a9808f9ab47cd52cbf3 100644 (file)
@@ -15,8 +15,14 @@ int fdatasync_path(const char *path)
        fd = open(path, O_RDONLY);
        if (fd == -1)
                return -1;
-       if (fdatasync(fd) < 0)
-               ret = -1;
+       if (fdatasync(fd) < 0) {
+               if (errno == EBADF) {
+                       /* At least NetBSD doesn't allow fsyncing directories.
+                          Silently ignore the problem. */
+               } else {
+                       ret = -1;
+               }
+       }
        (void)close(fd);
        return ret;
 }