[PATCH v4] lsof: correct check for symbolic link

Denys Vlasenko vda.linux at googlemail.com
Wed Jun 26 23:36:04 UTC 2013


On Friday 21 June 2013 21:27, Thomas De Schampheleire wrote:
> Busybox lsof used the d_type field of a 'struct dirent' to verify whether the
> entry is a symbolic link. This field, however, is not portable. On at least
> one board [1] I have seen, that field is 0, and the check fails even though
> the entry is a link.
> 
> The explicit check for a symbolic link is really only needed to skip the
> default directory entries '.' and '..'. The directory /proc/<pid>/fd/
> should not contain anything else but these two and symbolic links.
> With these assumptions, this patch replaces the explicit link check with a
> basic check for '.' and '..' (and any hidden file). In the unlikely case that
> there are other file types, xmalloc_readlink() will return NULL, and we can
> skip the entry.
> 
> [1] A MIPS-based board with glibc 2.9, Linux 2.6.32.27.
> 
> Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>

Applied, thanks!


More information about the busybox mailing list