1 %/* 2 % * CDDL HEADER START 3 % * 4 % * The contents of this file are subject to the terms of the 5 % * Common Development and Distribution License (the "License"). 6 % * You may not use this file except in compliance with the License. 7 % * 8 % * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 % * or http://www.opensolaris.org/os/licensing. 10 % * See the License for the specific language governing permissions 11 % * and limitations under the License. 12 % * 13 % * When distributing Covered Code, include this CDDL HEADER in each 14 % * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 % * If applicable, add the following below this CDDL HEADER, with the 16 % * fields enclosed by brackets "[]" replaced with your own identifying 17 % * information: Portions Copyright [yyyy] [name of copyright owner] 18 % * 19 % * CDDL HEADER END 20 % */ 21 % 22 %/* 23 % * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 % * Use is subject to license terms. 25 % */ 26 % 27 28 %/* get timeval32 definition */ 29 %#include <sys/types32.h> 30 31 #ifndef _KERNEL 32 %#ifdef _KERNEL 33 %#error "Compiling kernel file rpcgened without _KERNEL define." 34 %#endif /* _KERNEL */ 35 #endif /* _KERNEL */ 36 %#include <sys/dditypes.h> 37 38 #ifdef RPC_XDR 39 #ifndef _KERNEL 40 %bool_t 41 %xdr_uint_t(XDR *xdrs, uint_t *objp) 42 %{ 43 % if (!xdr_u_int(xdrs, (u_int *)objp)) 44 % return (FALSE); 45 % return (TRUE); 46 %} 47 %bool_t 48 %xdr_ushort_t(XDR *xdrs, ushort_t *objp) 49 %{ 50 % if (!xdr_u_short(xdrs, (u_short *)objp)) 51 % return (FALSE); 52 % return (TRUE); 53 %} 54 %bool_t 55 %xdr_dev_t(XDR *xdrs, dev_t *objp) 56 %{ 57 % if (!xdr_u_int(xdrs, (u_int *)objp)) 58 % return (FALSE); 59 % return (TRUE); 60 %} 61 %bool_t 62 %xdr_dev32_t(XDR *xdrs, dev32_t *objp) 63 %{ 64 % if (!xdr_u_int(xdrs, (u_int *)objp)) 65 % return (FALSE); 66 % return (TRUE); 67 %} 68 %bool_t 69 %xdr_md_dev64_t(XDR *xdrs, md_dev64_t *objp) 70 %{ 71 % if (!xdr_u_longlong_t(xdrs, objp)) 72 % return (FALSE); 73 % return (TRUE); 74 %} 75 %bool_t 76 %xdr_size_t(XDR *xdrs, size_t *objp) 77 %{ 78 % if (!xdr_u_int(xdrs, (u_int *) objp)) 79 % return (FALSE); 80 % return (TRUE); 81 %} 82 %bool_t 83 %xdr_daddr_t(XDR *xdrs, daddr_t *objp) 84 %{ 85 % if (!xdr_int(xdrs, (int *) objp)) 86 % return (FALSE); 87 % return (TRUE); 88 %} 89 %bool_t 90 %xdr_daddr32_t(XDR *xdrs, daddr32_t *objp) 91 %{ 92 % if (!xdr_int(xdrs, (int *) objp)) 93 % return (FALSE); 94 % return (TRUE); 95 %} 96 %bool_t 97 %xdr_diskaddr_t(XDR *xdrs, diskaddr_t *objp) 98 %{ 99 % if (!xdr_u_longlong_t(xdrs, objp)) 100 % return (FALSE); 101 % return (TRUE); 102 %} 103 %bool_t 104 %xdr_ddi_devid_t(XDR *xdrs, ddi_devid_t *objp) 105 %{ 106 % /* device ids not supported for non-local sets */ 107 % return (TRUE); 108 %} 109 %bool_t 110 %xdr_off_t(XDR *xdrs, off_t *objp) 111 %{ 112 % if (!xdr_int(xdrs, (int *) objp)) 113 % return (FALSE); 114 % return (TRUE); 115 %} 116 %bool_t 117 %xdr_timeval(XDR *xdrs, struct timeval *objp) 118 %{ 119 % if (!xdr_int(xdrs, (int *)&objp->tv_sec)) 120 % return (FALSE); 121 % if (!xdr_int(xdrs, (int *)&objp->tv_usec)) 122 % return (FALSE); 123 % return (TRUE); 124 %} 125 % 126 %bool_t 127 %xdr_md_timeval32_t(XDR *xdrs, md_timeval32_t *objp) 128 %{ 129 % if (!xdr_int(xdrs, &objp->tv_sec)) 130 % return (FALSE); 131 % if (!xdr_int(xdrs, &objp->tv_usec)) 132 % return (FALSE); 133 % return (TRUE); 134 %} 135 % 136 #else /* _KERNEL */ 137 %#ifdef _LP64 138 %bool_t 139 %xdr_timeval(XDR *xdrs, struct timeval *objp) 140 %{ 141 % struct timeval32 tv32; 142 % if (xdrs->x_op == XDR_ENCODE) 143 % TIMEVAL_TO_TIMEVAL32(&tv32, objp); 144 % if (!xdr_int(xdrs, &tv32.tv_sec)) 145 % return (FALSE); 146 % if (!xdr_int(xdrs, &tv32.tv_usec)) 147 % return (FALSE); 148 % if (xdrs->x_op == XDR_DECODE) 149 % TIMEVAL32_TO_TIMEVAL(objp, &tv32); 150 % return (TRUE); 151 %} 152 %#else /* !_LP64 */ 153 %bool_t 154 %xdr_timeval(XDR *xdrs, struct timeval *objp) 155 %{ 156 % if (!xdr_int(xdrs, (int *)&objp->tv_sec)) 157 % return (FALSE); 158 % if (!xdr_int(xdrs, (int *)&objp->tv_usec)) 159 % return (FALSE); 160 % return (TRUE); 161 %} 162 %#endif /* _LP64 */ 163 #endif /* !_KERNEL */ 164 % 165 %bool_t 166 %xdr_minor_t(XDR *xdrs, minor_t *objp) 167 %{ 168 % if (!xdr_u_int(xdrs, (u_int *)objp)) 169 % return (FALSE); 170 % return (TRUE); 171 %} 172 % 173 %bool_t 174 %xdr_clnt_stat(XDR *xdrs, enum clnt_stat *objp) 175 %{ 176 % if (!xdr_enum(xdrs, (enum_t *)objp)) 177 % return (FALSE); 178 % return (TRUE); 179 %} 180 % 181 #ifdef _KERNEL 182 % 183 %#define LASTUNSIGNED ((u_int)0-1) 184 % 185 %/* 186 % * xdr_vector(): 187 % * 188 % * XDR a fixed length array. Unlike variable-length arrays, 189 % * the storage of fixed length arrays is static and unfreeable. 190 % * > basep: base of the array 191 % * > size: size of the array 192 % * > elemsize: size of each element 193 % * > xdr_elem: routine to XDR each element 194 % */ 195 %bool_t 196 %xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) 197 % XDR *xdrs; 198 % char *basep; 199 % u_int nelem; 200 % u_int elemsize; 201 % xdrproc_t xdr_elem; 202 %{ 203 % u_int i; 204 % char *elptr; 205 % 206 % elptr = basep; 207 % for (i = 0; i < nelem; i++) { 208 % if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) { 209 % return (FALSE); 210 % } 211 % elptr += elemsize; 212 % } 213 % return (TRUE); 214 %} 215 #endif /* _KERNEL */ 216 #endif /* RPC_XDR */ 217 218 #ifdef RPC_HDR 219 % 220 %/* 221 % * Some constants 222 % */ 223 const MD_MAX_SETNAME = 50; 224 const MD_MAX_NODENAME = 63; 225 const MAX_HOST_ADDRS = 3; 226 const MD_MAX_MNNODENAME = 256; 227 228 const MED_MAX_HOSTS = 3; 229 const MED_DEF_HOSTS = 3; 230 231 const MD_MAXSIDES = 8; 232 const MD_LOCAL_SET = 0; 233 234 const MD_MNMAXSIDES = 128; 235 const MDDB_SN_LEN = 12; 236 const MDDB_MINOR_NAME_MAX = 32; 237 const MD_MAXDRVNM = 16; 238 239 const MD_MAX_BLKS_FOR_SMALL_DEVS = 2147483647; 240 %#define MD_MAX_BLKS_FOR_EXTVTOC 4294967295ULL 241 % 242 %/* Minimum number of metadevice database replicas needed */ 243 const MD_MINREPLICAS = 1; 244 245 %#define MD_MAX_SETNAME_PLUS_1 (MD_MAX_SETNAME + 1) 246 %#define MD_MAX_NODENAME_PLUS_1 (MD_MAX_NODENAME + 1) 247 %#define MD_MAX_MNNODENAME_PLUS_1 (MD_MAX_MNNODENAME + 1) 248 % 249 %#define MD_SET_BAD ((set_t)~0UL) 250 % 251 %#define MD_LOCAL_NAME "" 252 % 253 %#define MD_SIDEWILD ((side_t)~0UL) 254 % 255 %#define MD_KEYWILD ((mdkey_t)0) 256 %#define MD_KEYBAD ((mdkey_t)~0UL) 257 %#define MD_UNITBAD ((unit_t)~0UL) 258 %#define MD_HSPID_WILD ((hsp_t)~0UL) 259 260 %/* Maximum length of a metadevice name */ 261 %#define MD_MAX_SIDENAME_LEN (MD_MAXDRVNM + MD_MAX_SETNAME + 2) 262 % 263 %/* 264 % * dev_t is 64 bit now across userland and kernel. Whereever 32 bit value 265 % * is specifically needed, dev32_t will be used. Internally dev_t is used. 266 % * timeval is always 32 bit across userland and kernel. 267 % */ 268 %typedef u_longlong_t md_dev64_t; 269 %typedef struct timeval32 md_timeval32_t; 270 % 271 %/* 272 % * The following definitions are not available, when operating in 273 % * a 32 bit environment. As we are always dealing with 274 % * 64 bit devices, md_dev64_t, we need those definitions also in 275 % * a 32 bit environment 276 % */ 277 %#ifndef NBITSMAJOR64 278 %#define NBITSMAJOR64 32 /* # of major device bits in 64-bit Solaris */ 279 %#endif /* NBITSMAJOR64 */ 280 % 281 %#ifndef NBITSMINOR64 282 %#define NBITSMINOR64 32 /* # of minor device bits in 64-bit Solaris */ 283 %#endif /* NBITSMINOR64 */ 284 % 285 %#ifndef MAXMAJ64 286 %#define MAXMAJ64 0xfffffffful /* max major value */ 287 %#endif /* MAXMAJ64 */ 288 % 289 %#ifndef MAXMIN64 290 %#define MAXMIN64 0xfffffffful /* max minor value */ 291 %#endif /* MAXMIN64 */ 292 % 293 %#ifndef NODEV64 294 %#define NODEV64 0xffffffffffffffffuLL 295 %#endif /* NODEV64 */ 296 % 297 %#ifndef NODEV32 298 %#define NODEV32 0xffffffffuL 299 %#endif /* NODEV32 */ 300 % 301 %#ifndef MD_DISKADDR_ERROR 302 %#define MD_DISKADDR_ERROR 0xffffffffffffffffuLL 303 %#endif /* MD_DISKADDR_ERROR */ 304 305 #endif /* RPC_HDR */ 306 307 #if defined(RPC_HDR) || defined(RPC_XDR) 308 % 309 %/* namespace key */ 310 typedef int mdkey_t; 311 312 % 313 %/* set ID */ 314 typedef u_int set_t; 315 316 % 317 %/* record ID type */ 318 typedef int mddb_recid_t; 319 320 % 321 %/* side ID */ 322 typedef u_int side_t; 323 324 % 325 %/* Multi-node node ID */ 326 typedef uint32_t md_mn_nodeid_t; 327 328 % 329 %/* Shared definitions */ 330 #include "meta_arr.x" 331 332 #endif /* defined(RPC_HDR) || defined(RPC_XDR) */ 333 334 #ifdef RPC_HDR 335 % 336 %#if defined(__STDC__) || defined(__cplusplus) 337 #ifndef _KERNEL 338 %extern bool_t xdr_uint_t(XDR *xdrs, uint_t *objp); 339 %extern bool_t xdr_ushort_t(XDR *xdrs, ushort_t *objp); 340 %extern bool_t xdr_dev_t(XDR *xdrs, dev_t *objp); 341 %extern bool_t xdr_dev32_t(XDR *xdrs, dev32_t *objp); 342 %extern bool_t xdr_md_dev64_t(XDR *xdrs, md_dev64_t *objp); 343 %extern bool_t xdr_size_t(XDR *xdrs, size_t *objp); 344 %extern bool_t xdr_daddr_t(XDR *xdrs, daddr_t *objp); 345 %extern bool_t xdr_daddr32_t(XDR *xdrs, daddr32_t *objp); 346 %extern bool_t xdr_diskaddr_t(XDR *xdrs, diskaddr_t *objp); 347 %extern bool_t xdr_ddi_devid_t(XDR *xdrs, ddi_devid_t *objp); 348 %extern bool_t xdr_off_t(XDR *xdrs, off_t *objp); 349 %extern bool_t xdr_md_timeval32_t(XDR *xdrs, md_timeval32_t *objp); 350 #endif /* !_KERNEL */ 351 %extern bool_t xdr_minor_t(XDR *xdrs, minor_t *objp); 352 %extern bool_t xdr_timeval(XDR *xdrs, struct timeval *objp); 353 %extern bool_t xdr_clnt_stat(XDR *xdrs, enum clnt_stat *objp); 354 #ifdef _KERNEL 355 %extern bool_t xdr_vector(XDR *xdrs, char *basep, 356 % u_int nelem, u_int elemsize, 357 % xdrproc_t xdr_elem); 358 #endif /* _KERNEL */ 359 %#else /* K&R C */ 360 #ifndef _KERNEL 361 %extern bool_t xdr_uint_t(); 362 %extern bool_t xdr_ushort_t(); 363 %extern bool_t xdr_dev_t(); 364 %extern bool_t xdr_dev32_t(); 365 %extern bool_t xdr_md_dev64_t(); 366 %extern bool_t xdr_size_t(); 367 %extern bool_t xdr_daddr_t(); 368 %extern bool_t xdr_daddr32_t(); 369 %extern bool_t xdr_diskaddr_t(); 370 %extern bool_t xdr_ddi_devid_t(); 371 %extern bool_t xdr_off_t(); 372 %extern bool_t xdr_md_timeval32_t(); 373 #endif /* !_KERNEL */ 374 %extern bool_t xdr_minor_t(); 375 %extern bool_t xdr_timeval(); 376 %extern bool_t xdr_clnt_stat(); 377 % 378 #ifdef _KERNEL 379 %extern bool_t xdr_vector(); 380 #endif /* _KERNEL */ 381 %#endif /* K&R C */ 382 #endif /* RPC_HDR */ 383