summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2010-11-30 14:08:25 -0500
committerScott Ullrich <sullrich@pfsense.org>2010-11-30 14:08:25 -0500
commit00bc5bcc87a5e5f8aa7fc5e33973add703d688b4 (patch)
treedbcc0713d23f6476fc8e72314d3187d032602b4a /etc/inc
parenta6e0e07bf1934f9e73d1a1bd8e99c91f7839e30f (diff)
downloadpfsense-00bc5bcc87a5e5f8aa7fc5e33973add703d688b4.zip
pfsense-00bc5bcc87a5e5f8aa7fc5e33973add703d688b4.tar.gz
Call sync after writing the file and before returning to continue processing.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/config.lib.inc40
1 files changed, 22 insertions, 18 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index b383921..2d51db7 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -433,27 +433,31 @@ function convert_config() {
* boolean - true if successful, false if not
******/
function safe_write_file($file, $content, $force_binary) {
- $tmp_file = $file . "." . getmypid();
- $write_mode = $force_binary ? "wb" : "w";
+ $tmp_file = $file . "." . getmypid();
+ $write_mode = $force_binary ? "wb" : "w";
- $fd = fopen($tmp_file, $write_mode);
- if (!$fd) {
- // Unable to open temporary file for writing
- return false;
- }
- if (!fwrite($fd, $content)) {
- // Unable to write to temporary file
- fclose($fd);
- return false;
+ $fd = fopen($tmp_file, $write_mode);
+ if (!$fd) {
+ // Unable to open temporary file for writing
+ return false;
}
- fclose($fd);
+ if (!fwrite($fd, $content)) {
+ // Unable to write to temporary file
+ fclose($fd);
+ return false;
+ }
+ fclose($fd);
- if (!rename($tmp_file, $file)) {
- // Unable to move temporary file to original
- unlink($tmp_file);
- return false;
- }
- return true;
+ if (!rename($tmp_file, $file)) {
+ // Unable to move temporary file to original
+ unlink($tmp_file);
+ return false;
+ }
+
+ // Sync file before returning
+ exec("/bin/sync");
+
+ return true;
}
/****f* config/write_config
OpenPOWER on IntegriCloud