Wed 22 Dec 2004 10:09:16 PM UTC, comment #2:
Hi Jay!
You're right, this is a kernel bug then, I'll soon report it
to the kernel folks.
On the other hand:
On recent systems, the "struct dirent" returned by readdir()
contains a d_type field which might (but not necessarily
does) provide information about the file type. E.g. it can
be DT_UNKNOWN meaning that stat() has to be performed in the
old-fashioned way to get the file type, but in the mean
time, it can also be DT_REG, DT_DIR and so on (see
/usr/include/dirent.h).
Whether or not this is supported depends on the operating
system as well as the filesystem type, for example, on reiserfs always DT_UNKNOWN is returned, but ext3 returns
normal values. And, fortunately, procfs also supports this
feature.
It would be very nice then if findutils, whenever available
(I know, both compile-time and run-time detection is needed,
run-time detection on a per-file basis), took advantage of
this feature (and ignored the -leaf/-noleaf option for those
directories). This would have at least two advantages:
- would be even faster than the current way since much more
stat() calls can be avoided,
- would be a perfect workaround for the kernel's /proc/PID
hardlink count problem.
|