• 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 <sys/cdefs.h>
20 #include <stdint.h>
21 
22 __BEGIN_DECLS
23 
24 struct ACgroupController;
25 typedef struct ACgroupController ACgroupController;
26 
27 // ACgroupFile
28 
29 /**
30  * Returns file version. See android::cgrouprc::format::CgroupFile for a list of valid versions
31  * for the file.
32  * If ACgroupFile_init() isn't called, initialization will be done first.
33  * If initialization failed, return 0.
34  */
35 __attribute__((warn_unused_result)) uint32_t ACgroupFile_getVersion() __INTRODUCED_IN(29);
36 
37 /**
38  * Returns the number of controllers.
39  * If ACgroupFile_init() isn't called, initialization will be done first.
40  * If initialization failed, return 0.
41  */
42 __attribute__((warn_unused_result)) uint32_t ACgroupFile_getControllerCount() __INTRODUCED_IN(29);
43 
44 /**
45  * Returns the controller at the given index.
46  * Returnss nullptr if the given index exceeds getControllerCount().
47  * If ACgroupFile_init() isn't called, initialization will be done first.
48  * If initialization failed, return 0.
49  */
50 __attribute__((warn_unused_result)) const ACgroupController* ACgroupFile_getController(
51         uint32_t index) __INTRODUCED_IN(29);
52 
53 // ACgroupController
54 
55 /**
56  * Returns the version of the given controller.
57  * If the given controller is null, return 0.
58  */
59 __attribute__((warn_unused_result)) uint32_t ACgroupController_getVersion(const ACgroupController*)
60         __INTRODUCED_IN(29);
61 
62 /**
63  * Flag bitmask used in ACgroupController_getFlags
64  */
65 #define CGROUPRC_CONTROLLER_FLAG_MOUNTED 0x1
66 #define CGROUPRC_CONTROLLER_FLAG_NEEDS_ACTIVATION 0x2
67 #define CGROUPRC_CONTROLLER_FLAG_OPTIONAL 0x4
68 
69 /**
70  * Returns the flags bitmask of the given controller.
71  * If the given controller is null, return 0.
72  */
73 __attribute__((warn_unused_result, weak)) uint32_t ACgroupController_getFlags(
74         const ACgroupController*) __INTRODUCED_IN(30);
75 
76 /**
77  * Returns the name of the given controller.
78  * If the given controller is null, return nullptr.
79  */
80 __attribute__((warn_unused_result)) const char* ACgroupController_getName(const ACgroupController*)
81         __INTRODUCED_IN(29);
82 
83 /**
84  * Returns the path of the given controller.
85  * If the given controller is null, return nullptr.
86  */
87 __attribute__((warn_unused_result)) const char* ACgroupController_getPath(const ACgroupController*)
88         __INTRODUCED_IN(29);
89 
90 __END_DECLS
91