From 03c6492d157166a0480c8669da1e5d9215e3a38f Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <mail@vasilij.de>
Date: Sat, 14 Oct 2017 16:59:02 +0200
Subject: [PATCH] Handle other errors than EACCES for access(3)
---
posix-common.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/posix-common.scm b/posix-common.scm
index 553725a9..ce323c54 100644
a
|
b
|
EOF |
369 | 369 | (let () |
370 | 370 | (define (check filename acc loc) |
371 | 371 | (##sys#check-string filename loc) |
372 | | (let ((r (fx= 0 (##core#inline "C_test_access" (##sys#make-c-string filename loc) acc)))) |
373 | | (unless r (##sys#update-errno)) |
374 | | r) ) |
| 372 | (let ([r (##core#inline "C_test_access" (##sys#make-c-string filename loc) acc)]) |
| 373 | (if (fx= r -1) |
| 374 | (if (fx= (##sys#update-errno) _eacces) |
| 375 | #f |
| 376 | (posix-error #:file-error loc "cannot access file" filename)) |
| 377 | #t))) |
375 | 378 | (set! file-read-access? (lambda (filename) (check filename _r_ok 'file-read-access?))) |
376 | 379 | (set! file-write-access? (lambda (filename) (check filename _w_ok 'file-write-access?))) |
377 | 380 | (set! file-execute-access? (lambda (filename) (check filename _x_ok 'file-execute-access?))) ) |