aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-02-20 16:58:19 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-02-20 16:58:19 +0000
commit0573d0a9b8ec478348cbf2a7ec370c875eb57dff (patch)
tree11b7e9f241b8fd9cad66b1f30bce46c6083e161c /lib/libc/stdlib
parent43623d0ce7ac4cbe47b94c69077ce5b268fb05cf (diff)
Notes
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/realpath.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c
index 99dc388c4db6..220910a3c610 100644
--- a/lib/libc/stdlib/realpath.c
+++ b/lib/libc/stdlib/realpath.c
@@ -42,14 +42,19 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <fcntl.h>
#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
* components. Returns (resolved) on success, or (NULL) on failure,
* in which case the path which caused trouble is left in (resolved).
*/
-static char *
+static char * __noinline
realpath1(const char *path, char *resolved)
{
struct stat sb;
@@ -223,6 +228,10 @@ 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);
+ }
res = realpath1(path, resolved);
if (res == NULL)
free(m);