summaryrefslogtreecommitdiff
path: root/src/stat/fstat.c
AgeCommit message (Collapse)AuthorLines
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-04provide an internal namespace-safe __fstatRich Felker-2/+4
this avoids the need for implementation-internal callers to depend on the nonstandard AT_EMPTY_PATH extension to use __fstatat and isolates knowledge of that extension to the implementation of __fstat.
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-18restore property that fstat(AT_FDCWD) fails with EBADFRich Felker-0/+1
AT_FDCWD is not a valid file descriptor, so POSIX requires fstat to fail with EBADF. if passed to fstatat, the call would spuriously succeed and return results for the working directory.
2019-07-18refactor all stat functions in terms of fstatatRich Felker-11/+2
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.
2018-09-12move and deduplicate declarations of __procfdname to make it checkableRich Felker-2/+0
syscall.h was chosen as the header to declare it, since its intended usage is alongside syscalls as a fallback for operations the direct syscall does not support.
2014-07-18fix missing flags arg to fstatat syscall in fstat fallback pathRich Felker-1/+1
this code path is used only on archs without the plain, non-at syscalls, and only when the fstat syscall fails with EBADF on a valid file descriptor. this in turn can happen only for O_PATH file descriptors, and may not happen at all on the newer kernels needed for supporting such archs. with the flags argument omitted, spurious fstat failures may happen when the argument register happens to have the AT_SYMLINK_NOFOLLOW bit set.
2014-05-30additional fixes for linux kernel apis with old syscalls removedRich Felker-0/+4
2013-12-19fix failure of fchmod, fstat, fchdir, and fchown to produce EBADFRich Felker-1/+3
the workaround/fallback code for supporting O_PATH file descriptors when the kernel lacks support for performing these operations on them caused EBADF to get replaced by ENOENT (due to missing entry in /proc/self/fd). this is unlikely to affect real-world code (calls that might yield EBADF are generally unsafe, especially in library code) but it was breaking some test cases. the fix I've applied is something of a tradeoff: it adds one syscall to these operations on kernels where the workaround is needed. the alternative would be to catch ENOENT from the /proc lookup and translate it to EBADF, but I want to avoid doing that in the interest of not touching/depending on /proc at all in these functions as long as the kernel correctly supports the operations. this is following the general principle of isolating hacks to code paths that are taken on broken systems, and keeping the code for correct systems completely hack-free.
2013-08-02make fchdir, fchmod, fchown, and fstat support O_PATH file descriptorsRich Felker-2/+10
on newer kernels, fchdir and fstat work anyway. this same fix should be applied to any other syscalls that are similarly affected. with this change, the current definitions of O_SEARCH and O_EXEC as O_PATH are mostly conforming to POSIX requirements. the main remaining issue is that O_NOFOLLOW has different semantics.
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