From 5a7f68ff1a4cfedfb123a6ce621c19a5cf7373be Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Mon, 7 Mar 2016 11:04:05 -0300 Subject: Revert "Import patch from https://reviews.freebsd.org/D5186" This reverts commit 3882f7f0612f5660c6287cfa1ba025f2843a1957. --- lib/libc/db/hash/hash.c | 6 +----- usr.bin/cap_mkdb/cap_mkdb.c | 2 +- usr.sbin/pwd_mkdb/pwd_mkdb.c | 8 ++++---- usr.sbin/services_mkdb/services_mkdb.c | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 333b1a1..af80929 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -422,10 +422,8 @@ hdestroy(HTAB *hashp) if (hashp->tmp_buf) free(hashp->tmp_buf); - if (hashp->fp != -1) { - (void)_fsync(hashp->fp); + if (hashp->fp != -1) (void)_close(hashp->fp); - } free(hashp); @@ -460,8 +458,6 @@ hash_sync(const DB *dbp, u_int32_t flags) return (0); if (__buf_free(hashp, 0, 1) || flush_meta(hashp)) return (ERROR); - if (hashp->fp != -1 && _fsync(hashp->fp) != 0) - return (ERROR); hashp->new_file = 0; return (0); } diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c index 2f8bd96..bbcedd5 100644 --- a/usr.bin/cap_mkdb/cap_mkdb.c +++ b/usr.bin/cap_mkdb/cap_mkdb.c @@ -119,7 +119,7 @@ main(int argc, char *argv[]) (void)snprintf(buf, sizeof(buf), "%s.db", capname ? capname : *argv); if ((capname = strdup(buf)) == NULL) errx(1, "strdup failed"); - if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR, + if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR | O_SYNC, DEFFILEMODE, DB_HASH, &openinfo)) == NULL) err(1, "%s", buf); diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index 9158e61..c75804a 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -225,14 +225,14 @@ main(int argc, char *argv[]) clean = FILE_INSECURE; cp(buf2, buf, PERM_INSECURE); dp = dbopen(buf, - O_RDWR|O_EXCL, PERM_INSECURE, DB_HASH, &openinfo); + O_RDWR|O_EXCL|O_SYNC, PERM_INSECURE, DB_HASH, &openinfo); if (dp == NULL) error(buf); clean = FILE_SECURE; cp(sbuf2, sbuf, PERM_SECURE); sdp = dbopen(sbuf, - O_RDWR|O_EXCL, PERM_SECURE, DB_HASH, &openinfo); + O_RDWR|O_EXCL|O_SYNC, PERM_SECURE, DB_HASH, &openinfo); if (sdp == NULL) error(sbuf); @@ -289,13 +289,13 @@ main(int argc, char *argv[]) method = 0; } else { dp = dbopen(buf, - O_RDWR|O_CREAT|O_EXCL, PERM_INSECURE, DB_HASH, &openinfo); + O_RDWR|O_CREAT|O_EXCL|O_SYNC, PERM_INSECURE, DB_HASH, &openinfo); if (dp == NULL) error(buf); clean = FILE_INSECURE; sdp = dbopen(sbuf, - O_RDWR|O_CREAT|O_EXCL, PERM_SECURE, DB_HASH, &openinfo); + O_RDWR|O_CREAT|O_EXCL|O_SYNC, PERM_SECURE, DB_HASH, &openinfo); if (sdp == NULL) error(sbuf); clean = FILE_SECURE; diff --git a/usr.sbin/services_mkdb/services_mkdb.c b/usr.sbin/services_mkdb/services_mkdb.c index c928ea9..9ea66de 100644 --- a/usr.sbin/services_mkdb/services_mkdb.c +++ b/usr.sbin/services_mkdb/services_mkdb.c @@ -141,7 +141,7 @@ main(int argc, char *argv[]) err(1, "Cannot install exit handler"); (void)snprintf(tname, sizeof(tname), "%s.tmp", dbname); - db = dbopen(tname, O_RDWR | O_CREAT | O_EXCL, + db = dbopen(tname, O_RDWR | O_CREAT | O_EXCL | O_SYNC, (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH), DB_HASH, &hinfo); if (!db) err(1, "Error opening temporary database `%s'", tname); -- cgit v1.1