aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2026-04-12 08:56:26 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2026-05-10 14:53:20 +0000
commita2e0822543e93a8d815acd2d1c3d51ef73d6e262 (patch)
tree7efdb49e31bdecb3cb6f1e5f22d44c9c9d758252
parent0f6c880fcecdbb9cc84ed03ee85a518dd3c66f12 (diff)
libc: add freadlink(3)
Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D56365
-rw-r--r--include/unistd.h1
-rw-r--r--lib/libc/gen/Makefile.inc1
-rw-r--r--lib/libc/gen/Symbol.map1
-rw-r--r--lib/libc/gen/freadlink.c16
4 files changed, 19 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h
index 797eac4c364d..290bcce6a0b3 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -518,6 +518,7 @@ int execvpe(const char *, char * const *, char * const *);
int feature_present(const char *);
int fchroot(int);
char *fflagstostr(u_long);
+ssize_t freadlink(int fd, char *buf, size_t bufsize);
int getdomainname(char *, int);
int getentropy(void *, size_t);
int getgrouplist(const char *, gid_t, gid_t *, int *);
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index c31f789fd1d1..18a68902f50a 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -56,6 +56,7 @@ SRCS+= \
fmtmsg.c \
fnmatch.c \
fpclassify.c \
+ freadlink.c \
frexp.c \
fstab.c \
ftok.c \
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index 60f34b3a1923..4d22251f7ec5 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -475,6 +475,7 @@ FBSD_1.8 {
};
FBSD_1.9 {
+ freadlink;
posix_spawn_file_actions_addchdir;
posix_spawn_file_actions_addfchdir;
posix_spawnattr_getexecfd_np;
diff --git a/lib/libc/gen/freadlink.c b/lib/libc/gen/freadlink.c
new file mode 100644
index 000000000000..e1ed7aba6c06
--- /dev/null
+++ b/lib/libc/gen/freadlink.c
@@ -0,0 +1,16 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2026 The FreeBSD Foundation
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ */
+
+#include <unistd.h>
+
+ssize_t
+freadlink(int fd, char *buf, size_t bufsize)
+{
+ return (readlinkat(fd, "", buf, bufsize));
+}