Mercurial > dropbear
diff dbutil.c @ 1329:185c14fa504d
Use atomic key generation in all cases
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 19 Nov 2016 00:31:21 +0800 |
parents | 21156be2bb26 |
children | bbc0a0ee3843 |
line wrap: on
line diff
--- a/dbutil.c Fri Nov 18 23:56:22 2016 +0800 +++ b/dbutil.c Sat Nov 19 00:31:21 2016 +0800 @@ -681,4 +681,21 @@ return time(NULL); } +void fsync_parent_dir(const char* fn) { +#ifdef HAVE_LIBGEN_H + char *fn_dir = m_strdup(fn); + char *dir = dirname(fn_dir); + int dirfd = open(dir, O_RDONLY); + if (dirfd != -1) { + 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); +#endif +}