1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later 2*49cdfc7eSAndroid Build Coastguard Worker /* 3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2020 Linaro Limited. All rights reserved. 4*49cdfc7eSAndroid Build Coastguard Worker * Author: Viresh Kumar <[email protected]> 5*49cdfc7eSAndroid Build Coastguard Worker */ 6*49cdfc7eSAndroid Build Coastguard Worker 7*49cdfc7eSAndroid Build Coastguard Worker #ifndef LAPI_IPCBUF_H__ 8*49cdfc7eSAndroid Build Coastguard Worker #define LAPI_IPCBUF_H__ 9*49cdfc7eSAndroid Build Coastguard Worker 10*49cdfc7eSAndroid Build Coastguard Worker #include "config.h" 11*49cdfc7eSAndroid Build Coastguard Worker #include "lapi/posix_types.h" 12*49cdfc7eSAndroid Build Coastguard Worker 13*49cdfc7eSAndroid Build Coastguard Worker #ifndef HAVE_STRUCT_IPC64_PERM 14*49cdfc7eSAndroid Build Coastguard Worker 15*49cdfc7eSAndroid Build Coastguard Worker #if defined(__hppa__) 16*49cdfc7eSAndroid Build Coastguard Worker #define HAVE_IPC64_PERM 17*49cdfc7eSAndroid Build Coastguard Worker /* 18*49cdfc7eSAndroid Build Coastguard Worker * The ipc64_perm structure for PA-RISC is almost identical to 19*49cdfc7eSAndroid Build Coastguard Worker * kern_ipc_perm as we have always had 32-bit UIDs and GIDs in the kernel. 20*49cdfc7eSAndroid Build Coastguard Worker * 'seq' has been changed from long to int so that it's the same size 21*49cdfc7eSAndroid Build Coastguard Worker * on 64-bit kernels as on 32-bit ones. 22*49cdfc7eSAndroid Build Coastguard Worker */ 23*49cdfc7eSAndroid Build Coastguard Worker 24*49cdfc7eSAndroid Build Coastguard Worker struct ipc64_perm 25*49cdfc7eSAndroid Build Coastguard Worker { 26*49cdfc7eSAndroid Build Coastguard Worker __kernel_key_t key; 27*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid_t uid; 28*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid_t gid; 29*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid_t cuid; 30*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid_t cgid; 31*49cdfc7eSAndroid Build Coastguard Worker #if __BITS_PER_LONG != 64 32*49cdfc7eSAndroid Build Coastguard Worker unsigned short int __pad1; 33*49cdfc7eSAndroid Build Coastguard Worker #endif 34*49cdfc7eSAndroid Build Coastguard Worker __kernel_mode_t mode; 35*49cdfc7eSAndroid Build Coastguard Worker unsigned short int __pad2; 36*49cdfc7eSAndroid Build Coastguard Worker unsigned short int seq; 37*49cdfc7eSAndroid Build Coastguard Worker unsigned int __pad3; 38*49cdfc7eSAndroid Build Coastguard Worker unsigned long long int __unused1; 39*49cdfc7eSAndroid Build Coastguard Worker unsigned long long int __unused2; 40*49cdfc7eSAndroid Build Coastguard Worker }; 41*49cdfc7eSAndroid Build Coastguard Worker #endif /* __hppa__ */ 42*49cdfc7eSAndroid Build Coastguard Worker 43*49cdfc7eSAndroid Build Coastguard Worker #if defined(__powerpc__) || defined(__powerpc64__) 44*49cdfc7eSAndroid Build Coastguard Worker #define HAVE_IPC64_PERM 45*49cdfc7eSAndroid Build Coastguard Worker /* 46*49cdfc7eSAndroid Build Coastguard Worker * The ipc64_perm structure for the powerpc is identical to 47*49cdfc7eSAndroid Build Coastguard Worker * kern_ipc_perm as we have always had 32-bit UIDs and GIDs in the 48*49cdfc7eSAndroid Build Coastguard Worker * kernel. Note extra padding because this structure is passed back 49*49cdfc7eSAndroid Build Coastguard Worker * and forth between kernel and user space. Pad space is left for: 50*49cdfc7eSAndroid Build Coastguard Worker * - 1 32-bit value to fill up for 8-byte alignment 51*49cdfc7eSAndroid Build Coastguard Worker * - 2 miscellaneous 64-bit values 52*49cdfc7eSAndroid Build Coastguard Worker */ 53*49cdfc7eSAndroid Build Coastguard Worker 54*49cdfc7eSAndroid Build Coastguard Worker struct ipc64_perm 55*49cdfc7eSAndroid Build Coastguard Worker { 56*49cdfc7eSAndroid Build Coastguard Worker __kernel_key_t key; 57*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid_t uid; 58*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid_t gid; 59*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid_t cuid; 60*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid_t cgid; 61*49cdfc7eSAndroid Build Coastguard Worker __kernel_mode_t mode; 62*49cdfc7eSAndroid Build Coastguard Worker unsigned int seq; 63*49cdfc7eSAndroid Build Coastguard Worker unsigned int __pad1; 64*49cdfc7eSAndroid Build Coastguard Worker unsigned long long __unused1; 65*49cdfc7eSAndroid Build Coastguard Worker unsigned long long __unused2; 66*49cdfc7eSAndroid Build Coastguard Worker }; 67*49cdfc7eSAndroid Build Coastguard Worker 68*49cdfc7eSAndroid Build Coastguard Worker #endif /* defined(__powerpc__) || defined(__powerpc64__) */ 69*49cdfc7eSAndroid Build Coastguard Worker 70*49cdfc7eSAndroid Build Coastguard Worker #if defined(__s390__) 71*49cdfc7eSAndroid Build Coastguard Worker #define HAVE_IPC64_PERM 72*49cdfc7eSAndroid Build Coastguard Worker /* 73*49cdfc7eSAndroid Build Coastguard Worker * The user_ipc_perm structure for S/390 architecture. 74*49cdfc7eSAndroid Build Coastguard Worker * Note extra padding because this structure is passed back and forth 75*49cdfc7eSAndroid Build Coastguard Worker * between kernel and user space. 76*49cdfc7eSAndroid Build Coastguard Worker * 77*49cdfc7eSAndroid Build Coastguard Worker * Pad space is left for: 78*49cdfc7eSAndroid Build Coastguard Worker * - 32-bit mode_t and seq 79*49cdfc7eSAndroid Build Coastguard Worker * - 2 miscellaneous 32-bit values 80*49cdfc7eSAndroid Build Coastguard Worker */ 81*49cdfc7eSAndroid Build Coastguard Worker 82*49cdfc7eSAndroid Build Coastguard Worker struct ipc64_perm 83*49cdfc7eSAndroid Build Coastguard Worker { 84*49cdfc7eSAndroid Build Coastguard Worker __kernel_key_t key; 85*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t uid; 86*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t gid; 87*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t cuid; 88*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t cgid; 89*49cdfc7eSAndroid Build Coastguard Worker __kernel_mode_t mode; 90*49cdfc7eSAndroid Build Coastguard Worker unsigned short __pad1; 91*49cdfc7eSAndroid Build Coastguard Worker unsigned short seq; 92*49cdfc7eSAndroid Build Coastguard Worker #ifndef __s390x__ 93*49cdfc7eSAndroid Build Coastguard Worker unsigned short __pad2; 94*49cdfc7eSAndroid Build Coastguard Worker #endif /* ! __s390x__ */ 95*49cdfc7eSAndroid Build Coastguard Worker unsigned long __unused1; 96*49cdfc7eSAndroid Build Coastguard Worker unsigned long __unused2; 97*49cdfc7eSAndroid Build Coastguard Worker }; 98*49cdfc7eSAndroid Build Coastguard Worker 99*49cdfc7eSAndroid Build Coastguard Worker #endif /* defined(__powerpc__) || defined(__powerpc64__) */ 100*49cdfc7eSAndroid Build Coastguard Worker 101*49cdfc7eSAndroid Build Coastguard Worker #if defined(__sparc__) 102*49cdfc7eSAndroid Build Coastguard Worker #define HAVE_IPC64_PERM 103*49cdfc7eSAndroid Build Coastguard Worker /* 104*49cdfc7eSAndroid Build Coastguard Worker * The ipc64_perm structure for sparc/sparc64 architecture. 105*49cdfc7eSAndroid Build Coastguard Worker * Note extra padding because this structure is passed back and forth 106*49cdfc7eSAndroid Build Coastguard Worker * between kernel and user space. 107*49cdfc7eSAndroid Build Coastguard Worker * 108*49cdfc7eSAndroid Build Coastguard Worker * Pad space is left for: 109*49cdfc7eSAndroid Build Coastguard Worker * - 32-bit seq 110*49cdfc7eSAndroid Build Coastguard Worker * - on sparc for 32 bit mode (it is 32 bit on sparc64) 111*49cdfc7eSAndroid Build Coastguard Worker * - 2 miscellaneous 64-bit values 112*49cdfc7eSAndroid Build Coastguard Worker */ 113*49cdfc7eSAndroid Build Coastguard Worker 114*49cdfc7eSAndroid Build Coastguard Worker struct ipc64_perm 115*49cdfc7eSAndroid Build Coastguard Worker { 116*49cdfc7eSAndroid Build Coastguard Worker __kernel_key_t key; 117*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t uid; 118*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t gid; 119*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t cuid; 120*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t cgid; 121*49cdfc7eSAndroid Build Coastguard Worker #ifndef __arch64__ 122*49cdfc7eSAndroid Build Coastguard Worker unsigned short __pad0; 123*49cdfc7eSAndroid Build Coastguard Worker #endif 124*49cdfc7eSAndroid Build Coastguard Worker __kernel_mode_t mode; 125*49cdfc7eSAndroid Build Coastguard Worker unsigned short __pad1; 126*49cdfc7eSAndroid Build Coastguard Worker unsigned short seq; 127*49cdfc7eSAndroid Build Coastguard Worker unsigned long long __unused1; 128*49cdfc7eSAndroid Build Coastguard Worker unsigned long long __unused2; 129*49cdfc7eSAndroid Build Coastguard Worker }; 130*49cdfc7eSAndroid Build Coastguard Worker 131*49cdfc7eSAndroid Build Coastguard Worker #endif /* __sparc__ */ 132*49cdfc7eSAndroid Build Coastguard Worker 133*49cdfc7eSAndroid Build Coastguard Worker #if defined(__xtensa__) 134*49cdfc7eSAndroid Build Coastguard Worker #define HAVE_IPC64_PERM 135*49cdfc7eSAndroid Build Coastguard Worker /* 136*49cdfc7eSAndroid Build Coastguard Worker * Pad space is left for: 137*49cdfc7eSAndroid Build Coastguard Worker * - 32-bit mode_t and seq 138*49cdfc7eSAndroid Build Coastguard Worker * - 2 miscellaneous 32-bit values 139*49cdfc7eSAndroid Build Coastguard Worker * 140*49cdfc7eSAndroid Build Coastguard Worker * This file is subject to the terms and conditions of the GNU General 141*49cdfc7eSAndroid Build Coastguard Worker * Public License. See the file "COPYING" in the main directory of 142*49cdfc7eSAndroid Build Coastguard Worker * this archive for more details. 143*49cdfc7eSAndroid Build Coastguard Worker */ 144*49cdfc7eSAndroid Build Coastguard Worker 145*49cdfc7eSAndroid Build Coastguard Worker struct ipc64_perm 146*49cdfc7eSAndroid Build Coastguard Worker { 147*49cdfc7eSAndroid Build Coastguard Worker __kernel_key_t key; 148*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t uid; 149*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t gid; 150*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t cuid; 151*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t cgid; 152*49cdfc7eSAndroid Build Coastguard Worker __kernel_mode_t mode; 153*49cdfc7eSAndroid Build Coastguard Worker unsigned long seq; 154*49cdfc7eSAndroid Build Coastguard Worker unsigned long __unused1; 155*49cdfc7eSAndroid Build Coastguard Worker unsigned long __unused2; 156*49cdfc7eSAndroid Build Coastguard Worker }; 157*49cdfc7eSAndroid Build Coastguard Worker 158*49cdfc7eSAndroid Build Coastguard Worker #endif /* __xtensa__ */ 159*49cdfc7eSAndroid Build Coastguard Worker 160*49cdfc7eSAndroid Build Coastguard Worker #ifndef HAVE_IPC64_PERM 161*49cdfc7eSAndroid Build Coastguard Worker /* 162*49cdfc7eSAndroid Build Coastguard Worker * The generic ipc64_perm structure: 163*49cdfc7eSAndroid Build Coastguard Worker * Note extra padding because this structure is passed back and forth 164*49cdfc7eSAndroid Build Coastguard Worker * between kernel and user space. 165*49cdfc7eSAndroid Build Coastguard Worker * 166*49cdfc7eSAndroid Build Coastguard Worker * ipc64_perm was originally meant to be architecture specific, but 167*49cdfc7eSAndroid Build Coastguard Worker * everyone just ended up making identical copies without specific 168*49cdfc7eSAndroid Build Coastguard Worker * optimizations, so we may just as well all use the same one. 169*49cdfc7eSAndroid Build Coastguard Worker * 170*49cdfc7eSAndroid Build Coastguard Worker * Pad space is left for: 171*49cdfc7eSAndroid Build Coastguard Worker * - 32-bit mode_t on architectures that only had 16 bit 172*49cdfc7eSAndroid Build Coastguard Worker * - 32-bit seq 173*49cdfc7eSAndroid Build Coastguard Worker * - 2 miscellaneous 32-bit values 174*49cdfc7eSAndroid Build Coastguard Worker */ 175*49cdfc7eSAndroid Build Coastguard Worker 176*49cdfc7eSAndroid Build Coastguard Worker struct ipc64_perm { 177*49cdfc7eSAndroid Build Coastguard Worker __kernel_key_t key; 178*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t uid; 179*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t gid; 180*49cdfc7eSAndroid Build Coastguard Worker __kernel_uid32_t cuid; 181*49cdfc7eSAndroid Build Coastguard Worker __kernel_gid32_t cgid; 182*49cdfc7eSAndroid Build Coastguard Worker __kernel_mode_t mode; 183*49cdfc7eSAndroid Build Coastguard Worker /* pad if mode_t is u16: */ 184*49cdfc7eSAndroid Build Coastguard Worker unsigned char __pad1[4 - sizeof(__kernel_mode_t)]; 185*49cdfc7eSAndroid Build Coastguard Worker unsigned short seq; 186*49cdfc7eSAndroid Build Coastguard Worker unsigned short __pad2; 187*49cdfc7eSAndroid Build Coastguard Worker __kernel_ulong_t __unused1; 188*49cdfc7eSAndroid Build Coastguard Worker __kernel_ulong_t __unused2; 189*49cdfc7eSAndroid Build Coastguard Worker }; 190*49cdfc7eSAndroid Build Coastguard Worker 191*49cdfc7eSAndroid Build Coastguard Worker #endif /* ipc64_perm */ 192*49cdfc7eSAndroid Build Coastguard Worker 193*49cdfc7eSAndroid Build Coastguard Worker #endif /* HAVE_IPC64_PERM */ 194*49cdfc7eSAndroid Build Coastguard Worker 195*49cdfc7eSAndroid Build Coastguard Worker #endif /* LAPI_IPCBUF_H__ */ 196