about summary refs log tree commit diff
path: root/src/stat
Commit message (Collapse)AuthorAgeFilesLines
* remove spurious inclusion of libc.h for LFS64 ABI aliasesRich Felker2018-09-126-18/+12
| | | | | | 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.
* reduce spurious inclusion of libc.hRich Felker2018-09-121-1/+0
| | | | | | | | | | | | | | | | | | | | | libc.h was intended to be a header for access to global libc state and related interfaces, but ended up included all over the place because it was the way to get the weak_alias macro. most of the inclusions removed here are places where weak_alias was needed. a few were recently introduced for hidden. some go all the way back to when libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented) cancellation points had to include it. remaining spurious users are mostly callers of the LOCK/UNLOCK macros and files that use the LFS64 macro to define the awful *64 aliases. in a few places, new inclusion of libc.h is added because several internal headers no longer implicitly include libc.h. declarations for __lockfile and __unlockfile are moved from libc.h to stdio_impl.h so that the latter does not need libc.h. putting them in libc.h made no sense at all, since the macros in stdio_impl.h are needed to use them correctly anyway.
* remove or make static various unused __-prefixed symbolsRich Felker2018-09-121-2/+2
|
* move and deduplicate declarations of __procfdname to make it checkableRich Felker2018-09-123-6/+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.
* fix failure of fchmodat to report EOPNOTSUPP in the race pathRich Felker2015-02-051-2/+4
| | | | | | | in the case where a non-symlink file was replaced by a symlink during the fchmodat operation with AT_SYMLINK_NOFOLLOW, mode change on the new symlink target was successfully suppressed, but the error was not reported. instead, fchmodat simply returned 0.
* fix fd leak race (missing O_CLOEXEC) in fchmodatRich Felker2015-02-041-1/+1
|
* fix missing flags arg to fstatat syscall in fstat fallback pathRich Felker2014-07-181-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.
* add __xmknod and __xmknodat abi-compat functionsRich Felker2014-06-221-0/+10
| | | | | these are put alongside the similar functions for __xstat, etc. in __xstat.c to avoid bloating the number of source files.
* consolidate __xstat abi-compat functions into a single source fileRich Felker2014-06-224-27/+18
| | | | | | | | | | these are mostly intended for use with dynamic linking (although they can also be used statically with object files compiled against glibc headers), so having them broken down into separate source files to optimize for static linking is unlikely to be worth the cost having more files in the source tree (which contributes to libc.a overhead, compile time, link time, ar/linker command line size exhaustion, and so on).
* additional fixes for linux kernel apis with old syscalls removedRich Felker2014-05-301-0/+4
|
* support linux kernel apis (new archs) with old syscalls removedRich Felker2014-05-299-7/+80
| | | | | | | | | | | | | | | | | | | | | | | | such archs are expected to omit definitions of the SYS_* macros for syscalls their kernels lack from arch/$ARCH/bits/syscall.h. the preprocessor is then able to select the an appropriate implementation for affected functions. two basic strategies are used on a case-by-case basis: where the old syscalls correspond to deprecated library-level functions, the deprecated functions have been converted to wrappers for the modern function, and the modern function has fallback code (omitted at the preprocessor level on new archs) to make use of the old syscalls if the new syscall fails with ENOSYS. this also improves functionality on older kernels and eliminates the incentive to program with deprecated library-level functions for the sake of compatibility with older kernels. in other situations where the old syscalls correspond to library-level functions which are not deprecated but merely lack some new features, such as the *at functions, the old syscalls are still used on archs which support them. this may change at some point in the future if or when fallback code is added to the new functions to make them usable (possibly with reduced functionality) on old kernels.
* fix failure of fchmod, fstat, fchdir, and fchown to produce EBADFRich Felker2013-12-192-2/+6
| | | | | | | | | | | | | | | | | | | 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.
* include cleanups: remove unused headers and add feature test macrosSzabolcs Nagy2013-12-123-1/+2
|
* make fchdir, fchmod, fchown, and fstat support O_PATH file descriptorsRich Felker2013-08-022-3/+19
| | | | | | | | | 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.
* debloat code that depends on /proc/self/fd/%d with shared functionRich Felker2013-08-021-1/+3
| | | | | | | I intend to add more Linux workarounds that depend on using these pathnames, and some of them will be in "syscall" functions that, from an anti-bloat standpoint, should not depend on the whole snprintf framework.
* work around linux's lack of flags argument to fchmodat syscallRich Felker2013-08-021-1/+29
| | | | | | | | | | | | | | | | | | | previously, the AT_SYMLINK_NOFOLLOW flag was ignored, giving dangerously incorrect behavior -- the target of the symlink had its modes changed to the modes (usually 0777) intended for the symlink). this issue was amplified by the fact that musl provides lchmod, as a wrapper for fchmodat, which some archival programs take as a sign that symlink modes are supported and thus attempt to use. emulating AT_SYMLINK_NOFOLLOW was a difficult problem, and I originally believed it could not be solved, at least not without depending on kernels newer than 3.5.x or so where O_PATH works halfway well. however, it turns out that accessing O_PATH file descriptors via their pseudo-symlink entries in /proc/self/fd works much better than trying to use the fd directly, and works even on older kernels. moreover, the kernel has permanently pegged these references to the inode obtained by the O_PATH open, so there should not be race conditions with the file being moved, deleted, replaced, etc.
* improve [f]stat[v]fs functions, and possibly work around old kernelsRich Felker2013-07-191-2/+5
| | | | | | | | | | | | | | | | | the main aim of this patch is to ensure that if not all fields are filled in, they contain zeros, so as not to confuse applications. reportedly some older kernels, including commonly used openvz kernels, lack the f_flags field, resulting in applications reading random junk as the mount flags; the common symptom seems to be wrongly considering the filesystem to be mounted read-only and refusing to operate. glibc has some amazingly ugly fallback code to get the mount flags for old kernels, but having them really is not that important anyway; what matters most is not presenting incorrect flags to the application. I have also aimed to fill in some fields of statvfs that were previously missing, and added code to explicitly zero the reserved space at the end of the structure, which will make things easier in the future if this space someday needs to be used.
* fix mknod and mknodat to accept large dev_t valuesRich Felker2013-05-162-5/+2
| | | | | | | | support for these was recently added to sysmacros.h. note that the syscall argument is a long, despite dev_t being 64-bit, so on 32-bit archs the high bits will be lost. it appears the high bits are just glibc silliness and not part of the kernel api, anyway, but it's nice that we have them there for future expansion if needed.
* add obsolete futimesat()rofl0r2012-12-061-0/+9
| | | | | | this function is obsolete, however it's available as a syscall and as such qemu userspace emulation tries to forward it to the host kernel.
* use restrict everywhere it's required by c99 and/or posix 2008Rich Felker2012-09-064-4/+4
| | | | | | | | 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.
* add LSB ABI __xstat, etc. junkRich Felker2012-05-314-0/+36
|
* fix statvfs.c to match new fsid_t definitionRich Felker2011-09-201-1/+1
|
* fix the definition of struct statvfs to match lsb abiRich Felker2011-09-192-19/+46
| | | | | at the same time, make struct statfs match the traditional definition and make it more useful, especially the fsid_t stuff.
* fix (hopefully) statvfs breakage on x86_64 that resulted from fixing i386...Rich Felker2011-04-052-2/+10
|
* fix statvfs syscalls (missing size argument)Rich Felker2011-04-032-2/+2
|
* global cleanup to use the new syscall interfaceRich Felker2011-03-2015-15/+15
|
* implement futimens and utimensatRich Felker2011-02-272-0/+13
|
* add portable lchown (trivial to support and a few ancient things want it..)Rich Felker2011-02-171-0/+7
|
* finish moving 32-bit-specific junk out of source files.Rich Felker2011-02-156-6/+6
|
* initial check-in, version 0.5.0 v0.5.0Rich Felker2011-02-1216-0/+137