Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions crates/runc-shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ uuid.workspace = true
# Async dependencies
async-trait.workspace = true
tokio = { workspace = true, features = ["full"] }
rustix = { version = "1", features = ["termios"] }

[package.metadata.cargo-machete]
ignored = ["libc"]

[target.'cfg(target_os = "linux")'.dependencies]
cgroups-rs.workspace = true
Expand Down
17 changes: 5 additions & 12 deletions crates/runc-shim/src/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@
limitations under the License.
*/

use std::{
os::unix::io::AsRawFd,
sync::{Arc, Mutex},
};
use std::sync::{Arc, Mutex};

use async_trait::async_trait;
use containerd_shim::{
ioctl_set_winsz,
protos::{
api::{ProcessInfo, StateResponse, Status},
cgroups::metrics::Metrics,
protobuf::well_known_types::timestamp::Timestamp,
},
util::asyncify,
Console, Result,
};
use oci_spec::runtime::LinuxResources;
use rustix::termios::{tcsetwinsize, Winsize};
use time::OffsetDateTime;
use tokio::{
fs::File,
Expand Down Expand Up @@ -174,17 +170,14 @@ where

async fn resize_pty(&mut self, height: u32, width: u32) -> Result<()> {
if let Some(console) = self.console.as_ref() {
let w = libc::winsize {
let w = Winsize {
ws_row: height as u16,
ws_col: width as u16,
ws_xpixel: 0,
ws_ypixel: 0,
};
let fd = console.file.as_raw_fd();
asyncify(move || -> Result<()> {
unsafe { ioctl_set_winsz(fd, &w).map(|_x| ()).map_err(Into::into) }
})
.await?;
tcsetwinsize(&console.file, w)
.map_err(|e| containerd_shim::Error::Other(e.to_string()))?;
}
Ok(())
}
Expand Down
11 changes: 2 additions & 9 deletions crates/shim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,17 @@
#![cfg_attr(feature = "docs", doc = include_str!("../README.md"))]

use std::{fs::File, path::PathBuf};
#[cfg(windows)]
use std::{fs::OpenOptions, os::windows::prelude::OpenOptionsExt};
#[cfg(unix)]
use std::{os::unix::net::UnixListener, path::Path};

pub use containerd_shim_protos as protos;
#[cfg(unix)]
use nix::ioctl_write_ptr_bad;
pub use protos::{
shim::shim::DeleteResponse,
ttrpc::{context::Context, Result as TtrpcResult},
};
use sha2::{Digest, Sha256};

#[cfg(unix)]
ioctl_write_ptr_bad!(ioctl_set_winsz, libc::TIOCSWINSZ, libc::winsize);

#[cfg(windows)]
use std::{fs::OpenOptions, os::windows::prelude::OpenOptionsExt};

#[cfg(windows)]
use windows_sys::Win32::Storage::FileSystem::FILE_FLAG_OVERLAPPED;

Expand Down
Loading