Ticket #891 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Results of CL:DIRECTORY when symlinks are involved

Reported by: xach Owned by:
Priority: normal Milestone:
Component: other Version: trunk
Keywords: Cc:

Description

Based on the discussion at  http://clozure.com/pipermail/openmcl-devel/2011-November/013137.html it would be nice to have the following change in CCL:

With a directory structure like this:

    src/bar/foo.asd
    foo/bar -> ../src/bar
    foo/baz/quux.asd

Currently, starting ccl in the "foo" directory and evaluating (directory "*/*.asd") returns only quux.asd. It would be nice if it returned both foo.asd and quux.asd, as most other implementations do.

Change History

comment:1 Changed 2 years ago by gb

  • Status changed from new to closed
  • Resolution set to fixed

(In [15083]) %%STAT-VALUES returns stat.st_dev. (I haven't checked to see if it's called by any other name on non-Linux systems.)

DIRECTORY treats links to directories as directories when :FOLLOW-LINKS is T (as it is by default.) The :DIRECTORIES argument now defaults to T. AFAICT, fixes ticket:891.

comment:2 Changed 2 years ago by gb

I just did:

[~] gb@leadfoot> rm -rf foo src
[~] gb@leadfoot> mkdir -p  src/bar
[~] gb@leadfoot> ls src
bar
[~] gb@leadfoot> touch src/bar/foo.asd
[~] gb@leadfoot> mkdir foo
[~] gb@leadfoot> cd foo
[~/foo] gb@leadfoot> ln -s ../src/bar/ .
[~/foo] gb@leadfoot> mkdir baz
[~/foo] gb@leadfoot> touch baz/quux.asd
[~/foo] gb@leadfoot> ccl64 
Welcome to Clozure Common Lisp Version 1.8-dev-r15082M-trunk  (LinuxX8664)!
? (directory "*/*.asd")
(#P"/home/gb/foo/baz/quux.asd" #P"/home/gb/src/bar/foo.asd")
? 

Does this work for you ? How does this differ from your example /

comment:3 Changed 2 years ago by xach

Here's what I just tried:

$ rm -rf foo src
$ mkdir -p  src/bar
$ ls src
bar
$ touch src/bar/foo.asd
$ mkdir foo
$ cd foo
$ ln -s ../src/bar/ .
$ mkdir baz
$ touch baz/quux.asd
$ ccl
Welcome to Clozure Common Lisp Version 1.7-r15083M  (LinuxX8664)!
? (directory "*/*.asd")
(#P"/home/xach/tmp/linktest/foo/baz/quux.asd")
?

I don't see how it differs at all from what you did.

comment:4 Changed 2 years ago by gb

If I do:

? (trace ccl::%read-dir)
}}
and then:
? (setf (current-directory) "home:foo;")
"home:foo;"
? (trace %read-dir)
NIL
? (directory "*/*.asd")
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned "baz"
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "quux.asd"
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned ".."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned NIL
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned "."
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned ".."
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned "bar"
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "foo.asd"
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned ".."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned NIL
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned NIL
(#P"/home/gb/foo/baz/quux.asd" #P"/home/gb/src/bar/foo.asd")

The addresses of the foreign pointers aren't significant, but I'd be interested in seeing what output you get.

comment:5 Changed 2 years ago by xach

Here's what I get:

Welcome to Clozure Common Lisp Version 1.7-r15083M  (LinuxX8664)!
? (truename "")
#P"/home/xach/tmp/linktest/foo/"
? (setf (current-directory) *)
#P"/home/xach/tmp/linktest/foo/"
? (trace ccl::%read-dir)
NIL
? (directory "*/*.asd")
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBE9AE0>)
<0 CCL::%READ-DIR returned "."
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBE9AE0>)
<0 CCL::%READ-DIR returned "bar"
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBE9AE0>)
<0 CCL::%READ-DIR returned "baz"
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBF1B10>)
<0 CCL::%READ-DIR returned "."
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBF1B10>)
<0 CCL::%READ-DIR returned ".."
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBF1B10>)
<0 CCL::%READ-DIR returned "quux.asd"
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBF1B10>)
<0 CCL::%READ-DIR returned NIL
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBE9AE0>)
<0 CCL::%READ-DIR returned ".."
0> Calling (CCL::%READ-DIR #<A Foreign Pointer #xBE9AE0>)
<0 CCL::%READ-DIR returned NIL
(#P"/home/xach/tmp/linktest/foo/baz/quux.asd")
? 

comment:6 Changed 2 years ago by gb

Tracing another function (CCL::%NEW-DIRECTORY-P) as well as CCL::%READ-DIR, I get:

? (trace ccl::%new-directory-p)
NIL
? (directory #p"*/*.asd")
0> Calling (%NEW-DIRECTORY-P "/home/gb/foo/" T #S(DIRECTORY-RESULT :TRUENAMES #<HASH-TABLE :TEST STRING= size 0/60 #x3020007A50ED> :DIRECTORIES-SEEN NIL)) 
<0 %NEW-DIRECTORY-P returned T
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned "baz"
0> Calling (%NEW-DIRECTORY-P "/home/gb/foo/baz/" T #S(DIRECTORY-RESULT :TRUENAMES #<HASH-TABLE :TEST STRING= size 0/60 #x3020007A50ED> :DIRECTORIES-SEEN ((37224984 . 2053)))) 
<0 %NEW-DIRECTORY-P returned T
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "quux.asd"
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned ".."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned NIL
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned "."
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned ".."
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned "bar"
0> Calling (%NEW-DIRECTORY-P "/home/gb/foo/bar/" T #S(DIRECTORY-RESULT :TRUENAMES #<HASH-TABLE :TEST STRING= size 1/60 #x3020007A50ED> :DIRECTORIES-SEEN ((37224986 . 2053) (37224984 . 2053)))) 
<0 %NEW-DIRECTORY-P returned T
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "foo.asd"
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned "."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned ".."
0> Calling (%READ-DIR #<A Foreign Pointer #x173A500>) 
<0 %READ-DIR returned NIL
0> Calling (%READ-DIR #<A Foreign Pointer #x17324D0>) 
<0 %READ-DIR returned NIL
(#P"/home/gb/foo/baz/quux.asd" #P"/home/gb/src/bar/foo.asd")

comment:7 Changed 2 years ago by xach

(trace ccl::%new-directory-p) =>

Error: CCL::%NEW-DIRECTORY-P is undefined.

comment:8 Changed 2 years ago by xach

The problem was my use of the release instead of trunk. Using trunk works fine.

comment:9 Changed 2 years ago by gb

This is in 1.7 as of r15096.

Note: See TracTickets for help on using tickets.