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