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.

Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53025

(cherry picked from commit 1406de21e176d8700240ac9e473df007cd41eec1)

Details

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