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