Dag-Erling Smørgrav wrote in <[email protected]>: |Steffen Nurpmeso <[email protected]> writes: |> Only to mention that POSIX Issue 8 has posix_getdents() that |> gives application programmers a good tool for flexible buffer |> usage ("none to many" dirents in one go, as you need it), as well |> as lots of *stat*(2) avoidance possibilities. This is a real |> improvement when available, and i hope the world will go this |> route, so that the only optional getdirentries() / getdents() |> / getdents64() / readdir()+stat() dances will come to an end in |> the future. | |posix_getdents() is getdents() with an unused flag argument and |deliberately incompatible types and names. I intend to implement it |eventually, but it adds nothing.
Not when all implement it and one can start (or restart, plan9port went into the opposite direction five years ago) to make use of its positive aspects. I think Geoff Clare had a good thought with the flags argument: Implementations are encouraged to include support for a DT_FORCE_TYPE flag which, when that bit is set in flags, causes posix_getdents( ) to look up the file type if it can not be obtained from the directory entry. This will allow applications that need to know the file type of every directory entry to keep the cost of these lookups to the minimum needed to obtain the type at the file system level, without the additional overhead of making a call to fstatat( ) for every file (that has d_type equal to DT_UNKNOWN). That completely moves that cost to the operating system, and avoids many expensive system calls -- the system calls! the locking! the lookups! and all that!! --, when implemented. Ah. The problems without *at(), to be able to lstat() the path of an actual entry, you know, .. and how (un!)safe was that actually. So many (unsafe) code paths to drop. Simply use posix_getdents() with the DT_FORCE_TYPE flag. I think Geoff Clare really does a really really great job! --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
