summaryrefslogtreecommitdiff
path: root/src/stat/fstatat.c
AgeCommit message (Collapse)AuthorLines
2023-11-06pass AT_NO_AUTOMOUNT when emulating fstatat via statxAlexey Izbyshev-0/+1
AT_NO_AUTOMOUNT is implied for stat/lstat/fstatat syscalls since Linux 3.1 (commit b6c8069d3577481390b3f24a8434ad72a3235594). However, this is not the case for statx syscall, which defaults to automounting, so this flag must be passed explicitly when statx is used to implement stat-like functions. This change affects only arches which use 32-bit seconds in struct kstat, as well as out-of-tree/future ports to arches which lack SYS_fstatat.
2022-10-19remove LFS64 symbol aliases; replace with dynamic linker remappingRich Felker-4/+0
originally the namespace-infringing "large file support" interfaces were included as part of glibc-ABI-compat, with the intent that they not be used for linking, since our off_t is and always has been unconditionally 64-bit and since we usually do not aim to support nonstandard interfaces when there is an equivalent standard interface. unfortunately, having the symbols present and available for linking caused configure scripts to detect them and attempt to use them without declarations, producing all the expected ill effects that entails. as a result, commit 2dd8d5e1b8ba1118ff1782e96545cb8a2318592c was made to prevent this, using macros to redirect the LFS64 names to the standard names, conditional on _GNU_SOURCE or _LARGEFILE64_SOURCE. however, this has turned out to be a source of further problems, especially since g++ defines _GNU_SOURCE by default. in particular, the presence of these names as macros breaks a lot of valid code. this commit removes all the LFS64 symbols and replaces them with a mechanism in the dynamic linker symbol lookup failure path to retry with the spurious "64" removed from the symbol name. in the future, if/when the rest of glibc-ABI-compat is moved out of libc, this can be removed.
2022-05-01only use fstatat and others legacy stat syscalls if they existRich Felker-1/+9
riscv32 and future architectures only provide statx.
2022-05-01provide an internal namespace-safe __fstatatRich Felker-1/+3
this makes it so we can drop direct stat syscall use in interfaces that can't use the POSIX namespace.
2019-10-28make fstatat fill in old time32 stat fields tooRich Felker-0/+16
here _REDIR_TIME64 is used as an indication that there's an old ABI, and thereby the old time32 timespec fields of struct stat. keeping struct stat compatible and providing both versions of the timespec fields is done so that ftw/nftw does not need painful compat shims, and (more importantly) so that similar interfaces between pairs of libc consumers (applications/libraries) will be less likely to break when one has been rebuilt for time64 but the other has not.
2019-10-28disable lfs64 aliases for remapped time64 functionsRich Felker-0/+2
these functions cannot provide the glibc lfs64-ABI-compatible symbols when time_t differs from what it was in that ABI. instead, the aliases need to be provided by the time32 compat shims or through some other mechanism.
2019-07-21use the correct stat structure in the fstat pathSamuel Holland-4/+4
commit 01ae3fc6d48f4a45535189b7a6db286535af08ca modified fstatat to translate the kernel's struct stat ("kstat") into the libc struct stat. To do this, it created a local kstat object, and copied its contents into the user-provided object. However, the commit neglected to update the fstat compatibility path and its fallbacks. They continued to pass the user-supplied object to the kernel, later overwiting it with the uninitialized memory in the local temporary.
2019-07-19fix inadvertent introduction of extern object stxRich Felker-1/+1
commit dfc81828f7ab41da08f744c44117a1bb20a05749 accidentally defined an instance of struct statx along with the struct declaration.
2019-07-18implement fstatat with SYS_statx, conditional on undersized kstat timeRich Felker-2/+68
this commit adds a new backend for fstatat (and thereby the whole stat family) using the SYS_statx syscall, but conditions the new code on the kernel stat structure's time fields being smaller than time_t. in principle that should make it all dead code at present, but mips64 has a broken stat structure with 32-bit time fields despite having 64-bit time_t elsewhere, so on mips64 it is a functional change that makes post-Y2038 filesystem timestamps accessible. whenever the 32-bit archs end up getting 64-bit time_t, regardless of how that happens, the changes in this commit will automatically take effect for them too.
2019-07-18decouple struct stat from kernel typeRich Felker-4/+27
presently, all archs/ABIs have struct stat matching the kernel stat[64] type, except mips/mipsn32/mips64 which do conversion hacks in syscall_arch.h to work around bugs in the kernel type. this patch completely decouples them and adds a translation step to the success path of fstatat. at present, this is just a gratuitous copying, but it opens up multiple possibilities for future support for 64-bit time_t on 32-bit archs and for cleaned-up/unified ABIs. for clarity, the mips hacks are not yet removed in this commit, so the mips kstat structs still correspond to the output of the hacks in their syscall_arch.h files, not the raw kernel type. a subsequent commit will fix this.
2019-07-18refactor all stat functions in terms of fstatatRich Felker-2/+33
equivalent logic for fstat+O_PATH fallback and direct use of stat/lstat syscalls where appropriate is kept, now in the fstatat function. this change both improves functionality (now, fstatat forms equivalent to fstat/lstat/stat will work even on kernels too old to have the at functions) and localizes direct interfacing with the kernel stat structure to one file.
2018-09-12remove spurious inclusion of libc.h for LFS64 ABI aliasesRich Felker-2/+1
the LFS64 macro was not self-documenting and barely saved any characters. simply use weak_alias directly so that it's clear what's being done, and doesn't depend on a header to provide a strange macro.
2012-09-06use restrict everywhere it's required by c99 and/or posix 2008Rich Felker-1/+1
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
2011-03-20global cleanup to use the new syscall interfaceRich Felker-1/+1
2011-02-15finish moving 32-bit-specific junk out of source files.Rich Felker-1/+1
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+10