1.0.0.16: fix SB-POSIX:READDIR to work when built with largefile
authorNikodemus Siivola <nikodemus@random-state.net>
Sun, 3 Dec 2006 15:24:08 +0000 (15:24 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Sun, 3 Dec 2006 15:24:08 +0000 (15:24 +0000)
  * amusingly, the dirent type returned changes name when largefile
    support is enabled.
  * whitespace damage.

NEWS
contrib/sb-posix/constants.lisp
contrib/sb-posix/interface.lisp
contrib/sb-posix/posix-tests.lisp
src/compiler/parse-lambda-list.lisp
src/runtime/largefile.c
tests/compiler.impure.lisp
tests/run-program.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index e8d49a3..8d37f26 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ changes in sbcl-1.0.1 relative to sbcl-1.0:
     variable was defined, but had an empty value (reported by Peter Van Eynde)
   * bug fix: non ordinary lambda-list keyword in ordinary lambda lists
     signal a PROGRAM-ERROR, not a BUG.
+  * bug fix: SB-POSIX:READDIR works when built with large file support.
   * optimization: loading generic functions no longer takes O(n^2) time,
     proportional to the amount of methods in the generic function
     (reported by Todd Sabin and Jeremy Brown)        
index cf5c767..7018fca 100644 (file)
 
  ;; opendir()
  (:structure dirent
-             ("struct dirent"
+             (#+(and linux largefile) "struct dirent64"
+              #-(and linux largefile) "struct dirent"
               (:c-string name "char *" "d_name"
                          :distrust-length #+sunos t #-sunos nil)) t)
 
index 870fa14..daaae9b 100644 (file)
 (define-call* "rmdir" int minusp (pathname filename))
 (define-call* "unlink" int minusp (pathname filename))
 (define-call "opendir" (* t) null-alien (pathname filename))
-(define-call "readdir" (* dirent)
+(define-call ("readdir" :largefile) (* dirent)
   ;; readdir() has the worst error convention in the world.  It's just
   ;; too painful to support.  (return is NULL _and_ errno "unchanged"
   ;; is not an error, it's EOF).
index 7cc725b..78b4754 100644 (file)
                         #'string<)
                   (sort (append '("." "..")
                                 (mapcar (lambda (p)
-                                          (enough-namestring p *current-directory*))
+                                          (let ((string (enough-namestring p *current-directory*)))
+                                            (if (pathname-name p)
+                                                string
+                                                (subseq string 0 (1- (length string))))))
                                         (directory (make-pathname
                                                     :name :wild
                                                     :type :wild
                                                     :defaults *current-directory*))))
-                        #'string<)) 
+                        #'string<))
         (sb-posix:closedir dir)))
   t)
 
index 5569eb3..64e5838 100644 (file)
                  (compiler-error "multiple &AUX in lambda list: ~S" list))
                (setq auxp t
                      state :aux))
-              (t 
+              (t
                ;; It could be argued that &WHOLE and friends would be just ordinary
                ;; variables in an ordinary lambda-list, but since (1) it seem exceedingly
-               ;; unlikely that that was that the programmer actually ment (2) the spec 
+               ;; unlikely that that was that the programmer actually ment (2) the spec
                ;; can be interpreted as giving as licence to signal an error[*] we do.
                ;;
                ;; [* All lambda list keywords used in the
   (multiple-value-bind (required optional restp rest keyp keys allowp auxp aux
                         morep more-context more-count)
       (parse-lambda-list-like-thing lambda-list)
-    
+
     ;; Check validity of parameters.
     (flet ((need-symbol (x why)
              (unless (symbolp x)
index 291f7c9..a75339f 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <sys/mman.h>
 #include <sys/types.h>
+#include <dirent.h>
 #include <unistd.h>
 #include <sys/stat.h>
 
@@ -60,4 +61,9 @@ lstat_largefile(const char *file_name, struct stat *buf) {
     return lstat(file_name, buf);
 }
 
+struct dirent64 *
+readdir_largefile(DIR *dir) {
+    return readdir(dir);
+}
+
 #endif
index a3d6f33..6b01a47 100644 (file)
 
 ;;; program-error from bad lambda-list keyword
 (assert (eq :ok
-            (handler-case 
+            (handler-case
                 (funcall (lambda (&whole x)
                            (list &whole x)))
               (program-error ()
index a9d3632..644bc2b 100644 (file)
 (defparameter *cat-out* (make-synonym-stream '*cat-out-pipe*))
 
 (with-test (:name :run-program-cat-2)
-  (let ((cat (run-program "/bin/cat" nil :input *cat-in* :output *cat-out* 
+  (let ((cat (run-program "/bin/cat" nil :input *cat-in* :output *cat-out*
                           :wait nil)))
-    (dolist (test '("This is a test!" 
-                    "This is another test!" 
+    (dolist (test '("This is a test!"
+                    "This is another test!"
                     "This is the last test...."))
       (write-line test *cat-in*)
       (assert (equal test (read-line *cat-out*))))
@@ -65,7 +65,7 @@
 
 ;;; The above test used to use ed, but there were buffering issues: on some platforms
 ;;; buffering of stdin and stdout depends on their TTYness, and ed isn't sufficiently
-;;; agressive about flushing them. So, here's another test using :PTY. 
+;;; agressive about flushing them. So, here's another test using :PTY.
 
 (defparameter *tmpfile* "run-program-ed-test.tmp")
 
@@ -97,7 +97,7 @@
   *ed*)
 
 (unwind-protect
-     (with-test (:name :run-program-ed) 
+     (with-test (:name :run-program-ed)
        (assert-ed nil "4")
        (assert-ed ".s/bar/baz/g" "")
        (assert-ed "w" "4")
index 1154bac..3391f43 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.0.15"
+"1.0.0.16"