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