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 |
@@ -1,7 +1,7 @@
|
|||||||
name: BVT
|
name: BVT
|
||||||
on: [pull_request]
|
on: [pull_request]
|
||||||
env:
|
env:
|
||||||
RUST_VERSION: 1.85.1
|
RUST_VERSION: 1.90.0
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
@@ -35,4 +35,3 @@ jobs:
|
|||||||
- run: rustup install ${{ env.RUST_VERSION }} && rustup default ${{ env.RUST_VERSION }}
|
- run: rustup install ${{ env.RUST_VERSION }} && rustup default ${{ env.RUST_VERSION }}
|
||||||
- run: make test
|
- run: make test
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@ repository = "https://github.com/kata-containers/cgroups-rs"
|
|||||||
keywords = ["linux", "cgroup", "containers", "isolation"]
|
keywords = ["linux", "cgroup", "containers", "isolation"]
|
||||||
categories = ["os", "api-bindings", "os::unix-apis"]
|
categories = ["os", "api-bindings", "os::unix-apis"]
|
||||||
license = "MIT OR Apache-2.0"
|
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>"]
|
authors = ["The Kata Containers community <kata-dev@lists.katacontainers.io>", "Levente Kurusa <lkurusa@acm.org>", "Sam Wilson <tecywiz121@hotmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
homepage = "https://github.com/kata-containers/cgroups-rs"
|
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"
|
libc = "0.2"
|
||||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
oci-spec = { version = "0.8.1", optional = true }
|
oci-spec = { version = "0.10.0", optional = true }
|
||||||
zbus = "5.8"
|
zbus = "5.8"
|
||||||
bit-vec = "0.6"
|
bit-vec = "0.6"
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
# cgroups-rs 
|
# cgroups-rs
|
||||||
Native Rust library for managing control groups under Linux
|
|
||||||
|
|
||||||
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
|
## Examples
|
||||||
|
|
||||||
``` rust
|
|
||||||
|
|
||||||
|
### Create a control group using the builder pattern
|
||||||
|
|
||||||
|
```rust
|
||||||
use cgroups_rs::*;
|
use cgroups_rs::*;
|
||||||
use cgroups_rs::cgroup_builder::*;
|
use cgroups_rs::cgroup_builder::*;
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ cg.delete();
|
|||||||
// major version change.
|
// major version change.
|
||||||
```
|
```
|
||||||
|
|
||||||
# Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
This crate is licensed under:
|
This crate is licensed under:
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -550,18 +550,18 @@ fn create_v2_cgroup(
|
|||||||
// path: "a/b/c"
|
// path: "a/b/c"
|
||||||
let elements = path.split('/').collect::<Vec<&str>>();
|
let elements = path.split('/').collect::<Vec<&str>>();
|
||||||
let last_index = elements.len() - 1;
|
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() {
|
for (i, ele) in elements.iter().enumerate() {
|
||||||
// ROOT/a
|
// ROOT/a
|
||||||
fp.push(ele);
|
fp.push(ele);
|
||||||
// create dir, need not check if is a file or directory
|
// create dir if necessary
|
||||||
if !fp.exists() {
|
if let Err(e) = std::fs::create_dir_all(fp.clone()) {
|
||||||
if let Err(e) = std::fs::create_dir(fp.clone()) {
|
return Err(Error::with_cause(ErrorKind::FsError, e));
|
||||||
return Err(Error::with_cause(ErrorKind::FsError, e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if i < last_index {
|
if i < last_index {
|
||||||
// enable controllers for substree
|
// enable controllers for subtree
|
||||||
enable_controllers(&controllers, &fp);
|
enable_controllers(&controllers, &fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user