OSDN Git Service

34a6e7b46f6921537ad2398c160ea185762624a0
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / fstat.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * fstat() for uClibc
4  *
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9
10 /* need to hide the 64bit prototype or the strong_alias()
11  * will fail when __NR_fstat64 doesnt exist */
12 #define fstat64 __hidefstat64
13
14 #include <sys/syscall.h>
15 #include <unistd.h>
16 #include <sys/stat.h>
17 #include "xstatconv.h"
18
19 #undef fstat64
20
21 /* libc_hidden_proto(fstat) */
22
23 #define __NR___syscall_fstat __NR_fstat
24 static __inline__ _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf)
25
26 int fstat(int fd, struct stat *buf)
27 {
28         int result;
29         struct kernel_stat kbuf;
30
31         result = __syscall_fstat(fd, &kbuf);
32         if (result == 0) {
33                 __xstat_conv(&kbuf, buf);
34         }
35         return result;
36 }
37 libc_hidden_def(fstat)
38
39 #if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
40 extern __typeof(fstat) fstat64;
41 libc_hidden_proto(fstat64)
42 strong_alias(fstat,fstat64)
43 libc_hidden_def(fstat64)
44 #endif