X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Funistd%2Ffchdir.c;h=dee45ba68e6425a17fe2ef4f4b77038666e43d80;hb=d59e504279abd3f613c2305a65fb16936f7b07f1;hp=b2acbc29197cbc7e8cee34266736781d1cb8e4de;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/unistd/fchdir.c b/src/unistd/fchdir.c index b2acbc29..dee45ba6 100644 --- a/src/unistd/fchdir.c +++ b/src/unistd/fchdir.c @@ -1,7 +1,15 @@ #include +#include +#include #include "syscall.h" int fchdir(int fd) { - return syscall1(__NR_fchdir, 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); }