Subject: bug#63931: ls colors one symlink too much as non-broken in symlink chain

From: Paul Eggert <[email-masked]>
Date: Tue, 6 Jun 2023 15:10:49 -0700

On 6/6/23 13:32, Pádraig Brady wrote:
> I'll think a bit more about it and add a test before applying.

I wouldn't test that the 'ls' output exactly matches the 'cat' output. 
For example, it should be OK for stat_for_mode to pass the parent 
directory fd (instead of AT_FDCWD) to statx, for efficiency, and in that 
case the number of symbolic links traversed by 'ls' won't match the 
number traversed by 'cat', because the full name might traverse symlinks 
that statx (dirfd, ...) won't.

And it's OK if these two numbers don't match, as users shouldn't assume 
that the ELOOP limit is a constant.

With that in mind, the code change you proposed is reasonably innocuous, 
although it slows things down a bit in the usual case. Not sure it's 
worth doing (I guess it does fix a race but there are other unfixable 
races in this area....).