Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: readdir inconsistent!

by bluto (Curate)
on Jun 27, 2007 at 19:17 UTC ( #623712=note: print w/replies, xml ) Need Help??

in reply to readdir inconsistent!

First, you probably shouldn't assume that '.' and '..' are the first two directory entries returned from readdir(). AFAIK, this isn't guaranteed, so you should just check for them individually.

Second, are you mounting the filesystem over a network? For example, if you are using NFS make sure you test it with a hard mount or, if possible, test your code directly on the NFS server. NFS (and possibly other network filesystems) has to coordinate with the client on where in a directory it is reading from. I wouldn't be surprised if it's not exact on a huge directory since I've seen similar NFS bugs in the past.

One way to see if this is a filesystem issue, rather than in your perl code, is to use the 'find' command and count the lines in the output to see if you get inconsistent results.

Replies are listed 'Best First'.
Re^2: readdir inconsistent!
by LostShootingStar (Novice) on Jun 27, 2007 at 19:28 UTC
    I just tried the 'find' command suggestion, and found that the exact same thing is happening. different results each time. So i guess its not a perl issue, but if anyone has any suggestions im open too them. One thing i found is that if I run the script back to back to back, really fast, i get the same results. but if i wait a few min, or do other things on the system inbetween, the results are different. Again, im positive the directory contents are NOT changing.
      Again, im positive the directory contents are NOT changing.

      How do you back up that claim? Did you stat the '.' entry of the directories at each run? any differences?

      You might be hitting a bug of the underlying file system. What kind is it? xfs?


      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2021-10-22 07:18 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (85 votes). Check out past polls.