Christian Kujau
2009-Jan-23 09:19 UTC
something odd with the order of files in a directory (fwd)
On Fri, 16 Jan 2009, Folkert van Heusden wrote:> I then would expect: > a.b > a.c > a.a > > but instead I get > drwxr-xr-x 3 root root 4096 2009-01-16 12:59 .. > -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.c > -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.b > -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.a > drwxr-xr-x 2 root root 4096 2009-01-16 12:59 .Hm, is this reproducible? Which kernel, mount-options, arch? Here on 2.6.24/amd64 the "directory order" (GNU/ls -U resp. BSD/ls -f) seems to work as expected: $ touch 1 2 3 $ mv 2 t/ ; mv 3 t/; mv 1 t/ $ ls -Ugo --time-style=full-iso t/ -rw-r----- 1 0 2009-01-22 15:50:01.414115303 +0100 2 -rw-r----- 1 0 2009-01-22 15:50:01.414115303 +0100 3 -rw-r----- 1 0 2009-01-22 15:50:01.414115303 +0100 1 Christian. -- BOFH excuse #175: OS swapped to disk
Andreas Dilger
2009-Jan-23 22:03 UTC
something odd with the order of files in a directory (fwd)
On Jan 23, 2009 10:19 +0100, Christian Kujau wrote:> On Fri, 16 Jan 2009, Folkert van Heusden wrote: >> I then would expect: >> a.b >> a.c >> a.a >> >> but instead I get >> drwxr-xr-x 3 root root 4096 2009-01-16 12:59 .. >> -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.c >> -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.b >> -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.a >> drwxr-xr-x 2 root root 4096 2009-01-16 12:59 . > > Hm, is this reproducible? Which kernel, mount-options, arch? > Here on 2.6.24/amd64 the "directory order" (GNU/ls -U resp. BSD/ls -f) > seems to work as expected:There is no such thing as "directory order" in Unix. It can change at any time, with the caveat that a single process doing a single readdir() will get each entry existing at the start and end of readdir exactly once. Cheers, Andreas -- Andreas Dilger Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc.