The Cygwin developers have been trying to improve some d_type hints given during readdir(), to return DT_DIR instead of DT_UNKNOWN for obvious directories, as an example. But testing the patches for correctness has proved to be a bit of a challenge for testing. On an IRC chat, we discovered that it is really difficult to find out what d_type lists for a given file without using a debugger or writing a custom program - most GNU code is using it as an optimization to avoid lstat(), but never directly outputs that the optimization took place. So the idea was raised: could we teach stat(1) a new format arg that would make it painfully obvious what d_type hint is associated with a given file?
Of course, such a format is not trivial, and must not be part of the default stat output. Given 'stat --format=... a', you'd have to do readdir() on "." until you find "a", in order to get to the d_type. But I couldn't think of any better utility to enhance to easily get at d_type information from the shell. At least, stat(1) feels like a better choice than ls(1) for adding the enhanced output information. What do you think? Should I spend time writing up a patch? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
