OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / uClibc / 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 #include <sys/syscall.h>
11 #include <unistd.h>
12 #include <sys/stat.h>
13 #include "xstatconv.h"
14
15 int fstat(int fd, struct stat *buf)
16 {
17         int result;
18 #ifdef __NR_fstat64
19         /* normal stat call has limited values for various stat elements
20          * e.g. uid device major/minor etc.
21          * so we use 64 variant if available
22          * in order to get newer versions of stat elements
23          */
24         struct kernel_stat64 kbuf;
25         result = INLINE_SYSCALL(fstat64, 2, fd, &kbuf);
26         if (result == 0) {
27                 __xstat32_conv(&kbuf, buf);
28         }
29 #else
30         struct kernel_stat kbuf;
31
32         result = INLINE_SYSCALL(fstat, 2, fd, &kbuf);
33         if (result == 0) {
34                 __xstat_conv(&kbuf, buf);
35         }
36 #endif
37         return result;
38 }
39 libc_hidden_def(fstat)
40
41 #if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
42 strong_alias_untyped(fstat,fstat64)
43 libc_hidden_def(fstat64)
44 #endif