git: 7ca5de287e58 - main - __getcwd(2), __getrealpath(2); add kern_ implementations
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 12 Nov 2026 10:23:45 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=7ca5de287e5804aaba354afd4a871f49e2af519a
commit 7ca5de287e5804aaba354afd4a871f49e2af519a
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-12 10:23:23 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-12 10:23:23 +0000
__getcwd(2), __getrealpath(2); add kern_ implementations
This corrects a accidentialy introduced definition of kern___getcwd.
Effort: CHERI upstreaming
Fixes: d718de812fe1 ("Introduce kern_mmap_req().")
Sponsored by: DARPA, AFRL, Innovate UK
Pull Request: https://github.com/freebsd/freebsd-src/pull/2284
---
sys/kern/vfs_cache.c | 12 ++++++++----
sys/sys/syscallsubr.h | 5 +++--
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 4dd69ee47e82..58047ab047d9 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -3222,12 +3222,16 @@ vfs_cache_lookup(struct vop_lookup_args *ap)
/* Implementation of the getcwd syscall. */
int
sys___getcwd(struct thread *td, struct __getcwd_args *uap)
+{
+ return (kern___getcwd(td, uap->buf, uap->buflen));
+}
+
+int
+kern___getcwd(struct thread *td, char *ubuf, size_t buflen)
{
char *buf, *retbuf;
- size_t buflen;
int error;
- buflen = uap->buflen;
if (__predict_false(buflen < 2))
return (EINVAL);
if (buflen > MAXPATHLEN)
@@ -3236,7 +3240,7 @@ sys___getcwd(struct thread *td, struct __getcwd_args *uap)
buf = uma_zalloc(namei_zone, M_WAITOK);
error = vn_getcwd(buf, &retbuf, &buflen);
if (error == 0)
- error = copyout(retbuf, uap->buf, buflen);
+ error = copyout(retbuf, ubuf, buflen);
uma_zfree(namei_zone, buf);
return (error);
}
@@ -3277,7 +3281,7 @@ vn_getcwd(char *buf, char **retbuf, size_t *buflen)
* walk in userspace. Moreover, the path we return is inaccessible if the
* calling thread lacks permission to traverse "quux".
*/
-static int
+int
kern___realpathat(struct thread *td, int fd, const char *path, char *buf,
size_t size, int flags, enum uio_seg pathseg)
{
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 2f65eb2aaed4..df354fda9dc7 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -137,13 +137,14 @@ int kern___acl_set_path(struct thread *td, const char *path,
__acl_type_t type, const struct acl *aclp, int follow);
int kern___cap_rights_get(struct thread *td, int version, int fd,
cap_rights_t *rightsp);
-int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg,
- size_t buflen, size_t path_max);
+int kern___getcwd(struct thread *td, char *buf, size_t buflen);
int kern___mac_get_fd(struct thread *td, int fd, void *mac_p);
int kern___mac_get_pid(struct thread *td, pid_t pid, void *mac_p);
int kern___mac_get_proc(struct thread *td, void *mac_p);
int kern___mac_set_fd(struct thread *td, int fd, void *mac_p);
int kern___mac_set_proc(struct thread *td, void *mac_p);
+int kern___realpathat(struct thread *td, int fd, const char *path,
+ char *buf, size_t size, int flags, enum uio_seg pathseg);
int kern_abort2(struct thread *td, const char *why, int nargs,
void **uargs);
int kern_accept(struct thread *td, int s, struct sockaddr *sa,