Commit Graph

2242 Commits

Author SHA1 Message Date
Torbjørn Birch Moltu 3f62e51d24 Add cr_pid to FreeBSD xucred - an unreleased addition in FreeBSD 13
definition: https://svnweb.freebsd.org/base/head/sys/sys/ucred.h?view=markup#l85
manpage: https://www.freebsd.org/cgi/man.cgi?query=unix&sektion=0&manpath=FreeBSD+13-current&format=html

Continue comparing and hashing __cr_unused1 for backwards compatibility.
2021-03-08 19:37:01 +01:00
Torbjørn Birch Moltu fe4be350a8 Add SO_PEERSEC and SO_PASSSEC for all linux archs and android
SO_PASSSEC and SO_PEERSEC were already added for the most common archs
such as x86_64 and aarch64, but were missing on for example x86.

Sources:
* linux mips: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/mips/include/uapi/asm/socket.h
* linux sparc: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/sparc/include/uapi/asm/socket.h
* other linux: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/socket.h
* android: https://android.googlesource.com/platform/bionic.git/+/refs/heads/master/libc/kernel/uapi/asm-generic/socket.h
2021-03-08 00:10:10 +01:00
Torbjørn Birch Moltu 0f40951415 Add NetBSD unpcbid, LOCAL_PEEREID and other LOCAL_ constants 2021-03-07 21:44:23 +01:00
Torbjørn Birch Moltu adb0a34c87 Add LOCAL_PEERCRED and related to Dragonfly
https://gitweb.dragonflybsd.org/dragonfly.git/blob/cd4ac48fd186404370e0b8623530b6add4b70400:/sys/sys/ucred.h#l86

None of the other LOCAL_ constants for FreeBSD are available on Dragonfly:
https://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/sys/un.h
2021-03-07 21:44:17 +01:00
Maarten de Vries b98d5292b8 Re-add accept4 for Android on 32 bit ARM. 2021-03-05 14:54:34 +01:00
TheDoctor314 2de2cb74c8 Add gettid() for Linux and Android
Fixes #2076
2021-03-05 01:45:03 +09:00
bors c334f98ad9 dragonflybsd: expose waitid() prototype + related constants
This exposes the POSIX waitid() process management function and some related defined constants for dragonflybsd. It includes one correction: WSTOPPED which previously had the wrong value. Noticed this when a crate that depended on it, process_control, wouldn't compile on this platform.
2021-03-03 16:18:04 +00:00
Kenta Tada 6be7fa8037 Add definitions for security related MAGIC
Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2021-03-02 18:36:02 +09:00
Yuki Okushi d96c9a2d8e Replace `x86_64-sun-solaris` with `x86_64-pc-solaris` 2021-03-02 16:27:20 +09:00
Kenta Tada bdb1ab7b01 Add definition of SELINUX_MAGIC
Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2021-03-01 21:49:48 +09:00
Yuki Okushi 9f2acfaa53 Fix build for `s390x-unknown-linux-musl` 2021-03-01 04:13:17 +09:00
bors 5fd6540db9 Auto merge of #2071 - kaniini:s390x-musl, r=Amanieu
add definitions for s390x musl targets

Add support for s390x musl targets to libc.

I haven't added CI because I am not familiar with the pipelines, but would be glad to do so if somebody outlines what needs to be done.
2021-02-28 04:14:47 +00:00
Ariadne Conill dbb0e6cce9
musl: s390x: use c_int instead of c_ulong for terminal-related ioctl constants
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2021-02-27 17:36:02 -07:00
Ariadne Conill db9d4cfe1c
musl: s390x: use c_int instead of c_ulong for ioctl constants
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2021-02-27 17:35:22 -07:00
Lucy Phipps 51461b1bbe
use GNU/Linux siginfo_t on Android
needs testing
2021-02-27 17:17:21 +00:00
bors add972649f Auto merge of #2079 - de-vri-es:android-x86-accept4, r=joshtriplett,JohnTitor
Implement accept4 on x86 android with `socketcall` syscall.

Linux x86 kernels before 4.3 only support the `socketcall` syscall rather than individual syscalls for socket operations. Since `libc` does a raw syscall for `accept4` on Android, it doesn't work on x86 systems.

This PR instead implements `accept4` for x86 android using `socketcall`. The value for `SYS_ACCEPT4` (in contrast to `SYS_accept4` 👀) is taken from the `linux/net.h` header.

Also note that the `socketcall` syscall takes all arguments as array of long ints. I've double checked with `glibc` to check how they pass arguments, since the Linux man page only says this: "args points to a block containing the actual arguments" and "only standard library implementors and kernel hackers need to know about socketcall()".

This should fix https://github.com/rust-lang/rust/issues/82400
2021-02-27 13:11:19 +00:00
bors 31a2777d8f Implement accept4 on x86 android with `socketcall` syscall.
Linux x86 kernels before 4.3 only support the `socketcall` syscall rather than individual syscalls for socket operations. Since `libc` does a raw syscall for `accept4` on Android, it doesn't work on x86 systems.

This PR instead implements `accept4` for x86 android using `socketcall`. The value for `SYS_ACCEPT4` (in contrast to `SYS_accept4` 👀) is taken from the `linux/net.h` header.

Also note that the `socketcall` syscall takes all arguments as array of long ints. I've double checked with `glibc` to check how they pass arguments, since the Linux man page only says this: "args points to a block containing the actual arguments" and "only standard library implementors and kernel hackers need to know about socketcall()".

This should fix https://github.com/rust-lang/rust/issues/82400
2021-02-27 13:11:19 +00:00
Jason King 0f8e3d054c Add several IPsec related options 2021-02-27 06:24:22 +00:00
Jason King 5ab626984f Additional solaris fcntl values 2021-02-27 06:14:26 +00:00
bors 83d8c39f54 Auto merge of #2080 - jbit:freebsd-bpf, r=JohnTitor
Add FreeBSD BPF structures

This PR adds BPF structures that are common between [FreeBSD 11](https://github.com/freebsd/freebsd-src/blob/release/11.0.0/sys/net/bpf.h), [FreeBSD 12](https://github.com/freebsd/freebsd-src/blob/release/12.0.0/sys/net/bpf.h), [FreeBSD mainline/13](https://github.com/freebsd/freebsd-src/blob/main/sys/net/bpf.h) and [DragonFlyBSD 5.9](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/v5.9.0/sys/net/bpf.h).

It also fixes the definition of `BPF_ALIGNMENT`, which should be equal to `sizeof(long)`, which is `4` on 32bit FreeBSD.

https://www.freebsd.org/cgi/man.cgi?query=arch&sektion=7
> All supported ABIs can be	divided	into two groups:
> * ILP32: `int`, `long`, `void *` types machine representations all have 4-byte size.
> * LP64: `int` type machine representation uses 4 bytes, while `long` and `void *` are 8 bytes.

I introduced the private `SIZEOF_LONG` const, since I didn't want to introduce a dependency on rust 1.24+ by depending on `libc_const_size_of`.

These changes allow my experimental crate to build on FreeBSD: https://github.com/jbit/powerline
2021-02-26 18:22:44 +00:00
James Lee 4b55c8715c Add BPF structures for FreeBSD 2021-02-25 17:18:07 +11:00
James Lee ed1256a366 Fix BPF_ALIGNMENT for 32bit FreeBSD 2021-02-25 17:17:50 +11:00
Jubilee Young 104154738c Fix mips64-musl ioctl consts to c_int
This arch was overlooked or unspecified in earlier PRs that fixed
c_ulong to c_int for ioctl.h consts for musl, see PR #289, PR #301,
or PR #1097 for such prior art, however these are still args to
fn ioctl on mips64-musl, which is expecting c_ints.

Some numbers acquired casts to reflect the fact the data is being
used and (so should be written as) an unsized bitfield, even if
the value is greater than i32::MAX.
2021-02-23 12:34:04 -08:00
Sean Klein 6873e2f930 Add O_DIRECTORY to solarish 2021-02-16 03:30:57 +00:00
Ariadne Conill 88de3880fb add definitions for s390x musl targets 2021-02-15 22:37:14 +00:00
bors b035574949 Auto merge of #2070 - nielx:haiku-raw-pointers, r=JohnTitor
Haiku: use raw pointers instead of references in convenience functions

The Haiku API has some convenience macros to make it easier to call certain
functions. In the libc implementation, these are implemented as unsafe
functions. The previous choice was to take certain pointer parameters as
references, and do the conversion to raw pointers when the actual external
function was called.

However, this causes issues with the image_info struct, which needs to be
initialized in Rust, before a native API call is used to enter data. Since
part of this structure consists of function pointers, mem::zeroed() cannot be
used, since in Rust function pointers cannot be NULL. Thus one needs to use the
MaybeUnit<T> API to properly initialize it. This then makes it problematic to
use the convenience functions, as a MaybeUnit<image_info> cannot be converted
into an &mut image_info before it is marked as initialized with valid data. It can
be converted into a raw *mut image_info, so if the function accepts this as a
parameter it can be used.

For consistency, all convenience functions have been converted from using
references to using raw pointers.
2021-02-14 07:55:01 +00:00
Jonah Petri 3378f0cebf style fixes to satisfy new rustfmt 2021-02-13 15:04:45 -05:00
Jonah Petri 13090dfcc0 uclibc: fix x86_64-unknown-l4re-uclibc build 2021-02-13 15:04:45 -05:00
Niels Sascha Reedijk 59afbfe9f6 Haiku: use raw pointers instead of references in convenience functions
The Haiku API has some convenience macros to make it easier to call certain
functions. In the libc implementation, these are implemented as unsafe
functions. The previous choice was to take certain pointer parameters as
references, and do the conversion to raw pointers when the actual external
function was called.

However, this causes issues with the image_info struct, which needs to be
initialized in Rust, before a native API call is used to enter data. Since
part of this structure consists of function pointers, mem::zeroed() cannot be
used, since in Rust function pointers cannot be NULL. Thus one needs to use the
MaybeUnit<T> API to properly initialize it. This then makes it problematic to
use the convenience functions, as a MaybeUnit<image_info> cannot be converted
into an &image_info before it is marked as initialized with valid data. It can
be converted into a raw *mut image_info, so if the function accepts this as a
parameter it can be used.

For consistency, all convenience functions have been converted from using
references to using raw pointers.
2021-02-13 11:07:39 +00:00
Jonah Petri 225363b690 move EPOLLEXCLUSIVE and EPOLLWAKEUP to linux/mod.rs 2021-02-12 20:44:53 -05:00
Jonah Petri 0ac10285d9 uclibc: style fixes 2021-02-12 20:43:02 -05:00
Jonah Petri 7775ce20b9 change getnameinfo flags type to int to conform to other libc implementations 2021-02-12 20:43:02 -05:00
Jonah Petri 10c54181b4 uclibc -> linux-like/linux: Manual consolitation of redundant structs and fns. 2021-02-12 20:42:59 -05:00
Jonah Petri fe8470be63 uclibc -> linux-like/linux: mostly mechanical removal of redundant symbols 2021-02-12 20:41:01 -05:00
Jonah Petri c4803a6783 Add ENOTSUP constant for uclibc 2021-02-12 20:41:01 -05:00
bors a61fd8c79c Auto merge of #2066 - wmanley:preadv2-pwritev2, r=JohnTitor
Linux: Add `preadv2` and `pwritev2` and associated constants

These functions are the same as `preadv` and `pwritev` but have a flags
parameter.  `preadv2()` and `pwritev2()` first appeared in Linux 4.6.
Library support was added in glibc 2.26.

See the definition of the constants in [linux/fs.h](fcadab7404/tools/include/uapi/linux/fs.h (L288-L301)).
2021-02-12 05:14:49 +00:00
William Manley ce0eb2321d Move `RWF_*` constants into linux/gnu/mod.rs
From `linux/mod.rs`.  These constants are not exposed by musl so were
causing failures in CI.

These constants are really defined in `include/uapi/linux/fs.h` in Linux
and are not specific to any libc and I hope to make them more available in
the future.
2021-02-11 22:10:32 +00:00
William Manley 01f62b6149 preadv2/pwritev2: Only define these functions with glibc
They're not implemented by musl or bionic.
2021-02-11 14:59:15 +00:00
Max Reitz 5b109dd882 Add mount ID to statx
This corresponds to the Linux commit
fa2fcf4f1df1559a0a4ee0f46915b496cc2ebf60 ("statx: add mount ID").

Note that STATX_ALL is not modified to include this field, because it
has actually been deprecated in Linux and is now effectively defined as
equal to STATX_BASIC_STATS | STATX_BTIME (see Linux commit
581701b7efd60ba13d8a7eed60cbdd7fefaf6696, "uapi: deprecate STATX_ALL").

Because said commit fa2fcf4f1d is less than a year old, skip testing the
STATX_MNT_ID constant.

Signed-off-by: Max Reitz <mreitz@redhat.com>
2021-02-11 14:08:53 +01:00
Max Reitz d6fbe9b85a Make statx's padding fields private
Padding and reserved fields should not be publicly accessible, because
they may be replaced by new (functional) fields at any time.

Searching for these padding fields on github or Google reveals no users,
so making them private should not break any existing users.

It is possible that there are projects outside of github that access
these fields, but if so, they should have been warned by the fact that
these fields are prefixed by double underscores.

Signed-off-by: Max Reitz <mreitz@redhat.com>
2021-02-11 11:24:27 +01:00
William Manley a18aee2068 Linux: Add `preadv2` and `pwritev2` and associated constants
These functions are the same as `preadv` and `pwritev` but have a flags
parameter.  `preadv2()` and `pwritev2()` first appeared in Linux 4.6.
Library support was added in glibc 2.26.
2021-02-11 00:27:53 +00:00
Alexander Batischev 3e4d684dcd
Add bindings for iconv calls
FreeBSD-likes all implement iconv:
- DragonflyBSD: bbb35c81f7/include/iconv.h
- FreeBSD: a6dc68c0e0/include/iconv.h

NetBSD-likes:
- NetBSD: 81a39f6087/include/iconv.h
- OpenBSD doesn't implement it

macOS: apparently ships a conforming implementation as a separate
library:
https://stackoverflow.com/questions/57734434/libiconv-or-iconv-undefined-symbol-on-mac-osx/57734435#57734435

Linux:
- glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=iconv/iconv.h;h=fdddf53d99c3046ef9c280db01a425c2f499043e;hb=HEAD
- musl: https://git.musl-libc.org/cgit/musl/tree/include/iconv.h?id=455f96857f91d14e193219ca00969354a981c09c
2021-02-11 01:22:49 +03:00
Thomas de Zeeuw a8a28adcc2 Add SO_LINGER_SEC on macOS 2021-02-08 13:20:18 +01:00
bors 05cc7961af Auto merge of #2034 - nielx:haiku-native, r=JohnTitor
Haiku: add definitions for the Haiku's native sytem API.

On the Haiku platform, the POSIX (and BSD) API coexists with the native API,
that has its origins on the BeOS platform. Unlike other UNIX-like platforms,
the native API is not an extension of the POSIX API, but instead exists sui
generis, and many of the POSIX concepts have their own native variety, with
relatively limited interoperability.

Nonetheless, the native API coexists in the same library as the standard C and
POSIX functions, namely libroot.so, and therefore this crate is a good place
to add bindings to it.

This commit implements most of Haiku's support kit, the most important parts
of the kernel kit, and a part of the storage kit.
2021-02-08 10:48:13 +00:00
Guillaume Gomez d51b418bfe Add getmntinfo and getmntinfo functions, MNT_WAIT and MNT_NOWAIT constants 2021-02-07 22:47:16 +01:00
Amanieu d'Antras 9d393107c6 Rustfmt 2021-02-01 22:52:54 +00:00
Amanieu d'Antras 60da93f9cc Don't mark time_t as deprecated on musl in rustc build 2021-02-01 22:01:47 +00:00
Alan Somers c070417497 Add aio_readv and aio_writev
They are new in FreeBSD 13.
2021-01-29 16:06:09 -07:00
Alan Somers e3482c13c1 Refactor freebsd to add a new FreeBSD 13 module 2021-01-29 16:05:51 -07:00
Niels Sascha Reedijk 813d7d839b Haiku: fix various issues pointed out by the automated tests
No changes to other platforms.
2021-01-28 14:31:24 +00:00