>From 4371464ac760a7934ceee474f3f196ba96827ed1 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Tue, 1 Oct 2013 22:16:26 +0200 Subject: [PATCH] A few fixes for file-creation-mode. - Don't pass #f to C_umask as if it were a fixnum - Ensure it always returns the old value even if no new value is set - Document the fact that MODE is optional --- manual/Unit posix | 5 +++-- posix-common.scm | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/manual/Unit posix b/manual/Unit posix index 961fbf1..d27fa88 100644 --- a/manual/Unit posix +++ b/manual/Unit posix @@ -598,10 +598,11 @@ exact integers) using the {{chown()}} system call. ==== file-creation-mode -(file-creation-mode MODE) +(file-creation-mode [MODE]) Returns the initial file permissions used for newly created files -(as with {{umask(2)}}. You can set the mode by executing +(as with {{umask(2)}}). If {{MODE}} is supplied, the mode is +changed to this value. You can set the mode by executing (set! (file-creation-mode) MODE) diff --git a/posix-common.scm b/posix-common.scm index 99c0315..99a840c 100644 --- a/posix-common.scm +++ b/posix-common.scm @@ -470,9 +470,9 @@ EOF (getter-with-setter (lambda (#!optional um) (when um (##sys#check-exact um 'file-creation-mode)) - (let ((um2 (##core#inline "C_umask" um))) - (unless um (##core#inline "C_umask" um2) - um2))) + (let ((um2 (##core#inline "C_umask" (or um 0)))) + (unless um (##core#inline "C_umask" um2)) ; restore + um2)) (lambda (um) (##sys#check-exact um 'file-creation-mode) (##core#inline "C_umask" um)) -- 1.8.3.4