Messages in this thread | | | Date | Sun, 21 Nov 2010 09:52:52 -0600 | From | Shawn Bohrer <> | Subject | Re: [PATCH] perf: Handle DT_UNKNOWN on filesystems that don't support d_type |
| |
On Sat, Nov 20, 2010 at 10:48:36PM -0200, Arnaldo Carvalho de Melo wrote: > Em Sat, Nov 20, 2010 at 06:42:19PM -0600, Shawn Bohrer escreveu: > > Some filesystems like xfs and reiserfs will return DT_UNKNOWN for the > > d_type. Handle this case by calling stat() to determine the type. > > Thanks for the fix, just waiting for some more reviewers to chime in, > seems odd, like readdir_r has a bug.
The readdir_r man page says the following:
If the file type could not be determined, the value DT_UNKNOWN is returned in d_type.
Currently, only some file systems (among them: Btrfs, ext2, ext3, and ext4) have full support returning the file type in d_type. All applications must properly handle a return of DT_UNKNOWN.
So it isn't a bug in readdir_r. This also isn't the only place that perf uses readdir/readdir_r, and doesn't handle DT_UNKNOWN. In the other locations it looked to me like it was only reading from debugfs, so I don't think it matters.
> Even if that is the case we'll have to cope, and doing the extra stat > only when in "doubt" (i.e. when getting DT_UNKNOWN) seems the right > thing to me. > > - Arnaldo
| |