Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AsFd for RawPool #478

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/shm/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use std::{
fs::File,
io,
os::unix::prelude::{AsFd, OwnedFd},
os::unix::prelude::{AsFd, BorrowedFd, OwnedFd},
sync::Arc,
time::{SystemTime, UNIX_EPOCH},
};
Expand Down Expand Up @@ -151,6 +151,12 @@
}
}

impl AsFd for RawPool {
fn as_fd(&self) -> BorrowedFd {
self.mem_file.as_fd()
}
}

impl io::Write for RawPool {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
io::Write::write(&mut self.mem_file, buf)
Expand Down Expand Up @@ -227,7 +233,7 @@
use rustix::fs::{MemfdFlags, SealFlags};

loop {
let name = CStr::from_bytes_with_nul(b"smithay-client-toolkit\0").unwrap();

Check failure on line 236 in src/shm/raw.rs

View workflow job for this annotation

GitHub Actions / lint

calling `CStr::new` with a byte string literal
let flags = MemfdFlags::ALLOW_SEALING | MemfdFlags::CLOEXEC;

match rustix::fs::memfd_create(name, flags) {
Expand Down
Loading