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