Skip to content

Commit 220e609

Browse files
authored
Documentation and test cleanups. (#1357)
* Documentation and test cleanups. Fix broken links and typos in documentaion, and add a testt for the `ioctl::opcode` functions. * Mention `rustix::ioctl` in the README.md. * Fix and enable the `secure_computing_mode` test. * Use a Rust-style signal name in a comment. * Remove some redundant `cfg`s.
1 parent 137c733 commit 220e609

15 files changed

Lines changed: 94 additions & 121 deletions

File tree

CHANGES.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,14 @@ The `rustix::procfs` is removed. This functionality is now available in the
9292

9393
[rustix-linux-procfs crate]: https://crates.io/crates/rustix-linux-procfs
9494

95-
The `flags` field of [`rustix::net::RecvMsgReturn`] changed type from
96-
[`RecvFlags`] to a new [`ReturnFlags`], since it supports a different set of
97-
flags.
95+
`rustix::net::RecvMsgReturn` is renamed to [`rustix::net::RecvMsg`].
96+
97+
[`rustix::net::RecvMsg`]: https://docs.rs/rustix/1.0.0/rustix/net/struct.RecvMsg.html
98+
99+
The `flags` field of [`rustix::net::RecvMsg`] changed type from [`RecvFlags`]
100+
to a new [`ReturnFlags`], since it supports a different set of flags.
98101

99-
[`rustix::net::RecvMsgReturn`]: https://docs.rs/rustix/1.0.0/rustix/net/struct.RecvMsgReturn.html
102+
[`rustix::net::RecvMsg`]: https://docs.rs/rustix/1.0.0/rustix/net/struct.RecvMsg.html
100103
[`RecvFlags`]: https://docs.rs/rustix/1.0.0/rustix/net/struct.RecvFlags.html
101104
[`ReturnFlags`]: https://docs.rs/rustix/1.0.0/rustix/net/struct.ReturnFlags.html
102105

@@ -106,8 +109,8 @@ mean a timeout in milliseconds to an `Option<&Timespec>`. The [`Timespec`]'s
106109
fields are `tv_sec` which holds seconds and `tv_nsec` which holds nanoseconds.
107110

108111
[`rustix::event::poll`]: https://docs.rs/rustix/1.0.0/rustix/event/fn.poll.html
109-
[`rustix::event::epoll`]: https://docs.rs/rustix/1.0.0/rustix/event/fn.epoll.html
110-
[`Timespec`]: https://docs.rs/rustix/1.0.0/rustix/time/type.Timespec.html
112+
[`rustix::event::epoll`]: https://docs.rs/rustix/1.0.0/rustix/event/epoll/index.html
113+
[`Timespec`]: https://docs.rs/rustix/1.0.0/rustix/time/struct.Timespec.html
111114

112115
Functions in [`rustix::event::port`] are renamed to remove the redundant
113116
`port_*` prefix.
@@ -124,22 +127,22 @@ Functions in [`rustix::event::port`] are renamed to remove the redundant
124127
directly. They are now signed instead of unsigned, so that they can represent
125128
times before the epoch.
126129

127-
[`rustix::fs::Stat`]: https://docs.rs/rustix/1.0.0/rustix/fs/type.Stat.html
130+
[`rustix::fs::Stat`]: https://docs.rs/rustix/1.0.0/rustix/fs/struct.Stat.html
128131

129132
`rustix::io::is_read_write` is removed, as it's higher-level functionality that
130133
can be implemented in terms of lower-level rustix calls.
131134

132-
[`rustix::net::recv_uninit`] and [`rustix::net::recvfrom_uninit`] now include
135+
[`rustix::net::recv`] and [`rustix::net::recvfrom`] now include
133136
the number of received bytes in their return types, as this number may differ
134137
from the number of bytes written to the buffer when
135138
[`rustix::net::RecvFlags::TRUNC`] is used.
136139

137-
[`rustix::net::recv_uninit`]: https://docs.rs/rustix/1.0.0/rustix/net/fn.recv_uninit.html
138-
[`rustix::net::recvfrom_uninit`]: https://docs.rs/rustix/1.0.0/rustix/net/fn.recvfrom_uninit.html
140+
[`rustix::net::recv`]: https://docs.rs/rustix/1.0.0/rustix/net/fn.recv.html
141+
[`rustix::net::recvfrom`]: https://docs.rs/rustix/1.0.0/rustix/net/fn.recvfrom.html
139142
[`rustix::net::RecvFlags::TRUNC`]: https://docs.rs/rustix/1.0.0/rustix/net/struct.RecvFlags.html#associatedconstant.TRUNC
140143

141144
[`rustix::io_uring::io_uring_register`] now has a [`IoringRegisterFlags`]
142-
argument, and `rustix::io_uring::io_uring_register` is removed.
145+
argument, and `rustix::io_uring::io_uring_register_with` is removed.
143146

144147
[`rustix::io_uring::io_uring_register`]: https://docs.rs/rustix/1.0.0/rustix/io_uring/fn.io_uring_register.html
145148
[`IoringRegisterFlags`]: https://docs.rs/rustix/1.0.0/rustix/io_uring/struct.IoringRegisterFlags.html
@@ -148,20 +151,16 @@ argument, and `rustix::io_uring::io_uring_register` is removed.
148151
`Signal::Int` is now named [`Signal::INT`]. Also, `Signal` is no longer
149152
directly convertible to `i32`; use [`Signal::as_raw`] instead.
150153

151-
[`rustix::process::Signal`]: https://docs.rs/rustix/1.0.0/rustix/process/enum.Signal.html
152-
[`Signal::INT`]: https://docs.rs/rustix/1.0.0/rustix/process/enum.Signal.html#variant.Int
153-
[`Signal::as_raw`]: https://docs.rs/rustix/1.0.0/rustix/process/enum.Signal.html#method.as_raw
154+
[`rustix::process::Signal`]: https://docs.rs/rustix/1.0.0/rustix/process/struct.Signal.html
155+
[`Signal::INT`]: https://docs.rs/rustix/1.0.0/rustix/process/struct.Signal.html#variant.Int
156+
[`Signal::as_raw`]: https://docs.rs/rustix/1.0.0/rustix/process/struct.Signal.html#method.as_raw
154157

155158
The associated constant `rustix::ioctl::Ioctl::OPCODE` is now replaced with an
156159
associated method [`rustix::ioctl::Ioctl::opcode`], to support ioctls where the
157160
opcode is computed rather than a constant.
158161

159162
[`rustix::ioctl::Ioctl::opcode`]: https://docs.rs/rustix/1.0.0/rustix/ioctl/trait.Ioctl.html#tymethod.opcode
160163

161-
`rustix::net::RecvMsgReturn` is renamed to [`rustix::net::RecvMsg`].
162-
163-
[`rustix::net::RecvMsg`]: https://docs.rs/rustix/1.0.0/rustix/net/struct.RecvMsgReturn.html
164-
165164
The `ifindex` argument in
166165
[`rustix::net::sockopt::set_ip_add_membership_with_ifindex`] and
167166
[`rustix::net::sockopt::set_ip_drop_membership_with_ifindex`]
@@ -172,7 +171,7 @@ changed from `i32` to `u32`.
172171

173172
The `list` argument in [`rustix::fs::listxattr`], [`rustix::fs::flistxattr`],
174173
and [`rustix::fs::llistxattr`] changed from `[c_char]`, which is `[i8]` on some
175-
architectures, to [`u8`].
174+
architectures, to `[u8]`.
176175

177176
[`rustix::fs::listxattr`]: https://docs.rs/rustix/1.0.0/rustix/fs/fn.listxattr.html
178177
[`rustix::fs::flistxattr`]: https://docs.rs/rustix/1.0.0/rustix/fs/fn.flistxattr.html
@@ -188,7 +187,7 @@ with other platforms:
188187
| `st_ctimensec` | `st_ctime_nsec` |
189188
| `st_birthtimensec` | `st_birthtime_nsec` |
190189

191-
[`Stat`]: https://docs.rs/rustix/1.0.0/x86_64-unknown-netbsd/rustix/fs/type.Stat.html
190+
[`Stat`]: https://docs.rs/rustix/1.0.0/x86_64-unknown-netbsd/rustix/fs/struct.Stat.html
192191

193192
[`rustix::mount::mount`]'s `data` argument is now an `Option`, so it can now
194193
be used in place of `mount2`, and `mount2` is now removed.
@@ -247,13 +246,14 @@ pointer provenance.
247246

248247
The aliases for [`fcntl_dupfd_cloexec`], [`fcntl_getfd`], and [`fcntl_setfd`]
249248
in `rustix::fs` are removed; these functions are just available in
250-
`rustix::io` now.
249+
[`rustix::io`] now.
251250

252251
[`fcntl_dupfd_cloexec`]: https://docs.rs/rustix/1.0.0/rustix/io/fn.fcntl_dupfd_cloexec.html
253252
[`fcntl_getfd`]: https://docs.rs/rustix/1.0.0/rustix/io/fn.fcntl_getfd.html
254253
[`fcntl_setfd`]: https://docs.rs/rustix/1.0.0/rustix/io/fn.fcntl_setfd.html
254+
[`rustix::io`]: https://docs.rs/rustix/1.0.0/rustix/io/index.html
255255

256-
[`SocketAddrXdp`] no longer has a shared umem field. A new
256+
[`SocketAddrXdp`] no longer has a shared UMEM field. A new
257257
[`SocketAddrXdpWithSharedUmem`] is added for the purpose of calling `bind` and
258258
passing it an XDP address with a shared UMEM fd. And `SockaddrXdpFlags` is
259259
renamed to [`SocketAddrXdpFlags`].
@@ -303,11 +303,11 @@ vector before calling `epoll::wait` or `kqueue`, or consuming it using
303303
[`Buffer` trait]: https://docs.rs/rustix/1.0.0/rustix/buffer/trait.Buffer.html
304304
[`spare_capacity`]: https://docs.rs/rustix/1.0.0/rustix/buffer/fn.spare_capacity.html
305305

306-
The `Opcode` type has changed from a struct to a raw integer value, and the
307-
associated utilities are change to `const` functions. In place of `ReadOpcode`,
308-
`WriteOpcode`, `ReadWriteOpcode`, and `NoneOpcode`, use the `read`, `write`,
309-
`read_write`, and `none` const functions in the [`ioctl::opcode`] module. For
310-
example, in place of this:
306+
The [`rustix::ioctl::Opcode`] type has changed from a struct to a raw integer
307+
value, and the associated utilities are change to `const` functions. In place
308+
of `ReadOpcode`, `WriteOpcode`, `ReadWriteOpcode`, and `NoneOpcode`, use the
309+
`read`, `write`, `read_write`, and `none` const functions in the
310+
[`ioctl::opcode`] module. For example, in place of this:
311311
```rust
312312
ioctl::Setter::<ioctl::ReadOpcode<b'U', 15, c_uint>, c_uint>::new(interface)
313313
```
@@ -319,6 +319,7 @@ use this:
319319

320320
In place of `BadOpcode`, use the opcode value directly.
321321

322+
[`rustix::ioctl::Opcode`]: https://docs.rs/rustix/1.0.0/rustix/ioctl/type.Opcode.html
322323
[`ioctl::opcode`]: https://docs.rs/rustix/1.0.0/rustix/ioctl/opcode/index.html
323324

324325
All explicitly deprecated functions and types have been removed. Their

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ building.
5252

5353
## Cargo features
5454

55-
The modules [`rustix::io`], [`rustix::fd`], and [`rustix::ffi`] are enabled by
56-
default. The rest of the API is conditional with cargo feature flags:
55+
The modules [`rustix::io`], [`rustix::fd`], [`rustix::ffi`], and
56+
[`rustix::ioctl`] are enabled by default. The rest of the API is conditional
57+
with cargo feature flags:
5758

5859
| Name | Description |
5960
| ---------- | -------------------------------------------------------------- |
@@ -97,6 +98,7 @@ default. The rest of the API is conditional with cargo feature flags:
9798
[`rustix::io`]: https://docs.rs/rustix/*/rustix/io/index.html
9899
[`rustix::fd`]: https://docs.rs/rustix/*/rustix/fd/index.html
99100
[`rustix::ffi`]: https://docs.rs/rustix/*/rustix/ffi/index.html
101+
[`rustix::ioctl`]: https://docs.rs/rustix/*/rustix/ffi/ioctl.html
100102

101103
## 64-bit Large File Support (LFS) and Year 2038 (y2038) support
102104

src/backend/libc/mount/syscalls.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use crate::backend::c;
2-
use crate::backend::conv::ret;
3-
#[cfg(feature = "mount")]
4-
use crate::backend::conv::{borrowed_fd, c_str, ret_owned_fd};
5-
#[cfg(feature = "mount")]
2+
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_owned_fd};
63
use crate::fd::{BorrowedFd, OwnedFd};
74
use crate::ffi::CStr;
85
use crate::io;
@@ -33,7 +30,6 @@ pub(crate) fn unmount(target: &CStr, flags: super::types::UnmountFlags) -> io::R
3330
}
3431

3532
#[cfg(linux_kernel)]
36-
#[cfg(feature = "mount")]
3733
pub(crate) fn fsopen(fs_name: &CStr, flags: super::types::FsOpenFlags) -> io::Result<OwnedFd> {
3834
syscall! {
3935
fn fsopen(
@@ -45,7 +41,6 @@ pub(crate) fn fsopen(fs_name: &CStr, flags: super::types::FsOpenFlags) -> io::Re
4541
}
4642

4743
#[cfg(linux_kernel)]
48-
#[cfg(feature = "mount")]
4944
pub(crate) fn fsmount(
5045
fs_fd: BorrowedFd<'_>,
5146
flags: super::types::FsMountFlags,
@@ -62,7 +57,6 @@ pub(crate) fn fsmount(
6257
}
6358

6459
#[cfg(linux_kernel)]
65-
#[cfg(feature = "mount")]
6660
pub(crate) fn move_mount(
6761
from_dfd: BorrowedFd<'_>,
6862
from_pathname: &CStr,
@@ -91,7 +85,6 @@ pub(crate) fn move_mount(
9185
}
9286

9387
#[cfg(linux_kernel)]
94-
#[cfg(feature = "mount")]
9588
pub(crate) fn open_tree(
9689
dfd: BorrowedFd<'_>,
9790
filename: &CStr,
@@ -109,7 +102,6 @@ pub(crate) fn open_tree(
109102
}
110103

111104
#[cfg(linux_kernel)]
112-
#[cfg(feature = "mount")]
113105
pub(crate) fn fspick(
114106
dfd: BorrowedFd<'_>,
115107
path: &CStr,
@@ -126,7 +118,6 @@ pub(crate) fn fspick(
126118
unsafe { ret_owned_fd(fspick(borrowed_fd(dfd), c_str(path), flags.bits())) }
127119
}
128120

129-
#[cfg(feature = "mount")]
130121
#[cfg(linux_kernel)]
131122
syscall! {
132123
fn fsconfig(
@@ -139,7 +130,6 @@ syscall! {
139130
}
140131

141132
#[cfg(linux_kernel)]
142-
#[cfg(feature = "mount")]
143133
pub(crate) fn fsconfig_set_flag(fs_fd: BorrowedFd<'_>, key: &CStr) -> io::Result<()> {
144134
unsafe {
145135
ret(fsconfig(
@@ -153,7 +143,6 @@ pub(crate) fn fsconfig_set_flag(fs_fd: BorrowedFd<'_>, key: &CStr) -> io::Result
153143
}
154144

155145
#[cfg(linux_kernel)]
156-
#[cfg(feature = "mount")]
157146
pub(crate) fn fsconfig_set_string(
158147
fs_fd: BorrowedFd<'_>,
159148
key: &CStr,
@@ -171,7 +160,6 @@ pub(crate) fn fsconfig_set_string(
171160
}
172161

173162
#[cfg(linux_kernel)]
174-
#[cfg(feature = "mount")]
175163
pub(crate) fn fsconfig_set_binary(
176164
fs_fd: BorrowedFd<'_>,
177165
key: &CStr,
@@ -189,7 +177,6 @@ pub(crate) fn fsconfig_set_binary(
189177
}
190178

191179
#[cfg(linux_kernel)]
192-
#[cfg(feature = "mount")]
193180
pub(crate) fn fsconfig_set_fd(
194181
fs_fd: BorrowedFd<'_>,
195182
key: &CStr,
@@ -207,7 +194,6 @@ pub(crate) fn fsconfig_set_fd(
207194
}
208195

209196
#[cfg(linux_kernel)]
210-
#[cfg(feature = "mount")]
211197
pub(crate) fn fsconfig_set_path(
212198
fs_fd: BorrowedFd<'_>,
213199
key: &CStr,
@@ -226,7 +212,6 @@ pub(crate) fn fsconfig_set_path(
226212
}
227213

228214
#[cfg(linux_kernel)]
229-
#[cfg(feature = "mount")]
230215
pub(crate) fn fsconfig_set_path_empty(
231216
fs_fd: BorrowedFd<'_>,
232217
key: &CStr,
@@ -244,7 +229,6 @@ pub(crate) fn fsconfig_set_path_empty(
244229
}
245230

246231
#[cfg(linux_kernel)]
247-
#[cfg(feature = "mount")]
248232
pub(crate) fn fsconfig_create(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
249233
unsafe {
250234
ret(fsconfig(
@@ -258,7 +242,6 @@ pub(crate) fn fsconfig_create(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
258242
}
259243

260244
#[cfg(linux_kernel)]
261-
#[cfg(feature = "mount")]
262245
pub(crate) fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
263246
unsafe {
264247
ret(fsconfig(
@@ -272,7 +255,6 @@ pub(crate) fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
272255
}
273256

274257
#[cfg(linux_kernel)]
275-
#[cfg(feature = "mount")]
276258
pub(crate) fn fsconfig_create_excl(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
277259
unsafe {
278260
ret(fsconfig(

src/backend/libc/mount/types.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ bitflags! {
8383
}
8484
}
8585

86-
#[cfg(feature = "mount")]
8786
#[cfg(linux_kernel)]
8887
bitflags! {
8988
/// `FSOPEN_*` constants for use with [`fsopen`].
@@ -100,7 +99,6 @@ bitflags! {
10099
}
101100
}
102101

103-
#[cfg(feature = "mount")]
104102
#[cfg(linux_kernel)]
105103
bitflags! {
106104
/// `FSMOUNT_*` constants for use with [`fsmount`].
@@ -118,7 +116,6 @@ bitflags! {
118116
}
119117

120118
/// `FSCONFIG_*` constants for use with the `fsconfig` syscall.
121-
#[cfg(feature = "mount")]
122119
#[cfg(linux_kernel)]
123120
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
124121
#[repr(u32)]
@@ -151,7 +148,6 @@ pub(crate) enum FsConfigCmd {
151148
CreateExclusive = 8,
152149
}
153150

154-
#[cfg(feature = "mount")]
155151
#[cfg(linux_kernel)]
156152
bitflags! {
157153
/// `MOUNT_ATTR_*` constants for use with [`fsmount`].
@@ -201,7 +197,6 @@ bitflags! {
201197
}
202198
}
203199

204-
#[cfg(feature = "mount")]
205200
#[cfg(linux_kernel)]
206201
bitflags! {
207202
/// `MOVE_MOUNT_*` constants for use with [`move_mount`].
@@ -242,7 +237,6 @@ bitflags! {
242237
}
243238
}
244239

245-
#[cfg(feature = "mount")]
246240
#[cfg(linux_kernel)]
247241
bitflags! {
248242
/// `OPENTREE_*` constants for use with [`open_tree`].
@@ -274,7 +268,6 @@ bitflags! {
274268
}
275269
}
276270

277-
#[cfg(feature = "mount")]
278271
#[cfg(linux_kernel)]
279272
bitflags! {
280273
/// `FSPICK_*` constants for use with [`fspick`].

0 commit comments

Comments
 (0)