Coverage Report

Created: 2026-05-30 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dovecot/src/lib/fdatasync-path.c
Line
Count
Source
1
/* Copyright (c) 2008-2018 Dovecot authors, see the included COPYING file */
2
3
#include "lib.h"
4
#include "fdatasync-path.h"
5
6
#include <fcntl.h>
7
#include <unistd.h>
8
9
int fdatasync_path(const char *path)
10
0
{
11
0
  int fd, ret = 0;
12
13
  /* Directories need to be opened as read-only.
14
     fsync() doesn't appear to care about it. */
15
0
  fd = open(path, O_RDONLY);
16
0
  if (fd == -1)
17
0
    return -1;
18
0
  if (fdatasync(fd) < 0) {
19
    /* Some OSes/FSes don't allow fsyncing directories. Silently
20
       ignore the problem. */
21
0
    if (errno == EBADF) {
22
      /* e.g. NetBSD */
23
0
    } else if (errno == EINVAL) {
24
      /* e.g. Linux+CIFS */
25
0
    } else {
26
0
      ret = -1;
27
0
    }
28
0
  }
29
0
  i_close_fd(&fd);
30
0
  return ret;
31
0
}