From: Mark Andrews Date: Wed, 29 Aug 2001 05:52:49 +0000 (+0000) Subject: Ensure that the files contents have been synced to disk prior to renaming. X-Git-Tag: v9.2.0b1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7231717254c3e872f5d2ca87c554dbbb4bddeeec;p=thirdparty%2Fbind9.git Ensure that the files contents have been synced to disk prior to renaming. --- diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index c805cd94887..d4091004dfb 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: masterdump.c,v 1.55 2001/07/16 17:15:08 gson Exp $ */ +/* $Id: masterdump.c,v 1.56 2001/08/29 05:52:49 marka Exp $ */ #include @@ -1004,6 +1004,17 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, goto cleanup; } + result = isc_stdio_sync(f); + if (result != ISC_R_SUCCESS) { + isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL, + DNS_LOGMODULE_MASTERDUMP, ISC_LOG_ERROR, + "dumping master file: %s: fsync: %s", + tempname, isc_result_totext(result)); + (void)isc_stdio_close(f); + (void)isc_file_remove(tempname); + goto cleanup; + } + result = isc_stdio_close(f); if (result != ISC_R_SUCCESS) { isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL, @@ -1012,7 +1023,6 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, tempname, isc_result_totext(result)); (void)isc_file_remove(tempname); goto cleanup; - } result = isc_file_rename(tempname, filename);