summaryrefslogtreecommitdiffhomepage
path: root/svr-kex.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-01-04 22:22:43 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-01-04 22:22:43 +0800
commit634415f79e7bb13e9831186121009f407c23a5fc (patch)
treeab665c5593038237143adc8a77821ec581bfdc28 /svr-kex.c
parent4ba830fc31c056aaada774ce29bb7d4e136b5dcd (diff)
Open directories O_RDONLY for fsync, add debugging if it fails
Diffstat (limited to 'svr-kex.c')
-rw-r--r--svr-kex.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/svr-kex.c b/svr-kex.c
index 01c76e6..6cc5433 100644
--- a/svr-kex.c
+++ b/svr-kex.c
@@ -91,12 +91,15 @@ static void fsync_parent_dir(const char* fn) {
#ifdef HAVE_LIBGEN_H
char *fn_dir = m_strdup(fn);
char *dir = dirname(fn_dir);
- /* some OSes need the fd to be writable for fsync */
- int dirfd = open(dir, O_RDWR);
+ int dirfd = open(dir, O_RDONLY);
if (dirfd != -1) {
- fsync(dirfd);
+ if (fsync(dirfd) != 0) {
+ TRACE(("fsync of directory %s failed: %s", dir, strerror(errno)))
+ }
m_close(dirfd);
+ } else {
+ TRACE(("error opening directory %s for fsync: %s", dir, strerror(errno)))
}
free(fn_dir);