21 KiB
Changes from 0.38.x to 1.x
Silent behavior changes
rustix::pipe::fcntl_setpipe_size now returns the new size, which may be
greater than the requested size.
When a &mut Vec<_> is passed to rustix::event::epoll::wait,
rustix::event::kqueue::kevent, or rustix::event::port::getn, these
functions previously adjusted the length of the Vec to the number of elements
written, and now do not. A common alternative is to wrap the &mut Vec<_>
using spare_capacity, and then to clear the Vec by iterating using
.drain(..) after each call. For an example of using spare_capacity in this
way, see here.
API changes
rustix::thread::FutexOperation and rustix::thread::futex are removed. Use
the functions in the rustix::thread::futex module instead.
rustix::process::waitpid's return type changed from WaitStatus to
(Pid, WaitStatus), to additionally return the pid of the child.
terminating_signal and other functions in rustix::process::WaitStatus changed
from returning u32 to returning i32, for better compatibility with the new
Signal type and exit.
The SLAVE flag in rustix::mount::MountPropagationFlags is renamed to
DOWNSTREAM.
The "cc" and "libc-extra-traits" features are removed. The "cc" feature hasn't had any effect for several major releases. If you need the traits provided by "libc-extra-traits", you should instead depend on libc directly and enable its "extra_traits" feature.
rustix::net::Shutdown::ReadWrite is renamed to
rustix::net::Shutdown::Both to align with std.
The rustix::io_uring::io_uring_register_files_skip function is replaced with
a IORING_REGISTER_FILES_SKIP constant, similar to the rustix::fs::CWD
constant.
rustix::io_uring::io_uring_register now has a IoringRegisterFlags
argument, and rustix::io_uring::io_uring_register_with is removed.
Several structs in rustix::io_uring are now marked #[non_exhaustive]
because they contain padding or reserved fields. Instead of constructing
them with field values and ..Default::default(), construct them with
Default::default() and separately assign the fields.
rustix::process::Resource, rustix::thread::MembarrierCommand, and
rustix::thread::Capability are now marked #[non_exhaustive] to ease
migration in case new constants are defined in the future.
rustix::process::WaitidOptions and rustix::process::WaitidStatus are
renamed to
rustix::process::WaitIdOptions and rustix::process::WaitIdStatus (note
the capitalization), for consistency with rustix::process::WaitId.
The offsets in rustix::fs::SeekFrom::Hole and
rustix::fs::SeekFrom::Data are changed from i64 to u64, to
align with std, since they represent absolute offsets.
Functions in rustix::net::sockopt are renamed to remove the get_ prefix,
to align with Rust conventions.
rustix::process::sched_* and rustix::process::membarrier_* are moved from
rustix::process to rustix::thread, as they operate on the current
thread rather than the current process.
The udata in rustix::event::kqueue::Event is changed from isize to
*mut c_void to better propagate pointer provenance. To use arbitrary integer
values, convert using the without_provenance_mut and the .addr()
functions.
rustix::mount::mount_recursive_bind is renamed to
rustix::mount::mount_bind_recursive. See this comment for details.
The rustix::procfs is removed. This functionality is now available in the
rustix-linux-procfs crate.
rustix::net::RecvMsgReturn is renamed to rustix::net::RecvMsg.
The flags field of rustix::net::RecvMsg changed type from RecvFlags
to a new ReturnFlags, since it supports a different set of flags.
rustix::event::poll's and rustix::event::epoll's timeout argument
changed from a c_int where -1 means no timeout and non-negative numbers
mean a timeout in milliseconds to an Option<&Timespec>. The Timespec's
fields are tv_sec which holds seconds and tv_nsec which holds nanoseconds.
The timeout argument in rustix::thread::futex::wait,
rustix::thread::futex::lock_pi, rustix::thread::futex::wait_bitset,
rustix::thread::futex::wait_requeue_pi, and
rustix::thread::futex::lock_pi2 changed from Option<Timespec> to
Option<&Timespec>, for consistency with the rest of rustix's API, and for
low-level efficiency, as it means the implementation doesn't need to make a
copy of the Timespec to take its address. An easy way to convert an
Option<Timespec> to an Option<&Timespec> is to use [Option::as_ref`].
Functions in rustix::event::port are renamed to remove the redundant
port_* prefix.
rustix::fs::inotify::InotifyEvent is renamed to
rustix::fs::inotify::Event to remove the redundant prefix.
rustix::fs::StatExt is removed, and the timestamp fields st_atime,
st_mtime, and st_ctime of rustix::fs::Stat may now be accessed
directly. They are now signed instead of unsigned, so that they can represent
times before the epoch.
rustix::io::is_read_write is removed, as it's higher-level functionality that
can be implemented in terms of lower-level rustix calls.
rustix::net::recv and rustix::net::recvfrom now include
the number of received bytes in their return types, as this number may differ
from the number of bytes written to the buffer when
rustix::net::RecvFlags::TRUNC is used.
rustix::process::Signal constants are now upper-cased; for example,
Signal::Int is now named Signal::INT. Also, Signal is no longer
directly convertible to i32; use Signal::as_raw instead.
Signal::from_raw is renamed to Signal::from_named_raw.
The associated constant rustix::ioctl::Ioctl::OPCODE is now replaced with an
associated method rustix::ioctl::Ioctl::opcode, to support ioctls where the
opcode is computed rather than a constant.
The ifindex argument in
rustix::net::sockopt::set_ip_add_membership_with_ifindex and
rustix::net::sockopt::set_ip_drop_membership_with_ifindex
changed from i32 to u32.
The list argument in rustix::fs::listxattr, rustix::fs::flistxattr,
and rustix::fs::llistxattr changed from [c_char], which is [i8] on some
architectures, to [u8].
On NetBSD, the nanoseconds fields of Stat have been renamed, for consistency
with other platforms:
| Old name | New Name |
|---|---|
st_atimensec |
st_atime_nsec |
st_mtimensec |
st_mtime_nsec |
st_ctimensec |
st_ctime_nsec |
st_birthtimensec |
st_birthtime_nsec |
rustix::mount::mount's data argument is now an Option, so it can now
be used in place of mount2, and mount2 is now removed.
The rustix::net functions ending with _v4, _v6, _unix and _xdp have
been merged into a single function that accepts any address type.
Specifically, the following functions are removed:
bind_any,bind_unix,bind_v4,bind_v6,bind_xdpin favor ofbind,connect_any,connect_unix,connect_v4,connect_v6in favor ofconnect(leaving address-lessconnect_unspec),sendmsg_v4,sendmsg_v6,sendmsg_unix,sendmsg_xdp,sendmsg_anyin favor ofsendmsg_addr(leaving address-lesssendmsg),sendto_any,sendto_v4,sendto_v6,sendto_unix,sendto_xdpin favor ofsendto.
The SocketAddrAny enum has changed to a SocketAddrAny struct which can
contain any kind of socket address. It can be converted to and from the more
specific socket types using From/Into/TryFrom/TryInto conversions.
The len parameter to rustix::fs::fadvise has changed from u64 to
Option<NonZeroU64>, to reflect that zero is a special case meaning the
advice applies to the end of the file. To convert an arbitrary u64 value to
Option<NonZeroU64>, use NonZeroU64::new.
rustix::io_uring::io_uring_enter no longer has arg and size arguments
providing a raw *mut c_void and usize describing the argument value. To
pass argumentts, there are now additional functions, io_uring_enter_sigmask,
and io_uring_enter_arg, which take a KernelSigSet or an
io_uring_getevents_arg, respectively. These are more ergonomic, and provide
a better path to adding IORING_ENTER_EXT_ARG_REG support in the future.
The sigmask and ts fields of rustix::io_uring::getevents_arg
changed from u64 to rustix::io_uring::io_uring_ptr, to better preserve
pointer provenance.
The aliases for fcntl_dupfd_cloexec, fcntl_getfd, and fcntl_setfd
in rustix::fs are removed; these functions are just available in
rustix::io now.
SocketAddrXdp no longer has a shared UMEM field. A new
SocketAddrXdpWithSharedUmem is added for the purpose of calling bind and
passing it an XDP address with a shared UMEM fd. And SockaddrXdpFlags is
renamed to SocketAddrXdpFlags.
rustix::io_uring::io_uring_setup is now unsafe, due its io_uring_params
argument optionally containing a raw file descriptor.
The buffer for SendAncillaryBuffer and RecvAncillaryBuffer is now
a [MaybeUninit<u8>] instead of a [u8].
read, pread, recv, recvfrom, getrandom, readlinkat_raw,
epoll::wait, kevent, port::getn, getxattr, lgetxattr,
fgetxattr, listxattr, llistxattr, and flistxattr now use the
new Buffer trait.
This replaces read_uninit, pread_uninit, recv_uninit, recvfrom_uninit,
and getrandom_uninit, as the Buffer trait supports reading into
uninitialized slices.
epoll::wait, kevent, and port::getn previously took a Vec which they
implicitly cleared before results were appended. When passing a Vec to
epoll::wait, kevent, or port::getn using spare_capacity, the Vec is
not cleared first. Consider clearing the vector before calling epoll::wait,
kevent, or port::getn, or consuming it using .drain(..) before reusing it.
The rustix::ioctl::Opcode type has changed from a struct to a raw integer
value, and the associated utilities are change to const functions. In place
of ReadOpcode, WriteOpcode, ReadWriteOpcode, and NoneOpcode, use the
read, write, read_write, and none const functions in the
ioctl::opcode module. For example, in place of this:
ioctl::Setter::<ioctl::ReadOpcode<b'U', 15, c_uint>, c_uint>::new(interface)
use this:
+ ioctl::Setter::<{ ioctl::opcode::read::<c_uint>(b'U', 15) }, c_uint>::new(interface)
.
In place of BadOpcode, use the opcode value directly.
rustix::event::port::getn's min_events argument is now a u32, to
reflect the type in the underlying system API.
All explicitly deprecated functions and types have been removed. Their deprecation messages will have identified alternatives.