• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stdint.h>
20 #include <string>
21 
22 namespace android {
23 namespace cgrouprc {
24 namespace format {
25 
26 // Minimal controller description to be mmapped into process address space
27 struct CgroupController {
28   public:
29     CgroupController();
30     CgroupController(uint32_t version, uint32_t flags, const std::string& name,
31                      const std::string& path);
32 
33     uint32_t version() const;
34     uint32_t flags() const;
35     const char* name() const;
36     const char* path() const;
37 
38     void set_flags(uint32_t flags);
39 
40   private:
41     static constexpr size_t CGROUP_NAME_BUF_SZ = 16;
42     static constexpr size_t CGROUP_PATH_BUF_SZ = 32;
43 
44     uint32_t version_;
45     uint32_t flags_;
46     char name_[CGROUP_NAME_BUF_SZ];
47     char path_[CGROUP_PATH_BUF_SZ];
48 };
49 
50 }  // namespace format
51 }  // namespace cgrouprc
52 }  // namespace android
53