[PATCH v2] lsof: correct check for symbolic link
Thomas De Schampheleire
patrickdepinguin+busybox at gmail.com
Tue Jun 25 07:51:15 UTC 2013
On Fri, Jun 21, 2013 at 7:43 PM, Rich Felker <dalias at aerifal.cx> wrote:
> 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.
>
Thanks all for the feedback. I have sent an updated patch (v4) to the
list that implements the discussed approach.
Best regards,
Thomas
More information about the busybox
mailing list