[PATCH v2] lsof: correct check for symbolic link

Rich Felker dalias at aerifal.cx
Fri Jun 21 17:43:28 UTC 2013


On Fri, Jun 21, 2013 at 07:36:53PM +0200, Thomas De Schampheleire wrote:
> > Thanks for the feedback, I just sent a third version.
> >
> > For my info: is the check on the symbolic link only present to skip
> > '.' and '..', or are there situations where /proc/<pid>/fd contains
> > other entries than symbolic links and the two default directory
> > entries?
> 
> If it is only to skip . and .., and if we make an additional
> assumption that there will not be hidden files in /proc/<pid>/fd, then
> the entire code can be reduced to:

I think it's a reasonable assumption that /proc/<pid>/fd does not
contain anything but symbolic links, ., and .., but even if something
else does exist, readlink will fail with EINVAL. That seems like a
more reasonable way to detect the unexpected case of something other
than symlinks being there.

Rich


More information about the busybox mailing list