From ed955671d2e844f274dd8245aa3c5c7e9dcdc77a Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Wed, 19 Feb 2025 16:52:04 +0000 Subject: [PATCH] libc: use __sys___realpathat directly in realpath We don't need to use an interposable symbol for this purpose and it's simpler to just call the syscall in libsys. This resolves a bug where we were incorrectly using __realpathat in libc not libsys. While here, drop support for running on a FreeBSD 12 kernel and simplify includes. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D49048 --- lib/libc/stdlib/realpath.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 28348ea9e22..4c52b73319a 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -28,21 +28,16 @@ * SUCH DAMAGE. */ -#include "namespace.h" #include #include #include #include +#include #include #include #include #include -#include "un-namespace.h" -#include "libc_private.h" - -extern int __realpathat(int fd, const char *path, char *buf, size_t size, - int flags); /* * Find the real name of path, by removing all ".", ".." and symlink @@ -224,9 +219,8 @@ __ssp_real(realpath)(const char * __restrict path, char * __restrict resolved) if (resolved == NULL) return (NULL); } - if (__getosreldate() >= 1300080) { - if (__realpathat(AT_FDCWD, path, resolved, PATH_MAX, 0) == 0) - return (resolved); + if (__sys___realpathat(AT_FDCWD, path, resolved, PATH_MAX, 0) == 0) { + return (resolved); } res = realpath1(path, resolved); if (res == NULL)