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