From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/unistd/fchdir.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/unistd/fchdir.c (limited to 'src/unistd/fchdir.c') diff --git a/src/unistd/fchdir.c b/src/unistd/fchdir.c new file mode 100644 index 0000000..dee45ba --- /dev/null +++ b/src/unistd/fchdir.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include "syscall.h" + +int fchdir(int fd) +{ + int ret = __syscall(SYS_fchdir, fd); + if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0) + return __syscall_ret(ret); + + char buf[15+3*sizeof(int)]; + __procfdname(buf, fd); + return syscall(SYS_chdir, buf); +} -- cgit v1.2.3