Ticket #1386: 0001-Handle-other-errors-than-EACCES-for-access-3.2.patch

File 0001-Handle-other-errors-than-EACCES-for-access-3.2.patch, 1.2 KB (added by Vasilij Schneidermann, 5 years ago)
  • posix-common.scm

    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 
    369369(let ()
    370370  (define (check filename acc loc)
    371371    (##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)))
    375378  (set! file-read-access? (lambda (filename) (check filename _r_ok 'file-read-access?)))
    376379  (set! file-write-access? (lambda (filename) (check filename _w_ok 'file-write-access?)))
    377380  (set! file-execute-access? (lambda (filename) (check filename _x_ok 'file-execute-access?))) )