1 /*
2 * lstat64() for uClibc
3 *
4 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 *
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 */
8
9 #include <_lfs_64.h>
10 #include <sys/syscall.h>
11 #include <unistd.h>
12 #include <sys/stat.h>
13
14 #if defined __NR_fstatat64 && !defined __NR_lstat && !defined(__UCLIBC_USE_TIME64__)
15 # include <fcntl.h>
16
lstat64(const char * file_name,struct stat64 * buf)17 int lstat64(const char *file_name, struct stat64 *buf)
18 {
19 return fstatat64(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
20 }
21 libc_hidden_def(lstat64)
22
23 #elif __WORDSIZE == 64 && defined __NR_newfstatat
24 # include <fcntl.h>
25
26 int lstat64(const char *file_name, struct stat64 *buf)
27 {
28 return fstatat64(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
29 }
30 libc_hidden_def(lstat64)
31
32 #elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__
33 # include <fcntl.h>
34 # include <statx_cp.h>
35
36 int lstat64(const char *file_name, struct stat64 *buf)
37 {
38 struct statx tmp;
39 int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, file_name,
40 AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
41 STATX_BASIC_STATS, &tmp);
42 if (rc == 0)
43 __cp_stat64_statx ((struct stat64 *)buf, &tmp);
44
45 return rc;
46 }
47 libc_hidden_def(lstat64)
48
49 /* For systems which have both, prefer the old one */
50 #elif defined __NR_lstat64
51 # include "xstatconv.h"
52 # define __NR___syscall_lstat64 __NR_lstat64
53 static __always_inline _syscall2(int, __syscall_lstat64, const char *, file_name,
54 struct kernel_stat64 *, buf)
55
56 int lstat64(const char *file_name, struct stat64 *buf)
57 {
58 int result;
59 struct kernel_stat64 kbuf;
60
61 result = __syscall_lstat64(file_name, &kbuf);
62 if (result == 0) {
63 __xstat64_conv(&kbuf, buf);
64 }
65 return result;
66 }
67 libc_hidden_def(lstat64)
68 #endif
69