Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bsd-user: Implement do_freebsd_realpathat syscall
Signed-off-by: Mikaël Urankar <mikael.urankar@gmail.com>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
  • Loading branch information
Mikaël Urankar authored and bsdimp committed Aug 28, 2023
1 parent 292f00c commit 292bfd0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bsd-user/freebsd/os-stat.h
Expand Up @@ -634,4 +634,30 @@ static inline abi_long do_freebsd_fcntl(abi_long arg1, abi_long arg2,
return ret;
}

#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300080
extern int __realpathat(int fd, const char *path, char *buf, size_t size,
int flags);
/* https://svnweb.freebsd.org/base?view=revision&revision=358172 */
/* no man page */
static inline abi_long do_freebsd_realpathat(abi_long arg1, abi_long arg2,
abi_long arg3, abi_long arg4, abi_long arg5)
{
abi_long ret;
void *p, *b;

LOCK_PATH(p, arg2);
b = lock_user(VERIFY_WRITE, arg3, arg4, 0);
if (b == NULL) {
UNLOCK_PATH(p, arg2);
return -TARGET_EFAULT;
}

ret = get_errno(__realpathat(arg1, p, b, arg4, arg5));
UNLOCK_PATH(p, arg2);
unlock_user(b, arg3, ret);

return ret;
}
#endif

#endif /* BSD_USER_FREEBSD_OS_STAT_H */

0 comments on commit 292bfd0

Please sign in to comment.