1 /* 2 * Copyright (C) 2017 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 package android.system; 18 19 import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; 20 21 import android.annotation.SystemApi; 22 23 import libcore.util.Objects; 24 25 /** 26 * Corresponds to Linux' __user_cap_header_struct for capget and capset. 27 * Used in {@link Os.capget(StructCapUserHeader)} and 28 * {@link Os.capset(StructCapUserHeader, StructCapUserData[])}. 29 * 30 * Capabilities defined in <a href="https://man7.org/linux/man-pages/man7/capabilities.7.html">capabilities(7)</a> 31 * @hide 32 */ 33 @SystemApi(client = MODULE_LIBRARIES) 34 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) 35 public final class StructCapUserHeader { 36 /** 37 * Version of the header. Note this is not final as capget() may mutate the field when an 38 * invalid version is provided. 39 * 40 * See <a href="http://man7.org/linux/man-pages/man2/capget.2.html">capget(2)</a>. 41 * 42 * @see {@link OsConstants._LINUX_CAPABILITY_VERSION_3}. 43 * 44 * @hide 45 */ 46 public int version; /* __u32 */ 47 48 /** 49 * Pid of the header. The pid a call applies to. 50 * 51 * @hide 52 */ 53 public final int pid; 54 55 /** 56 * Constructs an instance with the given field values. 57 * 58 * @param version linux capability version 59 * @param pid process id 60 * 61 * @hide 62 */ 63 @SystemApi(client = MODULE_LIBRARIES) 64 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE) StructCapUserHeader(int version, int pid)65 public StructCapUserHeader(int version, int pid) { 66 this.version = version; 67 this.pid = pid; 68 } 69 70 /** 71 * @hide 72 */ toString()73 @Override public String toString() { 74 return Objects.toString(this); 75 } 76 } 77