* src/ls.c (format_inode): Access f->stat only if f->stat_ok is set.
* NEWS (Bug fixes): Mention it.
Improved-by: Pádraig Brady <P@draigBrady.com>
ls -Li is now consistent with ls -Lil in printing "?", not "0" as the
inode of a dangling symlink.
+ ls -Li no longer relies on unspecified behavior of stat/lstat.
+ Before this change, "ls -Li dangling-symlink" would mistakenly
+ print the inode number of the symlink under some conditions.
+
** Portability
On Solaris 9, many commands would mistakenly treat file/ the same as
format_inode (char *buf, size_t buflen, const struct fileinfo *f)
{
assert (INT_BUFSIZE_BOUND (uintmax_t) <= buflen);
- return (f->stat.st_ino == NOT_AN_INODE_NUMBER
- ? (char *) "?"
- : umaxtostr (f->stat.st_ino, buf));
+ return (f->stat_ok && f->stat.st_ino != NOT_AN_INODE_NUMBER
+ ? umaxtostr (f->stat.st_ino, buf)
+ : (char *) "?");
}
/* Print information about F in long format. */