shim: trivial documentation enhancements
Trivial documentation enhancements: 1) comments for unsafe code 2) list supported platforms Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This commit is contained in:
parent
a2bfeed2ca
commit
72aebb1b39
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue