1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <rpc/types.h> 30*7c478bd9Sstevel@tonic-gate #include <rpc/xdr.h> 31*7c478bd9Sstevel@tonic-gate #include <rpc/rpc.h> 32*7c478bd9Sstevel@tonic-gate #include <rpcsvc/nfs_prot.h> 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate /* 35*7c478bd9Sstevel@tonic-gate * Xdr routines for NFS ops. 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate static bool_t 39*7c478bd9Sstevel@tonic-gate xdr_b_nfs_fh3(XDR *xdrs, nfs_fh3 *objp) 40*7c478bd9Sstevel@tonic-gate { 41*7c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->data.data_val, 42*7c478bd9Sstevel@tonic-gate (uint_t *)&objp->data.data_len, NFS3_FHSIZE)); 43*7c478bd9Sstevel@tonic-gate } 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate static bool_t 46*7c478bd9Sstevel@tonic-gate xdr_b_fattr3(XDR *xdrs, fattr3 *objp) 47*7c478bd9Sstevel@tonic-gate { 48*7c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->type)) 49*7c478bd9Sstevel@tonic-gate return (FALSE); 50*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->mode)) 51*7c478bd9Sstevel@tonic-gate return (FALSE); 52*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->nlink)) 53*7c478bd9Sstevel@tonic-gate return (FALSE); 54*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->uid)) 55*7c478bd9Sstevel@tonic-gate return (FALSE); 56*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->gid)) 57*7c478bd9Sstevel@tonic-gate return (FALSE); 58*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->size)) 59*7c478bd9Sstevel@tonic-gate return (FALSE); 60*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->used)) 61*7c478bd9Sstevel@tonic-gate return (FALSE); 62*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rdev.specdata1)) 63*7c478bd9Sstevel@tonic-gate return (FALSE); 64*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->rdev.specdata2)) 65*7c478bd9Sstevel@tonic-gate return (FALSE); 66*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->fsid)) 67*7c478bd9Sstevel@tonic-gate return (FALSE); 68*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->fileid)) 69*7c478bd9Sstevel@tonic-gate return (FALSE); 70*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->atime.seconds)) 71*7c478bd9Sstevel@tonic-gate return (FALSE); 72*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->atime.nseconds)) 73*7c478bd9Sstevel@tonic-gate return (FALSE); 74*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->mtime.seconds)) 75*7c478bd9Sstevel@tonic-gate return (FALSE); 76*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->mtime.nseconds)) 77*7c478bd9Sstevel@tonic-gate return (FALSE); 78*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->ctime.seconds)) 79*7c478bd9Sstevel@tonic-gate return (FALSE); 80*7c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->ctime.nseconds)); 81*7c478bd9Sstevel@tonic-gate } 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate static bool_t 84*7c478bd9Sstevel@tonic-gate xdr_b_post_op_attr(XDR *xdrs, post_op_attr *objp) 85*7c478bd9Sstevel@tonic-gate { 86*7c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->attributes_follow)) 87*7c478bd9Sstevel@tonic-gate return (FALSE); 88*7c478bd9Sstevel@tonic-gate switch (objp->attributes_follow) { 89*7c478bd9Sstevel@tonic-gate case TRUE: 90*7c478bd9Sstevel@tonic-gate return (xdr_b_fattr3(xdrs, &objp->post_op_attr_u.attributes)); 91*7c478bd9Sstevel@tonic-gate case FALSE: 92*7c478bd9Sstevel@tonic-gate return (TRUE); 93*7c478bd9Sstevel@tonic-gate default: 94*7c478bd9Sstevel@tonic-gate return (FALSE); 95*7c478bd9Sstevel@tonic-gate } 96*7c478bd9Sstevel@tonic-gate } 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate static bool_t 99*7c478bd9Sstevel@tonic-gate xdr_b_diropargs3(XDR *xdrs, diropargs3 *objp) 100*7c478bd9Sstevel@tonic-gate { 101*7c478bd9Sstevel@tonic-gate if (!xdr_b_nfs_fh3(xdrs, &objp->dir)) 102*7c478bd9Sstevel@tonic-gate return (FALSE); 103*7c478bd9Sstevel@tonic-gate return (xdr_string(xdrs, &objp->name, ~0)); 104*7c478bd9Sstevel@tonic-gate } 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate bool_t 107*7c478bd9Sstevel@tonic-gate xdr_GETATTR3args(XDR *xdrs, GETATTR3args *objp) 108*7c478bd9Sstevel@tonic-gate { 109*7c478bd9Sstevel@tonic-gate return (xdr_b_nfs_fh3(xdrs, &objp->object)); 110*7c478bd9Sstevel@tonic-gate } 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate static bool_t 113*7c478bd9Sstevel@tonic-gate xdr_b_GETATTR3resok(XDR *xdrs, GETATTR3resok *objp) 114*7c478bd9Sstevel@tonic-gate { 115*7c478bd9Sstevel@tonic-gate return (xdr_b_fattr3(xdrs, &objp->obj_attributes)); 116*7c478bd9Sstevel@tonic-gate } 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate bool_t 119*7c478bd9Sstevel@tonic-gate xdr_GETATTR3res(XDR *xdrs, GETATTR3res *objp) 120*7c478bd9Sstevel@tonic-gate { 121*7c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->status)) 122*7c478bd9Sstevel@tonic-gate return (FALSE); 123*7c478bd9Sstevel@tonic-gate if (objp->status == NFS3_OK) 124*7c478bd9Sstevel@tonic-gate return (xdr_b_GETATTR3resok(xdrs, &objp->GETATTR3res_u.resok)); 125*7c478bd9Sstevel@tonic-gate return (TRUE); 126*7c478bd9Sstevel@tonic-gate } 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate bool_t 129*7c478bd9Sstevel@tonic-gate xdr_LOOKUP3args(XDR *xdrs, LOOKUP3args *objp) 130*7c478bd9Sstevel@tonic-gate { 131*7c478bd9Sstevel@tonic-gate return (xdr_b_diropargs3(xdrs, &objp->what)); 132*7c478bd9Sstevel@tonic-gate } 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate static bool_t 135*7c478bd9Sstevel@tonic-gate xdr_b_LOOKUP3resok(XDR *xdrs, LOOKUP3resok *objp) 136*7c478bd9Sstevel@tonic-gate { 137*7c478bd9Sstevel@tonic-gate if (!xdr_b_nfs_fh3(xdrs, &objp->object)) 138*7c478bd9Sstevel@tonic-gate return (FALSE); 139*7c478bd9Sstevel@tonic-gate if (!xdr_b_post_op_attr(xdrs, &objp->obj_attributes)) 140*7c478bd9Sstevel@tonic-gate return (FALSE); 141*7c478bd9Sstevel@tonic-gate return (xdr_b_post_op_attr(xdrs, &objp->dir_attributes)); 142*7c478bd9Sstevel@tonic-gate } 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate static bool_t 145*7c478bd9Sstevel@tonic-gate xdr_b_LOOKUP3resfail(XDR *xdrs, LOOKUP3resfail *objp) 146*7c478bd9Sstevel@tonic-gate { 147*7c478bd9Sstevel@tonic-gate return (xdr_b_post_op_attr(xdrs, &objp->dir_attributes)); 148*7c478bd9Sstevel@tonic-gate } 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate bool_t 151*7c478bd9Sstevel@tonic-gate xdr_LOOKUP3res(XDR *xdrs, LOOKUP3res *objp) 152*7c478bd9Sstevel@tonic-gate { 153*7c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->status)) 154*7c478bd9Sstevel@tonic-gate return (FALSE); 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate if (objp->status == NFS3_OK) 157*7c478bd9Sstevel@tonic-gate return (xdr_b_LOOKUP3resok(xdrs, &objp->LOOKUP3res_u.resok)); 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate return (xdr_b_LOOKUP3resfail(xdrs, &objp->LOOKUP3res_u.resfail)); 160*7c478bd9Sstevel@tonic-gate } 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate bool_t 163*7c478bd9Sstevel@tonic-gate xdr_READLINK3args(XDR *xdrs, READLINK3args *objp) 164*7c478bd9Sstevel@tonic-gate { 165*7c478bd9Sstevel@tonic-gate return (xdr_b_nfs_fh3(xdrs, &objp->symlink)); 166*7c478bd9Sstevel@tonic-gate } 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate static bool_t 169*7c478bd9Sstevel@tonic-gate xdr_b_READLINK3resok(XDR *xdrs, READLINK3resok *objp) 170*7c478bd9Sstevel@tonic-gate { 171*7c478bd9Sstevel@tonic-gate if (!xdr_b_post_op_attr(xdrs, &objp->symlink_attributes)) 172*7c478bd9Sstevel@tonic-gate return (FALSE); 173*7c478bd9Sstevel@tonic-gate return (xdr_string(xdrs, &objp->data, ~0)); 174*7c478bd9Sstevel@tonic-gate } 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate static bool_t 177*7c478bd9Sstevel@tonic-gate xdr_b_READLINK3resfail(XDR *xdrs, READLINK3resfail *objp) 178*7c478bd9Sstevel@tonic-gate { 179*7c478bd9Sstevel@tonic-gate return (xdr_b_post_op_attr(xdrs, &objp->symlink_attributes)); 180*7c478bd9Sstevel@tonic-gate } 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate bool_t 183*7c478bd9Sstevel@tonic-gate xdr_READLINK3res(XDR *xdrs, READLINK3res *objp) 184*7c478bd9Sstevel@tonic-gate { 185*7c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->status)) 186*7c478bd9Sstevel@tonic-gate return (FALSE); 187*7c478bd9Sstevel@tonic-gate if (objp->status == NFS3_OK) 188*7c478bd9Sstevel@tonic-gate return (xdr_b_READLINK3resok(xdrs, 189*7c478bd9Sstevel@tonic-gate &objp->READLINK3res_u.resok)); 190*7c478bd9Sstevel@tonic-gate return (xdr_b_READLINK3resfail(xdrs, &objp->READLINK3res_u.resfail)); 191*7c478bd9Sstevel@tonic-gate } 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate bool_t 194*7c478bd9Sstevel@tonic-gate xdr_READ3args(XDR *xdrs, READ3args *objp) 195*7c478bd9Sstevel@tonic-gate { 196*7c478bd9Sstevel@tonic-gate if (!xdr_b_nfs_fh3(xdrs, &objp->file)) 197*7c478bd9Sstevel@tonic-gate return (FALSE); 198*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->offset)) 199*7c478bd9Sstevel@tonic-gate return (FALSE); 200*7c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->count)); 201*7c478bd9Sstevel@tonic-gate } 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate static bool_t 204*7c478bd9Sstevel@tonic-gate xdr_b_READ3resok(XDR *xdrs, READ3resok *objp) 205*7c478bd9Sstevel@tonic-gate { 206*7c478bd9Sstevel@tonic-gate if (!xdr_b_post_op_attr(xdrs, &objp->file_attributes)) 207*7c478bd9Sstevel@tonic-gate return (FALSE); 208*7c478bd9Sstevel@tonic-gate if (!xdr_u_int(xdrs, &objp->count)) 209*7c478bd9Sstevel@tonic-gate return (FALSE); 210*7c478bd9Sstevel@tonic-gate if (!xdr_bool(xdrs, &objp->eof)) 211*7c478bd9Sstevel@tonic-gate return (FALSE); 212*7c478bd9Sstevel@tonic-gate return (xdr_bytes(xdrs, (char **)&objp->data.data_val, 213*7c478bd9Sstevel@tonic-gate (uint_t *)&objp->data.data_len, ~0)); 214*7c478bd9Sstevel@tonic-gate } 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate static bool_t 217*7c478bd9Sstevel@tonic-gate xdr_b_READ3resfail(XDR *xdrs, READ3resfail *objp) 218*7c478bd9Sstevel@tonic-gate { 219*7c478bd9Sstevel@tonic-gate return (xdr_b_post_op_attr(xdrs, &objp->file_attributes)); 220*7c478bd9Sstevel@tonic-gate } 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate bool_t 223*7c478bd9Sstevel@tonic-gate xdr_READ3res(XDR *xdrs, READ3res *objp) 224*7c478bd9Sstevel@tonic-gate { 225*7c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->status)) 226*7c478bd9Sstevel@tonic-gate return (FALSE); 227*7c478bd9Sstevel@tonic-gate if (objp->status == NFS3_OK) 228*7c478bd9Sstevel@tonic-gate return (xdr_b_READ3resok(xdrs, &objp->READ3res_u.resok)); 229*7c478bd9Sstevel@tonic-gate return (xdr_b_READ3resfail(xdrs, &objp->READ3res_u.resfail)); 230*7c478bd9Sstevel@tonic-gate } 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate bool_t 233*7c478bd9Sstevel@tonic-gate xdr_READDIR3args(XDR *xdrs, READDIR3args *objp) 234*7c478bd9Sstevel@tonic-gate { 235*7c478bd9Sstevel@tonic-gate if (!xdr_b_nfs_fh3(xdrs, &objp->dir)) 236*7c478bd9Sstevel@tonic-gate return (FALSE); 237*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->cookie)) 238*7c478bd9Sstevel@tonic-gate return (FALSE); 239*7c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->cookieverf, NFS3_COOKIEVERFSIZE)) 240*7c478bd9Sstevel@tonic-gate return (FALSE); 241*7c478bd9Sstevel@tonic-gate return (xdr_u_int(xdrs, &objp->count)); 242*7c478bd9Sstevel@tonic-gate } 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate static bool_t 245*7c478bd9Sstevel@tonic-gate xdr_b_entry3(XDR *xdrs, entry3 *objp) 246*7c478bd9Sstevel@tonic-gate { 247*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->fileid)) 248*7c478bd9Sstevel@tonic-gate return (FALSE); 249*7c478bd9Sstevel@tonic-gate if (!xdr_string(xdrs, &objp->name, ~0)) 250*7c478bd9Sstevel@tonic-gate return (FALSE); 251*7c478bd9Sstevel@tonic-gate if (!xdr_u_longlong_t(xdrs, &objp->cookie)) 252*7c478bd9Sstevel@tonic-gate return (FALSE); 253*7c478bd9Sstevel@tonic-gate return (xdr_pointer(xdrs, (char **)&objp->nextentry, 254*7c478bd9Sstevel@tonic-gate sizeof (entry3), (xdrproc_t)xdr_b_entry3)); 255*7c478bd9Sstevel@tonic-gate } 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate static bool_t 258*7c478bd9Sstevel@tonic-gate xdr_b_READDIR3resok(XDR *xdrs, READDIR3resok *objp) 259*7c478bd9Sstevel@tonic-gate { 260*7c478bd9Sstevel@tonic-gate if (!xdr_b_post_op_attr(xdrs, &objp->dir_attributes)) 261*7c478bd9Sstevel@tonic-gate return (FALSE); 262*7c478bd9Sstevel@tonic-gate if (!xdr_opaque(xdrs, objp->cookieverf, NFS3_COOKIEVERFSIZE)) 263*7c478bd9Sstevel@tonic-gate return (FALSE); 264*7c478bd9Sstevel@tonic-gate if (!xdr_pointer(xdrs, (char **)&objp->reply.entries, 265*7c478bd9Sstevel@tonic-gate sizeof (entry3), (xdrproc_t)xdr_b_entry3)) 266*7c478bd9Sstevel@tonic-gate return (FALSE); 267*7c478bd9Sstevel@tonic-gate return (xdr_bool(xdrs, &objp->reply.eof)); 268*7c478bd9Sstevel@tonic-gate } 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate static bool_t 271*7c478bd9Sstevel@tonic-gate xdr_b_READDIR3resfail(XDR *xdrs, READDIR3resfail *objp) 272*7c478bd9Sstevel@tonic-gate { 273*7c478bd9Sstevel@tonic-gate return (xdr_b_post_op_attr(xdrs, &objp->dir_attributes)); 274*7c478bd9Sstevel@tonic-gate } 275*7c478bd9Sstevel@tonic-gate 276*7c478bd9Sstevel@tonic-gate bool_t 277*7c478bd9Sstevel@tonic-gate xdr_READDIR3res(XDR *xdrs, READDIR3res *objp) 278*7c478bd9Sstevel@tonic-gate { 279*7c478bd9Sstevel@tonic-gate if (!xdr_enum(xdrs, (enum_t *)&objp->status)) 280*7c478bd9Sstevel@tonic-gate return (FALSE); 281*7c478bd9Sstevel@tonic-gate if (objp->status == NFS3_OK) 282*7c478bd9Sstevel@tonic-gate return (xdr_b_READDIR3resok(xdrs, &objp->READDIR3res_u.resok)); 283*7c478bd9Sstevel@tonic-gate return (xdr_b_READDIR3resfail(xdrs, &objp->READDIR3res_u.resfail)); 284*7c478bd9Sstevel@tonic-gate } 285