cgroups2: make a function declaration-less by moving it earlier
This commit is contained in:
parent
c0e13eebca
commit
3d0bbf6927
24
cgroup2.cc
24
cgroup2.cc
@ -41,7 +41,17 @@
|
|||||||
|
|
||||||
namespace cgroup2 {
|
namespace cgroup2 {
|
||||||
|
|
||||||
static bool addPidToProcList(const std::string &cgroup_path, pid_t pid);
|
static bool addPidToProcList(const std::string &cgroup_path, pid_t pid) {
|
||||||
|
std::string pid_str = std::to_string(pid);
|
||||||
|
|
||||||
|
LOG_D("Adding pid='%s' to cgroup.procs", pid_str.c_str());
|
||||||
|
if (!util::writeBufToFile((cgroup_path + "/cgroup.procs").c_str(), pid_str.c_str(),
|
||||||
|
pid_str.length(), O_WRONLY)) {
|
||||||
|
LOG_W("Could not update cgroup.procs");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string getCgroupPath(nsjconf_t *nsjconf, pid_t pid) {
|
static std::string getCgroupPath(nsjconf_t *nsjconf, pid_t pid) {
|
||||||
return nsjconf->cgroupv2_mount + "/NSJAIL." + std::to_string(pid);
|
return nsjconf->cgroupv2_mount + "/NSJAIL." + std::to_string(pid);
|
||||||
@ -114,18 +124,6 @@ static bool writeToCgroup(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool addPidToProcList(const std::string &cgroup_path, pid_t pid) {
|
|
||||||
std::string pid_str = std::to_string(pid);
|
|
||||||
|
|
||||||
LOG_D("Adding pid='%s' to cgroup.procs", pid_str.c_str());
|
|
||||||
if (!util::writeBufToFile((cgroup_path + "/cgroup.procs").c_str(), pid_str.c_str(),
|
|
||||||
pid_str.length(), O_WRONLY)) {
|
|
||||||
LOG_W("Could not update cgroup.procs");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void removeCgroup(const std::string &cgroup_path) {
|
static void removeCgroup(const std::string &cgroup_path) {
|
||||||
LOG_D("Remove '%s'", cgroup_path.c_str());
|
LOG_D("Remove '%s'", cgroup_path.c_str());
|
||||||
if (rmdir(cgroup_path.c_str()) == -1) {
|
if (rmdir(cgroup_path.c_str()) == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user