]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/file.c
Added a SyncOnClose directive to cups-files.conf to force cupsd to call fsync
[thirdparty/cups.git] / scheduler / file.c
index ca5aa5e2c5284f8d191431fae6fac89b7695014c..0d236c918bd4b0f951bbee1ccec220157c688781 100644 (file)
@@ -108,6 +108,29 @@ cupsdCloseCreatedConfFile(
        oldfile[1024];                  /* filename.O */
 
 
+ /*
+  * Synchronize changes to disk if SyncOnClose is enabled.
+  */
+
+  if (SyncOnClose)
+  {
+    if (cupsFileFlush(fp))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to write changes to \"%s\": %s",
+                     filename, strerror(errno));
+      cupsFileClose(fp);
+      return (-1);
+    }
+
+    if (fsync(cupsFileNumber(fp)))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to sync changes to \"%s\": %s",
+                     filename, strerror(errno));
+      cupsFileClose(fp);
+      return (-1);
+    }
+  }
+
  /*
   * First close the file...
   */