]> sourceware.org Git - glibc.git/blame - sysdeps/unix/sysv/linux/fxstat64.c
Avoid uninitialized result in sem_open when file does not exist
[glibc.git] / sysdeps / unix / sysv / linux / fxstat64.c
CommitLineData
6bbfc5c0 1/* fxstat64 using Linux fstat64/statx system call.
dff8da6b 2 Copyright (C) 1997-2024 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
5febe6a3 19#define __fxstat __redirect___fxstat
9756dfe1 20#include <sys/stat.h>
5febe6a3
AZ
21#undef __fxstat
22#include <fcntl.h>
9756dfe1 23#include <kernel_stat.h>
0dee6738 24#include <sysdep.h>
5febe6a3 25#include <xstatconv.h>
6bbfc5c0 26#include <statx_cp.h>
20b39d59
AZ
27#include <shlib-compat.h>
28
46c1c765 29#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
0dee6738 30
9756dfe1 31/* Get information about the file FD in BUF. */
56ddf355 32
9756dfe1 33int
56ddf355 34___fxstat64 (int vers, int fd, struct stat64 *buf)
9756dfe1 35{
5febe6a3
AZ
36#if XSTAT_IS_XSTAT64
37# ifdef __NR_fstat64
38 /* 64-bit kABI outlier, e.g. sparc64. */
39 if (vers == _STAT_VER_KERNEL)
40 return INLINE_SYSCALL_CALL (fstat, fd, buf);
41 else
42 {
43 struct stat64 st64;
44 int r = INLINE_SYSCALL_CALL (fstat64, fd, &st64);
45 return r ?: __xstat32_conv (vers, &st64, (struct stat *) buf);
46 }
47# elif defined __NR_fstat
460860f4 48 /* 64-bit kABI, e.g. aarch64, powerpc64*, s390x, riscv64,
5febe6a3
AZ
49 and x86_64. */
50 if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
51 return INLINE_SYSCALL_CALL (fstat, fd, buf);
52 return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
53# else
54 /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */
6bbfc5c0 55 struct statx tmp;
5febe6a3
AZ
56 int r = INLINE_SYSCALL_CALL (statx, fd, "", AT_EMPTY_PATH,
57 STATX_BASIC_STATS, &tmp);
58 if (r == 0)
6bbfc5c0 59 __cp_stat64_statx (buf, &tmp);
5febe6a3
AZ
60 return r;
61# endif
62#else
63 /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa, m68k,
64 microblaze, mips32, nios2, sh, powerpc32, and sparc32. */
65 return INLINE_SYSCALL_CALL (fstat64, fd, buf);
66#endif /* XSTAT_IS_XSTAT64 */
9756dfe1 67}
56ddf355 68
ce460d04 69#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
22edf4d4 70versioned_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
56ddf355
UD
71strong_alias (___fxstat64, __old__fxstat64)
72compat_symbol (libc, __old__fxstat64, __fxstat64, GLIBC_2_1);
fb23eb25 73#else
ce460d04 74strong_alias (___fxstat64, __fxstat64)
56ddf355 75#endif
5febe6a3
AZ
76
77#if XSTAT_IS_XSTAT64
22edf4d4 78strong_alias (___fxstat64, __fxstat)
5febe6a3 79#endif
20b39d59 80
46c1c765 81#endif /* LIB_COMPAT */
This page took 0.905842 seconds and 6 git commands to generate.