]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/stat.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / stat.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * stat() 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
14 #undef stat
15
16 #if defined __NR_fstatat64 && !defined __NR_stat
17 # include <fcntl.h>
18
19 int stat(const char *file_name, struct stat *buf)
20 {
21         return fstatat(AT_FDCWD, file_name, buf, 0);
22 }
23
24 #else
25 # include "xstatconv.h"
26
27 int stat(const char *file_name, struct stat *buf)
28 {
29         int result;
30 # ifdef __NR_stat64
31         /* normal stat call has limited values for various stat elements
32          * e.g. uid device major/minor etc.
33          * so we use 64 variant if available
34          * in order to get newer versions of stat elements
35          */
36         struct kernel_stat64 kbuf;
37         result = INLINE_SYSCALL(stat64, 2, file_name, &kbuf);
38         if (result == 0) {
39                 __xstat32_conv(&kbuf, buf);
40         }
41 # else
42         struct kernel_stat kbuf;
43
44         result = INLINE_SYSCALL(stat, 2, file_name, &kbuf);
45         if (result == 0) {
46                 __xstat_conv(&kbuf, buf);
47         }
48 # endif /* __NR_stat64 */
49         return result;
50 }
51 #endif /* __NR_fstat64 */
52 libc_hidden_def(stat)
53
54 #if ! defined __NR_stat64 && ! defined __NR_fstatat64 && \
55         defined __UCLIBC_HAS_LFS__
56 strong_alias_untyped(stat,stat64)
57 libc_hidden_def(stat64)
58 #endif