Raymond Toy pushed to branch master at cmucl / cmucl
Commits: 17499591 by Elias Pipping at 2016-09-28T21:21:52+00:00 Fix: directory followed symlinks with :follow-links nil
- - - - - 4bf2062f by Raymond Toy at 2016-10-02T16:48:11+00:00 Merge branch 'master' into 'master'
Fix: directory followed symlinks with :follow-links nil
I'm on Linux. I'm looking at a directory that contains both physical directories and symbolic links to directories.
### What I would expect: ```common-lisp (directory "/path/to/dir/*.*" :check-for-subdirs t :follow-links t :truenamep nil) ```
will show both (because it will show everything in that directory) and mark both types as directories with trailing slashes. ```common-lisp (directory "/path/to/dir/*.*" :check-for-subdirs t :follow-links nil :truenamep nil) ```
will again show all files but only add trailing slashes to the physical subdirectories.
### What actually happens Both commands give me the same output. That is because `directory` calls `unix:unix-file-kind` to categorise files into directory/link/etc., which internally calls `stat`. It will only use `lstat` if the second, optional argument is passed as **t**. In default mode (the way it currently is) symlinks to directories will be assigned the type :directory regardless of the flags passed to `directory`.
I believe the change contained in this merge request is thus the correct fix.
See merge request !15 - - - - -
1 changed file:
- src/code/filesys.lisp
Changes:
===================================== src/code/filesys.lisp ===================================== --- a/src/code/filesys.lisp +++ b/src/code/filesys.lisp @@ -1125,7 +1125,7 @@ optionally keeping some of the most recent old versions." (let ((*ignore-wildcards* t)) (mapcar #'(lambda (name) (let ((name (if (and check-for-subdirs - (eq (unix:unix-file-kind name) + (eq (unix:unix-file-kind name (not follow-links)) :directory)) (concatenate 'string name "/") name)))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/3d18025d13e030958e44641c7...