From 72aebb1b39d91571a0bbbe94e16b9d7619e4fdd3 Mon Sep 17 00:00:00 2001 From: Liu Jiang Date: Sat, 11 Dec 2021 19:28:05 +0800 Subject: [PATCH] shim: trivial documentation enhancements Trivial documentation enhancements: 1) comments for unsafe code 2) list supported platforms Signed-off-by: Liu Jiang --- crates/shim/README.md | 6 ++++++ crates/shim/src/lib.rs | 2 +- crates/shim/src/reap.rs | 10 ++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/shim/README.md b/crates/shim/README.md index 8591ece..ee21028 100644 --- a/crates/shim/README.md +++ b/crates/shim/README.md @@ -127,3 +127,9 @@ $ cat log [INFO] reaper thread exited [INFO] reaper thread stopped ``` + +## Supported Platforms +Currently following OSs and hardware architectures are supported, and more efforts are needed to enable and validate other OSs and architectures. +- Linux +- Mac OS +- x86_64 diff --git a/crates/shim/src/lib.rs b/crates/shim/src/lib.rs index 6a68abc..37df6f9 100644 --- a/crates/shim/src/lib.rs +++ b/crates/shim/src/lib.rs @@ -284,7 +284,7 @@ pub const SOCKET_ROOT: &str = "/run/containerd"; #[cfg(target_os = "macos")] pub const SOCKET_ROOT: &str = "/var/run/containerd"; -/// Make socket path from namespace and id. +/// Make socket path from containerd socket path, namespace and id. pub fn socket_address(socket_path: &str, namespace: &str, id: &str) -> String { let path = PathBuf::from(socket_path) .join(namespace) diff --git a/crates/shim/src/reap.rs b/crates/shim/src/reap.rs index 2168271..fac2ce7 100644 --- a/crates/shim/src/reap.rs +++ b/crates/shim/src/reap.rs @@ -14,21 +14,23 @@ limitations under the License. */ -use std::io; +use std::io::Result; #[cfg(target_os = "linux")] -pub fn set_subreaper() -> Result<(), io::Error> { +pub fn set_subreaper() -> Result<()> { use libc::PR_SET_CHILD_SUBREAPER; + use std::io::Error; + // Safe because we trust the kernel and have checked the result. let code = unsafe { libc::prctl(PR_SET_CHILD_SUBREAPER, 0, 0, 0) }; if code != 0 { - Err(io::Error::from_raw_os_error(code)) + Err(Error::from_raw_os_error(code)) } else { Ok(()) } } #[cfg(not(target_os = "linux"))] -pub fn set_subreaper() -> Result<(), io::Error> { +pub fn set_subreaper() -> Result<()> { Ok(()) }