1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cstddef>
20 #include <cstdint>
21 #include <string>
22 
23 namespace android {
24 namespace cgrouprc {
25 namespace format {
26 
27 // Minimal controller description to be mmapped into process address space
28 struct CgroupController {
29   public:
30     CgroupController() = default;
31     CgroupController(uint32_t version, uint32_t flags, const std::string& name,
32                      const std::string& path);
33 
34     uint32_t version() const;
35     uint32_t flags() const;
36     const char* name() const;
37     const char* path() const;
38 
39     void set_flags(uint32_t flags);
40 
41   private:
42     static constexpr size_t CGROUP_NAME_BUF_SZ = 16;
43     static constexpr size_t CGROUP_PATH_BUF_SZ = 32;
44 
45     uint32_t version_ = 0;
46     uint32_t flags_ = 0;
47     char name_[CGROUP_NAME_BUF_SZ] = {};
48     char path_[CGROUP_PATH_BUF_SZ] = {};
49 };
50 
51 }  // namespace format
52 }  // namespace cgrouprc
53 }  // namespace android
54