diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-06-05 11:14:41 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-06-05 23:10:37 +0200 |
commit | d088d5c4848f08bd62e722789132f9345659c52c (patch) | |
tree | aaa39f5005b036826b7437bed0e1af93c1caebcf /gnu/build/accounts.scm | |
parent | ed8570dce3683b73bdf668b3ad0f529a1cea30c5 (diff) | |
download | guix-d088d5c4848f08bd62e722789132f9345659c52c.tar guix-d088d5c4848f08bd62e722789132f9345659c52c.tar.gz |
accounts: Call 'fdatasync' when writing databases.
* gnu/build/accounts.scm (catch-ENOSYS): New macro.
(database-writer): Call 'fdatasync'.
Diffstat (limited to 'gnu/build/accounts.scm')
-rw-r--r-- | gnu/build/accounts.scm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gnu/build/accounts.scm b/gnu/build/accounts.scm index 2120c1d11d..b90149565f 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 () |