Loading init/util_test.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,9 @@ TEST(util, ReadFileWorldWiteable) { TEST(util, ReadFileSymbolicLink) { errno = 0; // lrw------- 1 root root 23 2008-12-31 19:00 default.prop -> system/etc/prop.default auto file_contents = ReadFile("/default.prop"); // lrwxrwxrwx 1 root shell 6 2020-06-26 09:55 /system/bin/ps -> toybox auto file_contents = ReadFile("/system/bin/ps"); EXPECT_EQ(ELOOP, errno); ASSERT_FALSE(file_contents.ok()); EXPECT_EQ("open() failed: Too many symbolic links encountered", Loading libprocessgroup/task_profiles.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -44,6 +44,11 @@ using android::base::WriteStringToFile; #define TASK_PROFILE_DB_FILE "/etc/task_profiles.json" #define TASK_PROFILE_DB_VENDOR_FILE "/vendor/etc/task_profiles.json" void ProfileAttribute::Reset(const CgroupController& controller, const std::string& file_name) { controller_ = controller; file_name_ = file_name; } bool ProfileAttribute::GetPathForTask(int tid, std::string* path) const { std::string subgroup; if (!controller()->GetTaskGroup(tid, &subgroup)) { Loading Loading @@ -380,15 +385,16 @@ bool TaskProfiles::Load(const CgroupMap& cg_map, const std::string& file_name) { std::string controller_name = attr[i]["Controller"].asString(); std::string file_attr = attr[i]["File"].asString(); if (attributes_.find(name) == attributes_.end()) { auto controller = cg_map.FindController(controller_name); if (controller.HasValue()) { auto iter = attributes_.find(name); if (iter == attributes_.end()) { attributes_[name] = std::make_unique<ProfileAttribute>(controller, file_attr); } else { LOG(WARNING) << "Controller " << controller_name << " is not found"; iter->second->Reset(controller, file_attr); } } else { LOG(WARNING) << "Attribute " << name << " is already defined"; LOG(WARNING) << "Controller " << controller_name << " is not found"; } } Loading libprocessgroup/task_profiles.h +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ class ProfileAttribute { const CgroupController* controller() const { return &controller_; } const std::string& file_name() const { return file_name_; } void Reset(const CgroupController& controller, const std::string& file_name); bool GetPathForTask(int tid, std::string* path) const; Loading Loading
init/util_test.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,9 @@ TEST(util, ReadFileWorldWiteable) { TEST(util, ReadFileSymbolicLink) { errno = 0; // lrw------- 1 root root 23 2008-12-31 19:00 default.prop -> system/etc/prop.default auto file_contents = ReadFile("/default.prop"); // lrwxrwxrwx 1 root shell 6 2020-06-26 09:55 /system/bin/ps -> toybox auto file_contents = ReadFile("/system/bin/ps"); EXPECT_EQ(ELOOP, errno); ASSERT_FALSE(file_contents.ok()); EXPECT_EQ("open() failed: Too many symbolic links encountered", Loading
libprocessgroup/task_profiles.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -44,6 +44,11 @@ using android::base::WriteStringToFile; #define TASK_PROFILE_DB_FILE "/etc/task_profiles.json" #define TASK_PROFILE_DB_VENDOR_FILE "/vendor/etc/task_profiles.json" void ProfileAttribute::Reset(const CgroupController& controller, const std::string& file_name) { controller_ = controller; file_name_ = file_name; } bool ProfileAttribute::GetPathForTask(int tid, std::string* path) const { std::string subgroup; if (!controller()->GetTaskGroup(tid, &subgroup)) { Loading Loading @@ -380,15 +385,16 @@ bool TaskProfiles::Load(const CgroupMap& cg_map, const std::string& file_name) { std::string controller_name = attr[i]["Controller"].asString(); std::string file_attr = attr[i]["File"].asString(); if (attributes_.find(name) == attributes_.end()) { auto controller = cg_map.FindController(controller_name); if (controller.HasValue()) { auto iter = attributes_.find(name); if (iter == attributes_.end()) { attributes_[name] = std::make_unique<ProfileAttribute>(controller, file_attr); } else { LOG(WARNING) << "Controller " << controller_name << " is not found"; iter->second->Reset(controller, file_attr); } } else { LOG(WARNING) << "Attribute " << name << " is already defined"; LOG(WARNING) << "Controller " << controller_name << " is not found"; } } Loading
libprocessgroup/task_profiles.h +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ class ProfileAttribute { const CgroupController* controller() const { return &controller_; } const std::string& file_name() const { return file_name_; } void Reset(const CgroupController& controller, const std::string& file_name); bool GetPathForTask(int tid, std::string* path) const; Loading