From 1752a17a1e6f7138892eeeb4806cd04ccb3ca1b0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 13 Jun 2016 17:52:08 +0200 Subject: utils: 'with-atomic-file-output' calls 'fdatasync'. Suggested by Danny Milosavljevic at . * guix/build/syscalls.scm (fdatasync): New procedure. * guix/utils.scm (with-atomic-file-output): Use it. Use 'close-port' instead of 'close'. --- guix/build/syscalls.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'guix/build/syscalls.scm') diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 48ff227e10..ed0eb060d9 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -64,6 +64,7 @@ processes mkdtemp! + fdatasync pivot-root fcntl-flock @@ -506,6 +507,20 @@ string TMPL and return its file name. TMPL must end with 'XXXXXX'." (list err))) (pointer->string result))))) +(define fdatasync + (let ((proc (syscall->procedure int "fdatasync" (list int)))) + (lambda (port) + "Flush buffered output of PORT, an output file port, and then call +fdatasync(2) on the underlying file descriptor." + (force-output port) + (let* ((fd (fileno port)) + (ret (proc fd)) + (err (errno))) + (unless (zero? ret) + (throw 'system-error "fdatasync" "~S: ~A" + (list fd (strerror err)) + (list err))))))) + (define-record-type (file-system type block-size blocks blocks-free -- cgit v1.2.3