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