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

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

    From 912a4c34661105a1d2ac8eb4740ab4950a3cfb53 Mon Sep 17 00:00:00 2001
    From: Vasilij Schneidermann <mail@vasilij.de>
    Date: Fri, 7 Jul 2017 22:42:12 +0200
    Subject: [PATCH] Handle other errors than EACCES for access(3)
    
    ---
     posixunix.scm | 9 ++++++---
     1 file changed, 6 insertions(+), 3 deletions(-)
    
    diff --git a/posixunix.scm b/posixunix.scm
    index 9304b395..de63399c 100644
    a b EOF 
    10311031(let ()
    10321032  (define (check filename acc loc)
    10331033    (##sys#check-string filename loc)
    1034     (let ([r (fx= 0 (##core#inline "C_test_access" (##sys#make-c-string filename loc) acc))])
    1035       (unless r (##sys#update-errno))
    1036       r) )
     1034    (let ([r (##core#inline "C_test_access" (##sys#make-c-string filename loc) acc)])
     1035      (if (fx= r -1)
     1036          (if (fx= (##sys#update-errno) _eacces)
     1037              #f
     1038              (posix-error #:file-error loc "cannot access file" filename))
     1039          #t)))
    10371040  (set! file-read-access? (lambda (filename) (check filename _r_ok 'file-read-access?)))
    10381041  (set! file-write-access? (lambda (filename) (check filename _w_ok 'file-write-access?)))
    10391042  (set! file-execute-access? (lambda (filename) (check filename _x_ok 'file-execute-access?))) )