readdir function sort behaviour changed in between Solaris 10 u2 and u3?

We rely on the usual sort order, observed generally on Unix and up to 6/06 in Solaris 10 too, but since we installed 11/06 on one SPARC system, the (default) sort order of directory entries returned by readdir seems to have changed. Is anything known about this? Does anybody need an
[299 byte] By [s.urbata] at [2007-11-27 7:31:21]
# 1
Hmm, I don't believe that the POSIX spec says anything about the sort order of entries returned by readdir. So if your application depends on one, arguably your application is buggy.That being said, its surprising that your seeing different results on just one machine..
robert.cohena at 2007-7-12 19:11:33 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 2

> We rely on the usual sort order, observed generally

> on Unix and up to 6/06 in Solaris 10 too, but since

> we installed 11/06 on one SPARC system, the (default)

> sort order of directory entries returned by readdir

> seems to have changed. Is anything known about this?

> Does anybody need an example?

"sort order"? Readdir may return a specific order, but it is not "sorted".

Can you show an example of what you're getting? How are you calling readdir? What filesystem are you using? UFS, ZFS, or something else?

On UFS, readdir should return entries in "directory" order, based upon positioning within the directory. This is identical to what is returned from 'ls -f' within the directory. Without the -f, 'ls' itself is responsible for sorting.

# touch z 3 a 6 p

# ls -a

... 3 6 a p z

# ls -f

... z3a6p

# perl -e 'opendir(D,".");print join " ", readdir(D); print "\n";'

. .. z 3 a 6 p

ZFS uses hashing techniques rather than a linear list to maintain a directory. This improves performance in some situations, but means that the order returned is not necessarily the order that the files were created (but the order should be stable unless the directory is changed).

/tank/test# touch z 3 a 6 p

/tank/test# ls -f

... 6a3zp

/tank/test# perl -e 'opendir(D,".");print join " ", readdir(D); print "\n";'

. .. 6 a 3 z p

--

Darren

Darren_Dunhama at 2007-7-12 19:11:33 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...
# 3
The software was running on ufs. Since we can't seriously rely on any order delivered by readdir, I have assigned the error internally to our own development, because they made obviously wrong assumptions. If we need further help I will post more specific informations anyway. Thanks for
s.urbata at 2007-7-12 19:11:33 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...