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 public final class StructCapUserHeader { 35 /** 36 * Version of the header. Note this is not final as capget() may mutate the field when an 37 * invalid version is provided. 38 * 39 * See <a href="http://man7.org/linux/man-pages/man2/capget.2.html">capget(2)</a>. 40 * 41 * @see {@link OsConstants._LINUX_CAPABILITY_VERSION_3}. 42 * 43 * @hide 44 */ 45 public int version; /* __u32 */ 46 47 /** 48 * Pid of the header. The pid a call applies to. 49 * 50 * @hide 51 */ 52 public final int pid; 53 54 /** 55 * Constructs an instance with the given field values. 56 * 57 * @param version linux capability version 58 * @param pid process id 59 * 60 * @hide 61 */ 62 @SystemApi(client = MODULE_LIBRARIES) StructCapUserHeader(int version, int pid)63 public StructCapUserHeader(int version, int pid) { 64 this.version = version; 65 this.pid = pid; 66 } 67 68 /** 69 * @hide 70 */ toString()71 @Override public String toString() { 72 return Objects.toString(this); 73 } 74 } 75