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