Ticket #669: posixunix.scm.patch

File posixunix.scm.patch, 917 bytes (added by Alan Post, 13 years ago)

Patch to add fchdir syscall to chicken-core.

  • posixunix.scm

    diff --git a/posixunix.scm b/posixunix.scm
    index 3e578d9..eeed8ac 100644
    a b static C_TLS struct stat C_statbuf; 
    143143
    144144#define C_mkdir(str)        C_fix(mkdir(C_c_string(str), S_IRWXU | S_IRWXG | S_IRWXO))
    145145#define C_chdir(str)        C_fix(chdir(C_c_string(str)))
     146#define C_fchdir(fd)        C_fix(fchdir(C_unfix(fd)))
    146147#define C_rmdir(str)        C_fix(rmdir(C_c_string(str)))
    147148
    148149#define C_opendir(x,h)      C_set_block_item(h, 0, (C_word) opendir(C_c_string(x)))
    EOF 
    768769        (posix-error #:file-error 'change-directory "cannot change current directory" name) )
    769770      name)))
    770771
     772(define change-directory/fd
     773  (lambda (fd)
     774    (##sys#check-exact fd 'change-directory/fd)
     775    (unless (fx= 0 (##core#inline "C_fchdir" fd))
     776      (posix-error #:file-error 'change-directory/fd "cannot change current directory" fd) )
     777    fd))
     778
    771779
    772780;;; Pipes:
    773781