add experimental aarch64 support
[uclibc-ng.git] / libc / sysdeps / linux / common / lstat.c
blobcef9b463d5f5f23da2958339b2d99b16236dfdcb
1 /* vi: set sw=4 ts=4: */
2 /*
3 * lstat() for uClibc
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 */
10 #include <sys/syscall.h>
11 #include <unistd.h>
12 #include <sys/stat.h>
14 #if defined __NR_fstatat64 && !defined __NR_lstat
15 # include <fcntl.h>
17 int lstat(const char *file_name, struct stat *buf)
19 return fstatat(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
21 libc_hidden_def(lstat)
23 #elif __WORDSIZE == 64 && defined __NR_newfstatat
24 # include <fcntl.h>
26 int lstat(const char *file_name, struct stat *buf)
28 return fstatat(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
30 libc_hidden_def(lstat)
32 /* For systems which have both, prefer the old one */
33 #else
34 # include "xstatconv.h"
35 int lstat(const char *file_name, struct stat *buf)
37 int result;
38 # ifdef __NR_lstat64
39 /* normal stat call has limited values for various stat elements
40 * e.g. uid device major/minor etc.
41 * so we use 64 variant if available
42 * in order to get newer versions of stat elements
44 struct kernel_stat64 kbuf;
45 result = INLINE_SYSCALL(lstat64, 2, file_name, &kbuf);
46 if (result == 0) {
47 __xstat32_conv(&kbuf, buf);
49 # else
50 struct kernel_stat kbuf;
52 result = INLINE_SYSCALL(lstat, 2, file_name, &kbuf);
53 if (result == 0) {
54 __xstat_conv(&kbuf, buf);
56 # endif /* __NR_lstat64 */
57 return result;
59 libc_hidden_def(lstat)
61 # if ! defined __NR_fstatat64 && ! defined __NR_lstat64
62 strong_alias_untyped(lstat,lstat64)
63 libc_hidden_def(lstat64)
64 # endif
66 #endif /* __NR_fstatat64 */