Re: [PATCH] perf: Handle DT_UNKNOWN on filesystems that don'tsupport d_type

From: Shawn Bohrer
Date: Sun Nov 21 2010 - 10:53:11 EST


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/