From 148c2531eef1881a5034615f8248bef2d0d92d7c Mon Sep 17 00:00:00 2001 From: "T.J. Mercier" Date: Thu, 14 Nov 2024 22:43:16 +0000 Subject: [PATCH 1/4] libprocessgroup: Remove CGROUPS_RC_PATH /dev/cgroup_info/cgroup.rc doesn't exist anymore! Bug: 349105928 Change-Id: I2f49fab15d083f0c1617989ccf96ca843f998140 --- libprocessgroup/include/processgroup/processgroup.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libprocessgroup/include/processgroup/processgroup.h b/libprocessgroup/include/processgroup/processgroup.h index 805775744..85796ea8e 100644 --- a/libprocessgroup/include/processgroup/processgroup.h +++ b/libprocessgroup/include/processgroup/processgroup.h @@ -57,8 +57,6 @@ __BEGIN_DECLS bool SetProcessProfilesCached(uid_t uid, pid_t pid, const std::vector& profiles); -[[deprecated]] static constexpr const char* CGROUPS_RC_PATH = "/dev/cgroup_info/cgroup.rc"; - bool UsePerAppMemcg(); // Drop the fd cache of cgroup path. It is used for when resource caching is enabled and a process From 9e5f74d4e466b00777667b147ca8eac77ea26805 Mon Sep 17 00:00:00 2001 From: "T.J. Mercier" Date: Wed, 7 Aug 2024 16:41:32 +0000 Subject: [PATCH 2/4] libprocessgroup: Remove CGROUPV2_CONTROLLER_NAME This was deprecated a year ago, and should no longer be used. Change-Id: I19c75e50fd3cc86734fa9cc7f3d883260b2484ca --- libprocessgroup/include/processgroup/processgroup.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libprocessgroup/include/processgroup/processgroup.h b/libprocessgroup/include/processgroup/processgroup.h index 85796ea8e..02f7c2508 100644 --- a/libprocessgroup/include/processgroup/processgroup.h +++ b/libprocessgroup/include/processgroup/processgroup.h @@ -27,7 +27,6 @@ __BEGIN_DECLS static constexpr const char* CGROUPV2_HIERARCHY_NAME = "cgroup2"; -[[deprecated]] static constexpr const char* CGROUPV2_CONTROLLER_NAME = "cgroup2"; bool CgroupsAvailable(); bool CgroupGetControllerPath(const std::string& cgroup_name, std::string* path); From b6071f19c318fd19ed37d9fa4ba0cf77d7d32d13 Mon Sep 17 00:00:00 2001 From: "T.J. Mercier" Date: Wed, 7 Aug 2024 16:35:55 +0000 Subject: [PATCH 3/4] libprocessgroup: Convert CGROUPV2_HIERARCHY_NAME to std::string Almost everywhere CGROUPV2_HIERARCHY_NAME is used a std::string is required, so change its type to avoid temporaries. Change-Id: I4466838c510f2eb8212fc71999cdaa47359ce9c3 --- libprocessgroup/include/processgroup/processgroup.h | 2 +- libprocessgroup/setup/cgroup_map_write.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libprocessgroup/include/processgroup/processgroup.h b/libprocessgroup/include/processgroup/processgroup.h index 02f7c2508..d27b56895 100644 --- a/libprocessgroup/include/processgroup/processgroup.h +++ b/libprocessgroup/include/processgroup/processgroup.h @@ -26,7 +26,7 @@ __BEGIN_DECLS -static constexpr const char* CGROUPV2_HIERARCHY_NAME = "cgroup2"; +static constexpr std::string CGROUPV2_HIERARCHY_NAME = "cgroup2"; bool CgroupsAvailable(); bool CgroupGetControllerPath(const std::string& cgroup_name, std::string* path); diff --git a/libprocessgroup/setup/cgroup_map_write.cpp b/libprocessgroup/setup/cgroup_map_write.cpp index d05bf2408..c4e1fb680 100644 --- a/libprocessgroup/setup/cgroup_map_write.cpp +++ b/libprocessgroup/setup/cgroup_map_write.cpp @@ -222,7 +222,7 @@ static bool SetupCgroup(const CgroupDescriptor& descriptor) { const CgroupController* controller = descriptor.controller(); if (controller->version() == 2) { - if (!strcmp(controller->name(), CGROUPV2_HIERARCHY_NAME)) { + if (controller->name() == CGROUPV2_HIERARCHY_NAME) { return MountV2CgroupController(descriptor); } else { return ActivateV2CgroupController(descriptor); From fdf4432356ddb597f46cfb7b047ab4e0bb808ba2 Mon Sep 17 00:00:00 2001 From: "T.J. Mercier" Date: Thu, 14 Nov 2024 23:04:10 +0000 Subject: [PATCH 4/4] libprocessgroup: Remove __BEGIN_DECLS and __END_DECLS These macros have been useless in this file since commit 82b72a566 ("libprocessgroup: Add support for task profiles") in 2018 which added C++ includes, and C++ types and keywords inside an extern "C" block. Change-Id: Iae1cbfcc5cb974034d88fb466b79088496190940 --- libprocessgroup/include/processgroup/processgroup.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libprocessgroup/include/processgroup/processgroup.h b/libprocessgroup/include/processgroup/processgroup.h index d27b56895..6a026a717 100644 --- a/libprocessgroup/include/processgroup/processgroup.h +++ b/libprocessgroup/include/processgroup/processgroup.h @@ -16,7 +16,6 @@ #pragma once -#include #include #include #include @@ -24,8 +23,6 @@ #include #include -__BEGIN_DECLS - static constexpr std::string CGROUPV2_HIERARCHY_NAME = "cgroup2"; bool CgroupsAvailable(); @@ -39,8 +36,6 @@ bool SetTaskProfiles(pid_t tid, const std::vector& profiles, bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector& profiles); bool SetUserProfiles(uid_t uid, const std::vector& profiles); -__END_DECLS - bool SetTaskProfiles(pid_t tid, std::initializer_list profiles, bool use_fd_cache = false); bool SetProcessProfiles(uid_t uid, pid_t pid, std::initializer_list profiles); @@ -50,7 +45,6 @@ bool SetTaskProfiles(pid_t tid, std::span profiles, bool SetProcessProfiles(uid_t uid, pid_t pid, std::span profiles); #endif -__BEGIN_DECLS #ifndef __ANDROID_VNDK__ @@ -96,5 +90,3 @@ bool getAttributePathForTask(const std::string& attr_name, pid_t tid, std::strin bool isProfileValidForProcess(const std::string& profile_name, uid_t uid, pid_t pid); #endif // __ANDROID_VNDK__ - -__END_DECLS