Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Is readdir ever deterministic?

by ChemBoy (Priest)
on Dec 17, 2001 at 23:54 UTC ( #132636=note: print w/replies, xml ) Need Help??

in reply to Is readdir ever deterministic?

Does there exist a platform where readdir returns . and .. in other than the first two return values?

Yes! Though it took me three months after reading this question to realize it... or possibly something changed in the system setup during those three months. But in any event, I have an example case:

% ls -a ./ ../ 10 11 2 4 5 6 8 9 % perl -le 'opendir DIR, "."; print join " ", readdir DIR' . 2 4 5 6 8 9 .. 10 11

The files were created in the order 2,4,6,8,10,5,9,11 (you could say this was an artificial test case, I suppose...), but this does not seem to affect the sort order. The result is the same running on 5.004/Irix and 5.005/Linux: the key is seems to be the underlying filesystem, which is SGI XFS (under IRIX 6.5).

As a further (and yet more psychotically artificial) test, we have

% touch , % ls -a , ./ ../ 10 11 2 4 5 6 8 9 % perl -le 'opendir DIR, "."; print join " ", readdir DIR' , . 2 4 5 6 8 9 .. 10 11

I haven't done an exhaustive investigation of exactly what XFS does for all cases, but it seems fairly clear that one-character filenames will, in general, break the common assumptions of readdir on that filesystem.

If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://132636]
LanX it's an imaginary list ...
LanX ... reflecting root problems
choroba uses real lists so he can easily insert as many items in between as needed
LanX questions the integerity of this approach. ..
LanX doesn't sound natural
[LanX]: welcome to a new episode of Big Perl Theory...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2018-03-20 10:30 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (250 votes). Check out past polls.