Commit Graph

37 Commits

Author SHA1 Message Date
Jonathan Neuschäfer 4b125dd408 fix POSIX_FADV_DONTNEED/_NOREUSE on s390x
On s390x, POSIX_FADV_DONTNEED and POSIX_FADV_NOREUSE have different
values than on all other architectures that Linux supports.

Handle this difference by wrapping their definitions in
include/fcntl.h in #ifdef, so that arch/s390x/bits/fcntl.h can
override them.
2019-03-13 11:37:29 -04:00
Khem Raj 7d7f44253f define MAX_HANDLE_SZ for use with name_to_handle_at
MAX_HANDLE_SZ is described in name_to_handle_at() to contain maximum
expected size for a file handle
2018-09-13 11:46:46 -04:00
Khem Raj 3e14bbcd19 wireup linux/name_to_handle_at and name_to_handle_at syscalls 2018-09-12 21:28:39 -04:00
Szabolcs Nagy 14ced22830 add new fcntl.h macros from linux v4.13
for getting/setting write lifetime hints fcntl commands were
added in linux commit c75b1d9421f80f4143e389d2d50ddfc8a28c8c35

added under _GNU_SOURCE || _BSD_SOURCE, since RWH_* life time
hints are not in the POSIX reserved namespace.
2017-11-05 18:41:24 -05:00
Duncan Overbruck c1f4ed1501 fix FFSYNC by changing it to O_SYNC
O_FSYNC was never defined and is legacy/wrong, nothing seems to use it.
2016-08-30 16:01:47 -04:00
Rich Felker befa5866ee make brace placement in public header struct definitions consistent
placing the opening brace on the same line as the struct keyword/tag
is the style I prefer and seems to be the prevailing practice in more
recent additions.

these changes were generated by the command:

find include/ arch/*/bits -name '*.h' \
-exec sed -i '/^struct [^;{]*$/{N;s/\n/ /;}' {} +

and subsequently checked by hand to ensure that the regex did not pick
up any false positives.
2016-07-03 15:02:25 -04:00
Rich Felker fd427c4eae move O_PATH definition back to arch bits
while it's the same for all presently supported archs, it differs at
least on sparc, and conceptually it's no less arch-specific than the
other O_* macros. O_SEARCH and O_EXEC are still defined in terms of
O_PATH in the main fcntl.h.
2015-04-01 19:31:06 -04:00
Szabolcs Nagy a3763d64e0 add new linux file sealing api to fcntl.h
new in linux v3.17 commit 40e041a2c858b3caefc757e26cb85bfceae5062b
sealing allows some operations to be blocked on a file which makes
file access safer when fds are shared between processes (only
supported for shared mem fds currently)

flags:
F_SEAL_SEAL prevents further sealing
F_SEAL_SHRINK prevents file from shrinking
F_SEAL_GROW prevents file from growing
F_SEAL_WRITE prevents writes

fcntl commands:
F_GET_SEALS get the current seal flags
F_ADD_SEALS add new seal flags
2014-10-08 11:39:28 -04:00
Szabolcs Nagy 976bb28fa0 add new F_OFD_* macros to fcntl.h (open file description locks)
open file description locks are inherited across fork and only auto
dropped after the last fd of the file description is closed, they can be
used to synchronize between threads that open separate file descriptions
for the same file.

new in linux 3.15 commit 0d3f7a2dd2f5cf9642982515e020c1aee2cf7af6
2014-09-08 15:35:26 +02:00
Rich Felker fdb3efa5dd add flock64 alias for (struct) flock in fcntl.h
this was a missing part of the LFS64 API; it's "needed" for use with
fcntl and the corresponding lock commands.
2014-02-18 11:04:15 -05:00
Rich Felker 1e7a581ad6 add some missing LFS64 aliases for fadvise/fallocate functions 2014-01-06 21:31:17 -05:00
Rich Felker 8f0359605a fix multiple minor namespace issues in headers
fcntl.h: AT_* is not a reserved namespace so extensions cannot be
exposed by default.

langinfo.h: YESSTR and NOSTR were removed from the standard.

limits.h: NL_NMAX was removed from the standard.

signal.h: the conditional for NSIG was wrongly checking _XOPEN_SOURCE
rather than _BSD_SOURCE. this was purely a mistake; it doesn't even
match the commit message from the commit that added it.
2013-10-20 22:01:51 -04:00
Rich Felker 14012b91f2 add some new linux AT_* flags 2013-08-03 03:20:56 -04:00
Rich Felker 78c6d30fd3 provide useless 64-bit fcntl macros with _LARGEFILE64_SOURCE
this is all useless but part of the API, which is part of the
_GNU_SOURCE API, so something may need them.
2013-08-02 10:00:09 -04:00
rofl0r e00e07f664 fix F_DUPFD_CLOEXEC being defined twice 2012-12-06 22:45:56 +01:00
rofl0r e34d967c3e fixup for fcntl.h changes 2012-12-06 21:43:00 +01:00
rofl0r 120e402de6 fcntl.h: add some linux-specific F_ macros
thankfully these are all generic across archs.
the DN_ macros are for usage with F_NOTIFY.
2012-12-06 17:48:16 +01:00
rofl0r 8d2887f884 fcntl.h: O_SEARCH was missing for powerpc
put some macros that do not differ between architectures in the
main header and remove from bits.
restructure mips header so it has the same structure as the others.
2012-11-18 05:14:40 +01:00
Rich Felker 5a1abeeb7c fix stupid bug in updating of O_ACCMODE for O_SEARCH support
this could cause major bugs, and warrants a fix release right away.
2012-09-15 23:17:00 -04:00
Rich Felker b238b37a0f add O_PATH/O_SEARCH support to fcntl.h
I'm not 100% sure that Linux's O_PATH meets the POSIX requirements for
O_SEARCH, but it seems very close if not perfect. and old kernels
ignore it, so O_SEARCH will still work as desired as long as the
caller has read permissions to the directory.
2012-09-13 20:56:25 -04:00
Rich Felker 997ba92a0f add linux tee syscall 2012-09-08 01:03:01 -04:00
Rich Felker 00e6bbcc05 add linux sync_file_range syscall 2012-09-08 00:58:25 -04:00
Rich Felker 90f770523f add linux readahead syscall 2012-09-08 00:40:37 -04:00
Rich Felker adb88e773b add fallocate (nonstandardized) function
this is equivalent to posix_fallocate except that it has an extra
mode/flags argument to control its behavior, and stores the error in
errno rather than returning an error code.
2012-09-08 00:33:04 -04:00
Rich Felker c1a9658bd1 default features: make musl usable without feature test macros
the old behavior of exposing nothing except plain ISO C can be
obtained by defining __STRICT_ANSI__ or using a compiler option (such
as -std=c99) that predefines it. the new default featureset is POSIX
with XSI plus _BSD_SOURCE. any explicit feature test macros will
inhibit the default.

installation docs have also been updated to reflect this change.
2012-09-07 23:13:55 -04:00
Rich Felker c4ea0e3f8e provide loff_t for splice syscall
so far, this is the only actual use of loff_t i've found. some
software, including glib, assumes loff_t must exist if splice exists;
this is a reasonable assumption since the official prototype for
splice uses loff_t, as it always works with 64-bit offsets regardless
of the selected libc off_t size. i'm using #define for now rather than
a typedef to make it easy to define in other headers if necessary
(like the LFS64 ugliness), but it may be necessary to add it to
alltypes.h eventually if other functions end up needing it.
2012-09-06 23:49:44 -04:00
Rich Felker 53147f902b add splice and vmsplice syscalls
based on patches by orc and Isaac Dunham.
2012-07-23 16:50:56 -04:00
Rich Felker 4e8b0938d9 proper error handling for fcntl F_GETOWN on modern kernels
on old kernels, there's no way to detect errors; we must assume
negative syscall return values are pgrp ids. but if the F_GETOWN_EX
fcntl works, we can get a reliable answer.
2012-06-20 22:16:47 -04:00
Rich Felker 3b94daba71 _GNU_SOURCE is supposed to imply _LARGEFILE64_SOURCE
this is ugly and stupid, but now that the *64 symbol names exist, a
lot of broken GNU software detects them in configure, then either
breaks during build due to missing off64_t definition, or attempts to
compile without function declarations/prototypes. "fixing" it here is
easier than telling everyone to add yet another feature test macro to
their builds.
2012-06-04 08:03:56 -04:00
Rich Felker 671ffab776 various header cleanups, some related to _BSD_SOURCE addition
there is no reason to avoid multiple identical macro definitions; this
is perfectly legal C, and even with the maximal warning options
enabled, gcc does not issue any warning for it.
2012-05-22 22:04:55 -04:00
Rich Felker 419ae6d5c9 support _BSD_SOURCE feature test macro
patch by Isaac Dunham. matched closely (maybe not exact) to glibc's
idea of what _BSD_SOURCE should make visible.
2012-05-22 21:52:08 -04:00
Rich Felker 2dd8d5e1b8 add support for ugly *64 functions with _LARGEFILE64_SOURCE
musl does not support legacy 32-bit-off_t whatsoever. off_t is always
64 bit, and correct programs that use off_t and the standard functions
will just work out of the box. (on glibc, they would require
-D_FILE_OFFSET_BITS=64 to work.) however, some programs instead define
_LARGEFILE64_SOURCE and use alternate versions of all the standard
types and functions with "64" appended to their names.

we do not want code to actually get linked against these functions
(it's ugly and inconsistent), so macros are used instead of prototypes
with weak aliases in the library itself. eventually the weak aliases
may be added at the library level for the sake of using code that was
originally built against glibc, but the macros will still be the
desired solution in the headers.
2012-05-04 00:13:23 -04:00
Rich Felker 67b25fe0a8 move F_DUPFD_CLOEXEC out of bits
fcntl values 1024 and up are universal, arch-independent. later I'll
add some of the other linux-specific ones for notify, leases, pipe
size, etc. here too.
2012-04-15 17:05:10 -04:00
Rich Felker a3aa89d826 fix O_SYNC definition, cleanup fcntl.h 2011-04-14 22:06:30 -04:00
Rich Felker c2b18f3531 fcntl.h: move macros that do not vary between archs out of bits 2011-04-14 21:49:22 -04:00
Rich Felker ac12eb91bd fcntl.h should make availabel the mode constants from sys/stat.h
also remove some legacy nonsense that crept in.
2011-03-08 12:35:35 -05:00
Rich Felker 0b44a0315b initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00