[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/09: accounts: Call 'fdatasync' when writing databases.
From: |
guix-commits |
Subject: |
09/09: accounts: Call 'fdatasync' when writing databases. |
Date: |
Wed, 5 Jun 2019 17:11:22 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit d088d5c4848f08bd62e722789132f9345659c52c
Author: Ludovic Courtès <address@hidden>
Date: Wed Jun 5 11:14:41 2019 +0200
accounts: Call 'fdatasync' when writing databases.
* gnu/build/accounts.scm (catch-ENOSYS): New macro.
(database-writer): Call 'fdatasync'.
---
gnu/build/accounts.scm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/gnu/build/accounts.scm b/gnu/build/accounts.scm
index 2120c1d..b901495 100644
--- a/gnu/build/accounts.scm
+++ b/gnu/build/accounts.scm
@@ -19,6 +19,7 @@
(define-module (gnu build accounts)
#:use-module (guix records)
#:use-module (guix combinators)
+ #:use-module ((guix build syscalls) #:select (fdatasync))
#:use-module (gnu system accounts)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
@@ -230,6 +231,14 @@ each field."
;; grab this lock with 'with-file-lock' when they access the databases.
"/etc/.pwd.lock")
+(define-syntax-rule (catch-ENOSYS exp)
+ (catch 'system-error
+ (lambda () exp)
+ (lambda args
+ (if (= ENOSYS (system-error-errno args))
+ #f
+ (apply throw args)))))
+
(define (database-writer file mode entry->string)
(lambda* (entries #:optional (file-or-port file))
"Write ENTRIES to FILE-OR-PORT. When FILE-OR-PORT is a file name, write
@@ -249,6 +258,11 @@ to it atomically and set the appropriate permissions."
(lambda ()
(chmod port mode)
(write-entries port)
+
+ ;; XXX: When booting with the statically-linked Guile,
+ ;; 'fdatasync' is unavailable.
+ (catch-ENOSYS (fdatasync port))
+
(close-port port)
(rename-file template file-or-port))
(lambda ()
- branch master updated (c0f6eeb -> d088d5c), guix-commits, 2019/06/05
- 04/09: syscalls: 'with-file-lock' expands to a call to 'call-with-file-lock'., guix-commits, 2019/06/05
- 02/09: gnu: minizip: Do not install crypt.h., guix-commits, 2019/06/05
- 08/09: accounts: Close database before renaming it., guix-commits, 2019/06/05
- 01/09: guix package: Do not list environment variables that need to be set., guix-commits, 2019/06/05
- 03/09: syscalls: Add 'with-file-lock' macro., guix-commits, 2019/06/05
- 09/09: accounts: Call 'fdatasync' when writing databases.,
guix-commits <=
- 07/09: nar: Really lock store files., guix-commits, 2019/06/05
- 05/09: syscalls: 'with-lock-file' catches ENOSYS., guix-commits, 2019/06/05
- 06/09: activation: Lock /etc/.pwd.lock before accessing databases., guix-commits, 2019/06/05