Skip to main content

libcgroups/systemd/
mod.rs

1use std::fs;
2
3mod controller;
4pub mod controller_type;
5mod cpu;
6mod cpuset;
7mod dbus_native;
8mod io;
9pub mod manager;
10mod memory;
11mod pids;
12mod unified;
13
14/// Checks if the system was booted with systemd
15pub fn booted() -> bool {
16    fs::symlink_metadata("/run/systemd/system")
17        .map(|p| p.is_dir())
18        .unwrap_or_default()
19}
20
21#[macro_export]
22macro_rules! recast {
23    ($v:ident, $t:ty) => {{
24        let mut buf = Vec::new();
25        $v.serialize(&mut buf);
26        let mut ctr = 0;
27        let ret = <$t>::deserialize(&buf, &mut ctr);
28        ret
29    }};
30}