Skip to content

Commit 22590e2

Browse files
committed
chore: update rustix to 1.0
1 parent 3af95ba commit 22590e2

File tree

8 files changed

+462
-406
lines changed

8 files changed

+462
-406
lines changed

mm-server/Cargo.lock

Lines changed: 407 additions & 383 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mm-server/Cargo.toml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ crossbeam-channel = "0.5"
2525
cstr = "0.2"
2626
ctrlc = "3"
2727
cursor-icon = "1"
28-
dasp = { version = "0.11", features = ["signal", "interpolate", "interpolate-sinc", "ring_buffer"] }
28+
dasp = { version = "0.11", features = [
29+
"signal",
30+
"interpolate",
31+
"interpolate-sinc",
32+
"ring_buffer",
33+
] }
2934
drm = "0.14"
3035
drm-fourcc = "2"
3136
either = "1"
@@ -73,7 +78,11 @@ tracing-tracy = { version = "0.11", default-features = false }
7378
tracy-client = { version = "0.17", default-features = false }
7479
uds = "0.4"
7580
uuid = "1"
76-
wayland-protocols = { version = "0.32", features = ["server", "staging", "unstable"] }
81+
wayland-protocols = { version = "0.32", features = [
82+
"server",
83+
"staging",
84+
"unstable",
85+
] }
7786
wayland-scanner = "0.31"
7887
wayland-server = { version = "0.31", features = ["log"] }
7988
x11rb = { version = "0.13", features = ["composite"] }
@@ -92,9 +101,21 @@ git = "https://github.com/colinmarc/pulseaudio-rs"
92101
rev = "70ddb748f20ceecc20e963e571188124aeb30186"
93102

94103
[dependencies.rustix]
95-
version = "0.38"
96-
default-features = false
97-
features = ["mm", "mount", "pipe", "time", "thread", "stdio"]
104+
version = "1.0"
105+
features = [
106+
"core",
107+
"event",
108+
"fs",
109+
"mm",
110+
"mount",
111+
"net",
112+
"pipe",
113+
"time",
114+
"thread",
115+
"stdio",
116+
"system",
117+
"process",
118+
]
98119

99120
[dependencies.southpaw]
100121
git = "https://github.com/colinmarc/southpaw"

mm-server/src/container.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use anyhow::{bail, Context as _};
1212
use rustix::{
1313
mount::MountAttrFlags,
14-
process::{Pid, Signal, WaitId, WaitidOptions},
14+
process::{Pid, Signal, WaitId, WaitIdOptions},
1515
};
1616
use tracing::{debug, info};
1717

@@ -51,7 +51,7 @@ impl ContainerHandle {
5151

5252
pub fn wait(&mut self) -> anyhow::Result<()> {
5353
let exit_status =
54-
rustix::process::waitid(WaitId::PidFd(self.as_fd()), WaitidOptions::EXITED)
54+
rustix::process::waitid(WaitId::PidFd(self.as_fd()), WaitIdOptions::EXITED)
5555
.context("waitid")?
5656
.and_then(|x| x.exit_status())
5757
.unwrap_or_default();

mm-server/src/container/ipc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ fn signal_eventfd(fd: impl AsFd) -> rustix::io::Result<()> {
100100
fn wait_eventfd(fd: impl AsFd, timeout: time::Duration) -> rustix::io::Result<()> {
101101
let mut pollfd = [PollFd::new(&fd, PollFlags::IN)];
102102
let mut buf = [0; 8];
103+
let timespec = timeout.try_into().expect("invalid duration");
103104
loop {
104-
match poll(&mut pollfd, timeout.as_millis() as _) {
105+
match poll(&mut pollfd, Some(&timespec)) {
105106
Ok(0) => return Err(Errno::TIMEDOUT),
106107
Ok(_) => return read(fd, &mut buf).map(|_| ()),
107108
Err(Errno::INTR) => continue,

mm-server/src/container/runtime.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,7 @@ impl Container {
423423
}
424424

425425
// Signal safety dictates what we can do here, and it's not a lot. The main
426-
// thing we avoid is allocations. Note that rustix is added as a dependency
427-
// without the 'alloc' feature.
426+
// thing we avoid is allocations.
428427
unsafe fn child_after_fork<FD>(
429428
mut self,
430429
stderr: Option<FD>,
@@ -444,7 +443,7 @@ impl Container {
444443
// is particularly important because we're PID 1, so the kernel won't
445444
// kill on SIGINT/SIGQUIT/etc if the child process doesn't have a signal
446445
// handler set up for them.
447-
must!(set_parent_process_death_signal(Some(Signal::Kill)));
446+
must!(set_parent_process_death_signal(Some(Signal::KILL)));
448447

449448
preexec_debug!("starting container setup");
450449

@@ -694,7 +693,7 @@ where
694693
let _ = rustix::stdio::dup2_stderr(fd.as_fd()); // Replace stderr.
695694
}
696695

697-
must!(set_parent_process_death_signal(Some(Signal::Kill)));
696+
must!(set_parent_process_death_signal(Some(Signal::KILL)));
698697

699698
must!(move_into_link_name_space(
700699
ns_pidfd.as_fd(),
@@ -721,7 +720,7 @@ where
721720
WaitOptions::empty(),
722721
) {
723722
Ok(st) => match st {
724-
Some(st) if st.as_raw() == 0 => return Ok(()),
723+
Some((_, st)) if st.as_raw() == 0 => return Ok(()),
725724
_ => return Err(io::Error::other("forked process exited with error")),
726725
},
727726
Err(Errno::INTR) => continue,

mm-server/src/session/compositor/buffers.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
sync::{Arc, RwLock},
1212
};
1313

14-
use anyhow::bail;
14+
use anyhow::{bail, Context as _};
1515
use ash::vk;
1616
use drm_fourcc::DrmModifier;
1717
pub use modifiers::*;
@@ -365,7 +365,10 @@ pub fn validate_buffer_parameters(
365365
mod ioctl {
366366
use std::{ffi::c_void, os::fd::RawFd};
367367

368-
use rustix::{io::Errno, ioctl::Opcode};
368+
use rustix::{
369+
io::Errno,
370+
ioctl::{opcode, Opcode},
371+
};
369372

370373
pub(super) const DMA_BUF_SYNC_READ: u32 = 1 << 0;
371374
pub(super) const DMA_BUF_SYNC_WRITE: u32 = 1 << 1;
@@ -403,9 +406,12 @@ mod ioctl {
403406
unsafe impl rustix::ioctl::Ioctl for ExportSyncFile {
404407
type Output = RawFd;
405408

406-
const OPCODE: Opcode = Opcode::read_write::<dma_buf_export_sync_file>(b'b', 2);
407409
const IS_MUTATING: bool = true;
408410

411+
fn opcode(&self) -> Opcode {
412+
opcode::read_write::<dma_buf_export_sync_file>(b'b', 2)
413+
}
414+
409415
fn as_ptr(&mut self) -> *mut c_void {
410416
&mut self.0 as *mut dma_buf_export_sync_file as _
411417
}
@@ -428,9 +434,12 @@ mod ioctl {
428434
unsafe impl rustix::ioctl::Ioctl for ImportSyncFile {
429435
type Output = ();
430436

431-
const OPCODE: Opcode = Opcode::write::<dma_buf_import_sync_file>(b'b', 3);
432437
const IS_MUTATING: bool = true;
433438

439+
fn opcode(&self) -> Opcode {
440+
opcode::write::<dma_buf_import_sync_file>(b'b', 3)
441+
}
442+
434443
fn as_ptr(&mut self) -> *mut c_void {
435444
&mut self.0 as *mut dma_buf_import_sync_file as _
436445
}
@@ -483,7 +492,8 @@ pub unsafe fn import_sync_file_as_semaphore(
483492

484493
/// Retrieves the fd of a sync file for a dmabuf.
485494
pub unsafe fn export_sync_file(dmabuf: impl AsFd, flags: u32) -> anyhow::Result<OwnedFd> {
486-
let raw_fd = rustix::ioctl::ioctl(dmabuf, ioctl::ExportSyncFile::new(flags))?;
495+
let raw_fd = rustix::ioctl::ioctl(dmabuf, ioctl::ExportSyncFile::new(flags))
496+
.context("DMA_BUF_IOCTL_EXPORT_SYNC_FILE")?;
487497
Ok(OwnedFd::from_raw_fd(raw_fd))
488498
}
489499

@@ -502,7 +512,8 @@ pub unsafe fn attach_sync_file(
502512
rustix::ioctl::ioctl(
503513
dmabuf,
504514
ioctl::ImportSyncFile::new(sync_file.as_raw_fd(), flags),
505-
)?;
515+
)
516+
.context("DMA_BUF_IOCTL_IMPORT_SYNC_FILE")?;
506517

507518
Ok(())
508519
}

mm-server/src/session/compositor/xwayland.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl DisplaySocket {
5050
loop {
5151
let dp = DisplaySocket(display);
5252

53-
match rustix::net::bind_unix(
53+
match rustix::net::bind(
5454
&sock,
5555
// By convention, the name is the same as the path.
5656
&SocketAddrUnix::new_abstract_name(dp.inner_path().as_os_str().as_encoded_bytes())?,
@@ -188,5 +188,5 @@ impl XWayland {
188188
}
189189

190190
fn unset_cloexec(socket_fd: impl AsFd) -> Result<(), rustix::io::Errno> {
191-
rustix::fs::fcntl_setfd(socket_fd, rustix::fs::FdFlags::empty())
191+
rustix::io::fcntl_setfd(socket_fd, rustix::io::FdFlags::empty())
192192
}

mm-server/src/session/reactor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl Reactor {
374374

375375
// Usually, TERM doesn't work, because the
376376
// process is PID 1 in the container.
377-
self.child.signal(rustix::process::Signal::Kill)?;
377+
self.child.signal(rustix::process::Signal::KILL)?;
378378
}
379379
Ok(msg) => self.handle_control_message(msg)?,
380380
Err(crossbeam::TryRecvError::Empty) => break,
@@ -448,7 +448,7 @@ impl Reactor {
448448
if self.ready_once.is_some() && self.compositor.surfaces_ready() {
449449
self.ready_once.take().unwrap().send(control_send.clone())?;
450450
} else if self.ready_once.is_some() && start.elapsed() > READY_TIMEOUT {
451-
self.child.signal(rustix::process::Signal::Kill)?;
451+
self.child.signal(rustix::process::Signal::KILL)?;
452452
bail!("timed out waiting for client");
453453
}
454454

0 commit comments

Comments
 (0)