Skip to content

Commit 2c926a2

Browse files
authored
Miscellaneous documentation fixes. (#1129)
1 parent 25c54dc commit 2c926a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+369
-300
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ stdio = []
182182
# Enable `rustix::system::*`.
183183
system = ["linux-raw-sys/system"]
184184

185-
# Enable `rustix::runtime::*`. This API is undocumented and unstable and
186-
# experimental and not intended for general-purpose use.
185+
# Enable `rustix::runtime::*`. This API is undocumented and unstable and
186+
# experimental and not intended for general-purpose use.
187187
runtime = ["linux-raw-sys/prctl"]
188188

189189
# Enable all API features.

src/backend/libc/c.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ pub(crate) const XCASE: tcflag_t = linux_raw_sys::general::XCASE as _;
8686
#[cfg(target_os = "aix")]
8787
pub(crate) const MSG_DONTWAIT: c_int = libc::MSG_NONBLOCK;
8888

89-
// It is defined as 0 in libc under 64-bit platforms, but is automatically set
90-
// by kernel. <https://github.com/torvalds/linux/blob/v6.7/fs/open.c#L1458-L1459>
89+
// `O_LARGEFILE` can be automatically set by the kernel on Linux:
90+
// <https://github.com/torvalds/linux/blob/v6.7/fs/open.c#L1458-L1459>
91+
// so libc implementations may leave it undefined or defined to zero.
9192
#[cfg(linux_kernel)]
9293
pub(crate) const O_LARGEFILE: c_int = linux_raw_sys::general::O_LARGEFILE as _;
9394

src/backend/libc/event/epoll.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use core::ptr::null_mut;
8585
use core::slice;
8686

8787
bitflags! {
88-
/// `EPOLL_*` for use with [`new`].
88+
/// `EPOLL_*` for use with [`create`].
8989
#[repr(transparent)]
9090
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
9191
pub struct CreateFlags: u32 {
@@ -157,6 +157,11 @@ bitflags! {
157157
///
158158
/// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
159159
/// descriptor from being implicitly passed across `exec` boundaries.
160+
///
161+
/// # References
162+
/// - [Linux]
163+
///
164+
/// [Linux]: https://man7.org/linux/man-pages/man2/epoll_create.2.html
160165
#[inline]
161166
#[doc(alias = "epoll_create1")]
162167
pub fn create(flags: CreateFlags) -> io::Result<OwnedFd> {
@@ -171,12 +176,17 @@ pub fn create(flags: CreateFlags) -> io::Result<OwnedFd> {
171176
/// This registers interest in any of the events set in `events` occurring on
172177
/// the file descriptor associated with `data`.
173178
///
174-
/// If [`delete`] is not called on the I/O source passed into this function
175-
/// before the I/O source is `close`d, then the `epoll` will act as if the I/O
176-
/// source is still registered with it. This can lead to spurious events being
177-
/// returned from [`wait`]. If a file descriptor is an
178-
/// `Arc<dyn SystemResource>`, then `epoll` can be thought to maintain a
179-
/// `Weak<dyn SystemResource>` to the file descriptor.
179+
/// Note that `close`ing a file descriptor does not necessarily unregister
180+
/// interest which can lead to spurious events being returned from [`wait`]. If
181+
/// a file descriptor is an `Arc<dyn SystemResource>`, then `epoll` can be
182+
/// thought to maintain a `Weak<dyn SystemResource>` to the file descriptor.
183+
/// Check the [faq] for details.
184+
///
185+
/// # References
186+
/// - [Linux]
187+
///
188+
/// [Linux]: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html
189+
/// [faq]: https://man7.org/linux/man-pages/man7/epoll.7.html#:~:text=Will%20closing%20a%20file%20descriptor%20cause%20it%20to%20be%20removed%20from%20all%0A%20%20%20%20%20%20%20%20%20%20epoll%20interest%20lists%3F
180190
#[doc(alias = "epoll_ctl")]
181191
pub fn add(
182192
epoll: impl AsFd,
@@ -209,6 +219,11 @@ pub fn add(
209219
/// given epoll object.
210220
///
211221
/// This sets the events of interest with `target` to `events`.
222+
///
223+
/// # References
224+
/// - [Linux]
225+
///
226+
/// [Linux]: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html
212227
#[doc(alias = "epoll_ctl")]
213228
pub fn modify(
214229
epoll: impl AsFd,
@@ -240,6 +255,11 @@ pub fn modify(
240255

241256
/// `epoll_ctl(self, EPOLL_CTL_DEL, target, NULL)`—Removes an element in a
242257
/// given epoll object.
258+
///
259+
/// # References
260+
/// - [Linux]
261+
///
262+
/// [Linux]: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html
243263
#[doc(alias = "epoll_ctl")]
244264
pub fn delete(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
245265
// SAFETY: We're calling `epoll_ctl` via FFI and we know how it
@@ -260,6 +280,11 @@ pub fn delete(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
260280
///
261281
/// For each event of interest, an element is written to `events`. On
262282
/// success, this returns the number of written elements.
283+
///
284+
/// # References
285+
/// - [Linux]
286+
///
287+
/// [Linux]: https://man7.org/linux/man-pages/man2/epoll_wait.2.html
263288
#[cfg(feature = "alloc")]
264289
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
265290
pub fn wait(epoll: impl AsFd, event_list: &mut EventVec, timeout: c::c_int) -> io::Result<()> {

src/backend/libc/fs/syscalls.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub(crate) fn linkat(
348348
new_path: &CStr,
349349
flags: AtFlags,
350350
) -> io::Result<()> {
351-
// macOS <= 10.9 lacks `linkat`.
351+
// macOS 10.9 lacks `linkat`.
352352
#[cfg(target_os = "macos")]
353353
unsafe {
354354
weak! {
@@ -405,7 +405,7 @@ pub(crate) fn unlink(path: &CStr) -> io::Result<()> {
405405

406406
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
407407
pub(crate) fn unlinkat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<()> {
408-
// macOS <= 10.9 lacks `unlinkat`.
408+
// macOS 10.9 lacks `unlinkat`.
409409
#[cfg(target_os = "macos")]
410410
unsafe {
411411
weak! {
@@ -458,7 +458,7 @@ pub(crate) fn renameat(
458458
new_dirfd: BorrowedFd<'_>,
459459
new_path: &CStr,
460460
) -> io::Result<()> {
461-
// macOS <= 10.9 lacks `renameat`.
461+
// macOS 10.9 lacks `renameat`.
462462
#[cfg(target_os = "macos")]
463463
unsafe {
464464
weak! {
@@ -744,7 +744,7 @@ pub(crate) fn accessat(
744744
access: Access,
745745
flags: AtFlags,
746746
) -> io::Result<()> {
747-
// macOS <= 10.9 lacks `faccessat`.
747+
// macOS 10.9 lacks `faccessat`.
748748
#[cfg(target_os = "macos")]
749749
unsafe {
750750
weak! {
@@ -2255,8 +2255,8 @@ pub(crate) fn getxattr(path: &CStr, name: &CStr, value: &mut [u8]) -> io::Result
22552255

22562256
#[cfg(apple)]
22572257
{
2258-
// Passing an empty to slice to getxattr leads to ERANGE on macOS. Pass
2259-
// null instead.
2258+
// Passing an empty to slice to `getxattr` leads to `ERANGE` on macOS.
2259+
// Pass null instead.
22602260
let ptr = if value.is_empty() {
22612261
core::ptr::null_mut()
22622262
} else {
@@ -2291,8 +2291,8 @@ pub(crate) fn lgetxattr(path: &CStr, name: &CStr, value: &mut [u8]) -> io::Resul
22912291

22922292
#[cfg(apple)]
22932293
{
2294-
// Passing an empty to slice to getxattr leads to ERANGE on macOS. Pass
2295-
// null instead.
2294+
// Passing an empty to slice to `getxattr` leads to `ERANGE` on macOS.
2295+
// Pass null instead.
22962296
let ptr = if value.is_empty() {
22972297
core::ptr::null_mut()
22982298
} else {
@@ -2328,8 +2328,8 @@ pub(crate) fn fgetxattr(fd: BorrowedFd<'_>, name: &CStr, value: &mut [u8]) -> io
23282328

23292329
#[cfg(apple)]
23302330
{
2331-
// Passing an empty to slice to getxattr leads to ERANGE on macOS. Pass
2332-
// null instead.
2331+
// Passing an empty to slice to `getxattr` leads to `ERANGE` on macOS.
2332+
// Pass null instead.
23332333
let ptr = if value.is_empty() {
23342334
core::ptr::null_mut()
23352335
} else {

src/backend/libc/io/errno.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use libc_errno::errno;
3131
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=errno&section=2
3232
/// [illumos]: https://illumos.org/man/3C/errno
3333
/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
34-
/// [`std::io::Error`]: Result
3534
#[repr(transparent)]
3635
#[doc(alias = "errno")]
3736
#[derive(Eq, PartialEq, Hash, Copy, Clone)]

src/backend/libc/net/netdevice.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Wrappers for netdevice ioctls.
2+
13
#![allow(unsafe_code)]
24

35
#[cfg(feature = "alloc")]

src/backend/libc/net/send_recv.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::backend::c;
22
use bitflags::bitflags;
33

44
bitflags! {
5-
/// `MSG_*` flags for use with [`send`], [`send_to`], and related
5+
/// `MSG_*` flags for use with [`send`], [`sendto`], and related
66
/// functions.
77
///
88
/// [`send`]: crate::net::send
@@ -29,6 +29,8 @@ bitflags! {
2929
#[cfg(not(windows))]
3030
const DONTWAIT = bitcast!(c::MSG_DONTWAIT);
3131
/// Deprecated alias for [`EOR`].
32+
///
33+
/// [`EOR`]: Self::EOR
3234
#[cfg(not(windows))]
3335
#[deprecated(note = "`rustix::net::SendFlags::EOT` is renamed to `rustix::net::SendFlags::EOR`.")]
3436
const EOT = bitcast!(c::MSG_EOR);

src/backend/libc/net/syscalls.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ pub(crate) fn acceptfrom_with(
526526
}
527527
}
528528

529-
/// Darwin lacks `accept4`, but does have `accept`. We define
530-
/// `SocketFlags` to have no flags, so we can discard it here.
529+
/// Darwin lacks `accept4`, but does have `accept`. We define `SocketFlags` to
530+
/// have no flags, so we can discard it here.
531531
#[cfg(any(
532532
apple,
533533
windows,
@@ -541,8 +541,8 @@ pub(crate) fn accept_with(sockfd: BorrowedFd<'_>, _flags: SocketFlags) -> io::Re
541541
accept(sockfd)
542542
}
543543

544-
/// Darwin lacks `accept4`, but does have `accept`. We define
545-
/// `SocketFlags` to have no flags, so we can discard it here.
544+
/// Darwin lacks `accept4`, but does have `accept`. We define `SocketFlags` to
545+
/// have no flags, so we can discard it here.
546546
#[cfg(any(
547547
apple,
548548
windows,

src/backend/libc/process/syscalls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ fn _waitid_pidfd(fd: BorrowedFd<'_>, options: WaitidOptions) -> io::Result<Optio
585585
unsafe fn cvt_waitid_status(status: MaybeUninit<c::siginfo_t>) -> Option<WaitidStatus> {
586586
let status = status.assume_init();
587587
// `si_pid` is supposedly the better way to check that the struct has been
588-
// filled, e.g. the Linux manpage says about the `WNOHANG` case “zero out
589-
// the si_pid field before the call and check for a nonzero value”.
588+
// filled, e.g. the Linux manual page says about the `WNOHANG` case “zero
589+
// out the si_pid field before the call and check for a nonzero value”.
590590
// But e.g. NetBSD/OpenBSD don't have it exposed in the libc crate for now,
591591
// and some platforms don't have it at all. For simplicity, always check
592592
// `si_signo`. We have zero-initialized the whole struct, and all kernels

src/backend/libc/termios/syscalls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> {
117117
let pid = ret_pid_t(c::tcgetpgrp(borrowed_fd(fd)))?;
118118

119119
// This doesn't appear to be documented, but on Linux, it appears
120-
// `tcsetpgrp` can succceed and set the pid to 0 if we pass it a
120+
// `tcsetpgrp` can succeed and set the pid to 0 if we pass it a
121121
// pseudo-terminal device fd. For now, translate it into `OPNOTSUPP`.
122122
#[cfg(linux_kernel)]
123123
if pid == 0 {

0 commit comments

Comments
 (0)