mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
fs: Move all files to fs subdirectory
Prepare to implement FsManager, which should be done in the following-up commits. Apart from that, no code is not modified. Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::{read_string_from, read_u64_from};
|
||||
use crate::{
|
||||
use crate::fs::{read_string_from, read_u64_from};
|
||||
use crate::fs::{
|
||||
BlkIoResources, ControllIdentifier, ControllerInternal, Controllers, CustomizedAttribute,
|
||||
Resources, Subsystem,
|
||||
};
|
||||
@@ -829,9 +829,9 @@ impl BlkIoController {
|
||||
impl CustomizedAttribute for BlkIoController {}
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::blkio::{parse_blkio_data, BlkIoData};
|
||||
use crate::blkio::{parse_io_service, parse_io_service_total, IoService};
|
||||
use crate::error::*;
|
||||
use crate::fs::blkio::{parse_blkio_data, BlkIoData};
|
||||
use crate::fs::blkio::{parse_io_service, parse_io_service_total, IoService};
|
||||
use crate::fs::error::*;
|
||||
|
||||
static TEST_VALUE: &str = "\
|
||||
8:32 Read 4280320
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
//! This module handles cgroup operations. Start here!
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::hierarchies::V1;
|
||||
use crate::{CgroupPid, ControllIdentifier, Controller, Hierarchy, Resources, Subsystem};
|
||||
use crate::fs::hierarchies::V1;
|
||||
use crate::fs::{CgroupPid, ControllIdentifier, Controller, Hierarchy, Resources, Subsystem};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::convert::From;
|
||||
@@ -51,7 +51,7 @@ impl Clone for Cgroup {
|
||||
fn clone(&self) -> Self {
|
||||
Cgroup {
|
||||
subsystems: self.subsystems.clone(),
|
||||
hier: crate::hierarchies::auto(),
|
||||
hier: crate::fs::hierarchies::auto(),
|
||||
path: self.path.clone(),
|
||||
specified_controllers: None,
|
||||
}
|
||||
@@ -62,7 +62,7 @@ impl Default for Cgroup {
|
||||
fn default() -> Self {
|
||||
Cgroup {
|
||||
subsystems: Vec::new(),
|
||||
hier: crate::hierarchies::auto(),
|
||||
hier: crate::fs::hierarchies::auto(),
|
||||
path: "".to_string(),
|
||||
specified_controllers: None,
|
||||
}
|
||||
@@ -16,10 +16,10 @@
|
||||
//! by a call to `build()`.
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! # use cgroups_rs::*;
|
||||
//! # use cgroups_rs::devices::*;
|
||||
//! # use cgroups_rs::cgroup_builder::*;
|
||||
//! let h = cgroups_rs::hierarchies::auto();
|
||||
//! # use cgroups_rs::fs::*;
|
||||
//! # use cgroups_rs::fs::devices::*;
|
||||
//! # use cgroups_rs::fs::cgroup_builder::*;
|
||||
//! let h = cgroups_rs::fs::hierarchies::auto();
|
||||
//! let cgroup: Cgroup = CgroupBuilder::new("hello")
|
||||
//! .memory()
|
||||
//! .kernel_memory_limit(1024 * 1024)
|
||||
@@ -60,7 +60,7 @@
|
||||
//! .build(h).unwrap();
|
||||
//! ```
|
||||
|
||||
use crate::{
|
||||
use crate::fs::{
|
||||
BlkIoDeviceResource, BlkIoDeviceThrottleResource, Cgroup, DeviceResource, Error, Hierarchy,
|
||||
HugePageResource, MaxValue, NetworkPriority, Resources,
|
||||
};
|
||||
@@ -250,9 +250,9 @@ impl DeviceResourceBuilder {
|
||||
mut self,
|
||||
major: i64,
|
||||
minor: i64,
|
||||
devtype: crate::devices::DeviceType,
|
||||
devtype: crate::fs::devices::DeviceType,
|
||||
allow: bool,
|
||||
access: Vec<crate::devices::DevicePermissions>,
|
||||
access: Vec<crate::fs::devices::DevicePermissions>,
|
||||
) -> DeviceResourceBuilder {
|
||||
self.cgroup.resources.devices.devices.push(DeviceResource {
|
||||
allow,
|
||||
@@ -13,11 +13,11 @@ use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::{parse_max_value, read_i64_from, read_u64_from};
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
use crate::fs::{parse_max_value, read_i64_from, read_u64_from};
|
||||
|
||||
use crate::{
|
||||
use crate::fs::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, CpuResources, CustomizedAttribute,
|
||||
MaxValue, Resources, Subsystem,
|
||||
};
|
||||
@@ -10,11 +10,11 @@
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::{read_string_from, read_u64_from};
|
||||
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
use crate::fs::{read_string_from, read_u64_from};
|
||||
use crate::fs::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
|
||||
/// A controller that allows controlling the `cpuacct` subsystem of a Cgroup.
|
||||
///
|
||||
@@ -13,11 +13,11 @@ use log::*;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::{read_string_from, read_u64_from};
|
||||
use crate::{
|
||||
use crate::fs::{read_string_from, read_u64_from};
|
||||
use crate::fs::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, CpuResources, Resources, Subsystem,
|
||||
};
|
||||
|
||||
@@ -591,7 +591,7 @@ impl CpuSetController {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cpuset;
|
||||
use crate::fs::cpuset;
|
||||
#[test]
|
||||
fn test_parse_range() {
|
||||
let test_cases = vec![
|
||||
@@ -12,10 +12,10 @@ use std::path::PathBuf;
|
||||
|
||||
use log::*;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::{
|
||||
use crate::fs::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, DeviceResource, DeviceResources,
|
||||
Resources, Subsystem,
|
||||
};
|
||||
@@ -12,8 +12,8 @@ use std::path::Path;
|
||||
use std::sync::mpsc::{self, Receiver};
|
||||
use std::thread;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
// notify_on_oom returns channel on which you can expect event about OOM,
|
||||
// if process died without OOM this channel will be closed.
|
||||
@@ -11,10 +11,10 @@
|
||||
use std::io::{Read, Write};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
use crate::fs::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
|
||||
/// A controller that allows controlling the `freezer` subsystem of a Cgroup.
|
||||
///
|
||||
@@ -11,23 +11,23 @@ use std::fs::File;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::blkio::BlkIoController;
|
||||
use crate::cpu::CpuController;
|
||||
use crate::cpuacct::CpuAcctController;
|
||||
use crate::cpuset::CpuSetController;
|
||||
use crate::devices::DevicesController;
|
||||
use crate::freezer::FreezerController;
|
||||
use crate::hugetlb::HugeTlbController;
|
||||
use crate::memory::MemController;
|
||||
use crate::net_cls::NetClsController;
|
||||
use crate::net_prio::NetPrioController;
|
||||
use crate::perf_event::PerfEventController;
|
||||
use crate::pid::PidController;
|
||||
use crate::rdma::RdmaController;
|
||||
use crate::systemd::SystemdController;
|
||||
use crate::{Controllers, Hierarchy, Subsystem};
|
||||
use crate::fs::blkio::BlkIoController;
|
||||
use crate::fs::cpu::CpuController;
|
||||
use crate::fs::cpuacct::CpuAcctController;
|
||||
use crate::fs::cpuset::CpuSetController;
|
||||
use crate::fs::devices::DevicesController;
|
||||
use crate::fs::freezer::FreezerController;
|
||||
use crate::fs::hugetlb::HugeTlbController;
|
||||
use crate::fs::memory::MemController;
|
||||
use crate::fs::net_cls::NetClsController;
|
||||
use crate::fs::net_prio::NetPrioController;
|
||||
use crate::fs::perf_event::PerfEventController;
|
||||
use crate::fs::pid::PidController;
|
||||
use crate::fs::rdma::RdmaController;
|
||||
use crate::fs::systemd::SystemdController;
|
||||
use crate::fs::{Controllers, Hierarchy, Subsystem};
|
||||
|
||||
use crate::cgroup::Cgroup;
|
||||
use crate::fs::cgroup::Cgroup;
|
||||
|
||||
/// Process mounts information.
|
||||
///
|
||||
@@ -12,11 +12,11 @@ use log::warn;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::{flat_keyed_to_vec, read_u64_from};
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
use crate::fs::{flat_keyed_to_vec, read_u64_from};
|
||||
|
||||
use crate::{
|
||||
use crate::fs::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, HugePageResources, Resources, Subsystem,
|
||||
};
|
||||
|
||||
@@ -14,14 +14,14 @@ use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::events;
|
||||
use crate::{read_i64_from, read_string_from, read_u64_from};
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
use crate::fs::events;
|
||||
use crate::fs::{read_i64_from, read_string_from, read_u64_from};
|
||||
|
||||
use crate::flat_keyed_to_hashmap;
|
||||
use crate::fs::flat_keyed_to_hashmap;
|
||||
|
||||
use crate::{
|
||||
use crate::fs::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, CustomizedAttribute, MaxValue,
|
||||
MemoryResources, Resources, Subsystem,
|
||||
};
|
||||
@@ -1002,7 +1002,7 @@ impl<'a> From<&'a Subsystem> for &'a MemController {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::memory::{
|
||||
use crate::fs::memory::{
|
||||
parse_memory_stat, parse_numa_stat, parse_oom_control, MemoryStat, NumaStat, OomControl,
|
||||
};
|
||||
|
||||
+1032
File diff suppressed because it is too large
Load Diff
@@ -10,11 +10,11 @@
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::read_u64_from;
|
||||
use crate::{
|
||||
use crate::fs::read_u64_from;
|
||||
use crate::fs::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, NetworkResources, Resources, Subsystem,
|
||||
};
|
||||
|
||||
@@ -11,11 +11,11 @@ use std::collections::HashMap;
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::read_u64_from;
|
||||
use crate::{
|
||||
use crate::fs::read_u64_from;
|
||||
use crate::fs::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, NetworkResources, Resources, Subsystem,
|
||||
};
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
//! [tools/perf/Documentation/perf-record.txt](https://raw.githubusercontent.com/torvalds/linux/master/tools/perf/Documentation/perf-record.txt)
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
use crate::fs::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
|
||||
/// A controller that allows controlling the `perf_event` subsystem of a Cgroup.
|
||||
///
|
||||
@@ -11,11 +11,11 @@
|
||||
use std::io::{Read, Write};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::read_u64_from;
|
||||
use crate::{
|
||||
use crate::fs::read_u64_from;
|
||||
use crate::fs::{
|
||||
parse_max_value, ControllIdentifier, ControllerInternal, Controllers, MaxValue, PidResources,
|
||||
Resources, Subsystem,
|
||||
};
|
||||
@@ -10,11 +10,11 @@
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::ErrorKind::*;
|
||||
use crate::error::*;
|
||||
use crate::fs::error::ErrorKind::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::read_string_from;
|
||||
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
use crate::fs::read_string_from;
|
||||
use crate::fs::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
|
||||
/// A controller that allows controlling the `rdma` subsystem of a Cgroup.
|
||||
///
|
||||
@@ -7,9 +7,9 @@
|
||||
//!
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::*;
|
||||
use crate::fs::error::*;
|
||||
|
||||
use crate::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
use crate::fs::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
|
||||
|
||||
/// A controller that allows controlling the `systemd` subsystem of a Cgroup.
|
||||
///
|
||||
+2
-1027
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user