HomeFreeBSD

realpath: Report correct path on failure

Description

realpath: Report correct path on failure

If lstat() fails with EACCES or ENOTDIR, the path we need to return in
the caller-provided buffer is that of the parent directory (which is
either unreadable or not a directory; the latter can only happen in the
case of a race) rather than that of the child we attempted to stat.

Approved by: re (cperciva)
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53025

(cherry picked from commit 1406de21e176d8700240ac9e473df007cd41eec1)
(cherry picked from commit 6c9b25246d4408eced73886d0b58feef7bff25c6)

Details

Provenance
desAuthored on Oct 13 2025, 11:53 AM
cpercivaCommitted on Thu, Oct 30, 11:49 PM
Reviewer
markj
Differential Revision
D53025: realpath: Report correct path on failure
Parents
rG4dc6fd2b9bab: realpath: Additional test cases
Branches
Unknown
Tags
Unknown