]>
Commit | Line | Data |
---|---|---|
ad845c0b | 1 | /* lxstat64 using Linux lstat64 system call. |
6d7e8eda | 2 | Copyright (C) 1991-2023 Free Software Foundation, Inc. |
4cca6b86 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
4cca6b86 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
4cca6b86 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
4cca6b86 | 18 | |
4f40e6ad | 19 | #define __lxstat __redirect___lxstat |
9756dfe1 | 20 | #include <sys/stat.h> |
4f40e6ad AZ |
21 | #undef __lxstat |
22 | #include <fcntl.h> | |
9756dfe1 | 23 | #include <kernel_stat.h> |
0dee6738 | 24 | #include <sysdep.h> |
4f40e6ad AZ |
25 | #include <xstatconv.h> |
26 | #include <statx_cp.h> | |
20b39d59 AZ |
27 | #include <shlib-compat.h> |
28 | ||
46c1c765 | 29 | #if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33) |
4bbb61e4 | 30 | |
9756dfe1 | 31 | /* Get information about the file NAME in BUF. */ |
4f40e6ad | 32 | |
9756dfe1 | 33 | int |
56ddf355 | 34 | ___lxstat64 (int vers, const char *name, struct stat64 *buf) |
9756dfe1 | 35 | { |
4f40e6ad AZ |
36 | #if XSTAT_IS_XSTAT64 |
37 | # ifdef __NR_lstat64 | |
38 | /* 64-bit kABI outlier, e.g. sparc64. */ | |
39 | if (vers == _STAT_VER_KERNEL) | |
40 | return INLINE_SYSCALL_CALL (lstat, name, buf); | |
41 | else | |
42 | { | |
43 | struct stat64 st64; | |
44 | int r = INLINE_SYSCALL_CALL (lstat64, name, &st64); | |
45 | return r ?: __xstat32_conv (vers, &st64, (struct stat *) buf); | |
46 | } | |
47 | # elif defined __NR_lstat | |
48 | /* Old 64-bit kABI, e.g. ia64, powerpc64*, s390x, and x86_64. */ | |
49 | if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX) | |
50 | return INLINE_SYSCALL_CALL (lstat, name, buf); | |
51 | # elif defined __NR_newfstatat | |
52 | /* New kABIs which uses generic 64-bit Linux ABI, e.g. aarch64, riscv64. */ | |
53 | if (vers == _STAT_VER_KERNEL) | |
54 | return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf, | |
55 | AT_SYMLINK_NOFOLLOW); | |
56 | # else | |
57 | /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */ | |
58 | if (vers == _STAT_VER_KERNEL) | |
59 | { | |
60 | struct statx tmp; | |
61 | int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name, | |
62 | AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW, | |
63 | STATX_BASIC_STATS, &tmp); | |
64 | if (r == 0) | |
65 | __cp_stat64_statx (buf, &tmp); | |
66 | return r; | |
67 | } | |
68 | # endif | |
69 | #else | |
70 | # if STAT_IS_KERNEL_STAT | |
71 | /* New kABIs which uses generic pre 64-bit time Linux ABI, | |
72 | e.g. csky, nios2 */ | |
73 | if (vers == _STAT_VER_KERNEL) | |
74 | return INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf, | |
75 | AT_SYMLINK_NOFOLLOW); | |
76 | # else | |
77 | /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, | |
78 | microblaze, s390, sh, mips32, powerpc32, and sparc32. */ | |
79 | return INLINE_SYSCALL_CALL (lstat64, name, buf); | |
80 | # endif /* STAT_IS_KERNEL_STAT */ | |
81 | #endif /* XSTAT_IS_XSTAT64 */ | |
82 | ||
83 | return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); | |
9756dfe1 | 84 | } |
56ddf355 | 85 | |
ce460d04 | 86 | #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) |
22edf4d4 | 87 | versioned_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2); |
56ddf355 UD |
88 | strong_alias (___lxstat64, __old__lxstat64) |
89 | compat_symbol (libc, __old__lxstat64, __lxstat64, GLIBC_2_1); | |
fb23eb25 UD |
90 | #else |
91 | strong_alias (___lxstat64, __lxstat64); | |
56ddf355 | 92 | #endif |
20b39d59 AZ |
93 | |
94 | #if XSTAT_IS_XSTAT64 | |
22edf4d4 | 95 | strong_alias (___lxstat64,__lxstat) |
20b39d59 AZ |
96 | #endif |
97 | ||
46c1c765 | 98 | #endif /* LIB_COMPAT */ |