mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a7fd32e4f | ||
|
|
3961c4b0dd | ||
|
|
fdcf75b27b | ||
|
|
7cd1cda42f | ||
|
|
0236d210d5 | ||
|
|
0d1029646c | ||
|
|
a32f96e473 | ||
|
|
acad18f4a5 | ||
|
|
3eeab4ef1c |
3
.github/workflows/bvt.yaml
vendored
3
.github/workflows/bvt.yaml
vendored
@@ -1,7 +1,7 @@
|
||||
name: BVT
|
||||
on: [pull_request]
|
||||
env:
|
||||
RUST_VERSION: 1.85.1
|
||||
RUST_VERSION: 1.90.0
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
@@ -35,4 +35,3 @@ jobs:
|
||||
- run: rustup install ${{ env.RUST_VERSION }} && rustup default ${{ env.RUST_VERSION }}
|
||||
- run: make test
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ repository = "https://github.com/kata-containers/cgroups-rs"
|
||||
keywords = ["linux", "cgroup", "containers", "isolation"]
|
||||
categories = ["os", "api-bindings", "os::unix-apis"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
authors = ["The Kata Containers community <kata-dev@lists.katacontainers.io>", "Levente Kurusa <lkurusa@acm.org>", "Sam Wilson <tecywiz121@hotmail.com>"]
|
||||
edition = "2018"
|
||||
homepage = "https://github.com/kata-containers/cgroups-rs"
|
||||
@@ -17,7 +17,7 @@ nix = { version = "0.25.0", default-features = false, features = ["event", "fs",
|
||||
libc = "0.2"
|
||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||
thiserror = "1"
|
||||
oci-spec = { version = "0.8.1", optional = true }
|
||||
oci-spec = { version = "0.10.0", optional = true }
|
||||
zbus = "5.8"
|
||||
bit-vec = "0.6"
|
||||
|
||||
|
||||
15
README.md
15
README.md
@@ -1,15 +1,14 @@
|
||||
# cgroups-rs 
|
||||
Native Rust library for managing control groups under Linux
|
||||
# cgroups-rs
|
||||
|
||||
Both v1 and v2 of cgroups are supported.
|
||||
[](https://crates.io/crates/cgroups-rs)
|
||||
|
||||
# Examples
|
||||
Native Rust library for managing Linux control groups. Supports both cgroups v1 and v2.
|
||||
|
||||
## Create a control group using the builder pattern
|
||||
|
||||
``` rust
|
||||
## Examples
|
||||
|
||||
### Create a control group using the builder pattern
|
||||
|
||||
```rust
|
||||
use cgroups_rs::*;
|
||||
use cgroups_rs::cgroup_builder::*;
|
||||
|
||||
@@ -44,7 +43,7 @@ cg.delete();
|
||||
// major version change.
|
||||
```
|
||||
|
||||
# Disclaimer
|
||||
## Disclaimer
|
||||
|
||||
This crate is licensed under:
|
||||
|
||||
|
||||
@@ -550,18 +550,18 @@ fn create_v2_cgroup(
|
||||
// path: "a/b/c"
|
||||
let elements = path.split('/').collect::<Vec<&str>>();
|
||||
let last_index = elements.len() - 1;
|
||||
// Build up the directory hierarchy element by element, enabling the controllers for all
|
||||
// parents along the way.
|
||||
for (i, ele) in elements.iter().enumerate() {
|
||||
// ROOT/a
|
||||
fp.push(ele);
|
||||
// create dir, need not check if is a file or directory
|
||||
if !fp.exists() {
|
||||
if let Err(e) = std::fs::create_dir(fp.clone()) {
|
||||
return Err(Error::with_cause(ErrorKind::FsError, e));
|
||||
}
|
||||
// create dir if necessary
|
||||
if let Err(e) = std::fs::create_dir_all(fp.clone()) {
|
||||
return Err(Error::with_cause(ErrorKind::FsError, e));
|
||||
}
|
||||
|
||||
if i < last_index {
|
||||
// enable controllers for substree
|
||||
// enable controllers for subtree
|
||||
enable_controllers(&controllers, &fp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user