Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Syntactic Confectionery Delight
 
PerlMonks  

Re: Is readdir ever deterministic?

by merlyn (Sage)
on Sep 17, 2001 at 18:52 UTC ( #112869=note: print w/ replies, xml ) Need Help??


in reply to Is readdir ever deterministic?

readdir on Unix returns the underlying raw directory order. Additions and deletions to the directory use and free-up slots. The first two entries to any directory are always created as "dot" and "dotdot", and these entries are never deleted under normal operation.

However, if a directory entry for either of these gets incorrectly deleted (through corruption, or using the perl -U option and letting the superuser unlink it, for example), the next fsck run has to recreate the entry, and it will simply add it. Oops, dot and dotdot are no longer the first two entries!

So, defensive programming mandates that you do not count on the slot order. And there's no promise that dot and dotdot are the first two entries, because Perl can't control that, and the underlying OS doesn't promise it either.

-- Randal L. Schwartz, Perl hacker


Comment on Re: Is readdir ever deterministic?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://112869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-04-18 23:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (472 votes), past polls