provide an internal namespace-safe __fstat
[musl] / src / stat / fstat.c
index 10228f7..27db0cc 100644 (file)
@@ -1,10 +1,17 @@
+#define _BSD_SOURCE
 #include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
 #include "syscall.h"
-#include "libc.h"
 
-int fstat(int fd, struct stat *buf)
+int __fstat(int fd, struct stat *st)
 {
-       return syscall(SYS_fstat, fd, buf);
+       if (fd<0) return __syscall_ret(-EBADF);
+       return __fstatat(fd, "", st, AT_EMPTY_PATH);
 }
 
-LFS64(fstat);
+weak_alias(__fstat, fstat);
+
+#if !_REDIR_TIME64
+weak_alias(fstat, fstat64);
+#endif