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 * nfs_inet.h contains definitions specific to inetboot's nfs implementation. 27*7c478bd9Sstevel@tonic-gate */ 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #ifndef _NFS_INET_H 30*7c478bd9Sstevel@tonic-gate #define _NFS_INET_H 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 35*7c478bd9Sstevel@tonic-gate extern "C" { 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #include <netinet/in.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/socket.h> 40*7c478bd9Sstevel@tonic-gate #include <net/if.h> 41*7c478bd9Sstevel@tonic-gate #include <netinet/if_ether.h> 42*7c478bd9Sstevel@tonic-gate #include <netinet/in_systm.h> 43*7c478bd9Sstevel@tonic-gate #include <netinet/ip.h> 44*7c478bd9Sstevel@tonic-gate #include <netinet/udp.h> 45*7c478bd9Sstevel@tonic-gate #include <sys/saio.h> 46*7c478bd9Sstevel@tonic-gate #include <rpcsvc/nfs_prot.h> 47*7c478bd9Sstevel@tonic-gate #include <rpcsvc/nfs4_prot.h> 48*7c478bd9Sstevel@tonic-gate #include "clnt.h" 49*7c478bd9Sstevel@tonic-gate #include <sys/vfs.h> 50*7c478bd9Sstevel@tonic-gate #include <sys/dirent.h> 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate #define NFSBUF_SIZE (READ_SIZE+1024) 53*7c478bd9Sstevel@tonic-gate #define READ_SIZE (8192) /* NFS readsize */ 54*7c478bd9Sstevel@tonic-gate #define NFS_READ_DECR (1024) /* NFS readsize decrement */ 55*7c478bd9Sstevel@tonic-gate #define NFS3BUF_SIZE (READ3_SIZE+1024) 56*7c478bd9Sstevel@tonic-gate #define READ3_SIZE (32 * 1024) /* NFS3 readsize */ 57*7c478bd9Sstevel@tonic-gate #define NFS4BUF_SIZE (READ4_SIZE+1024) 58*7c478bd9Sstevel@tonic-gate #define READ4_SIZE (32 * 1024) /* NFS4 readsize */ 59*7c478bd9Sstevel@tonic-gate #define NFS4_MAX_UTF8STRING (8 * 1024) 60*7c478bd9Sstevel@tonic-gate #define NFS4_MAX_BITWORDS (2) 61*7c478bd9Sstevel@tonic-gate #define NFS_MAX_FERRS (3) /* MAX frame errors before decr read size */ 62*7c478bd9Sstevel@tonic-gate #define NFS_REXMIT_MIN (3) /* NFS retry min in secs */ 63*7c478bd9Sstevel@tonic-gate #define NFS_REXMIT_MAX (15) /* NFS retry max in secs */ 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate extern int nfs_readsize; 66*7c478bd9Sstevel@tonic-gate extern struct nfs_file roothandle; 67*7c478bd9Sstevel@tonic-gate extern CLIENT *root_CLIENT; 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate /* 70*7c478bd9Sstevel@tonic-gate * Boot specific V4 fh with maximum allowed data statically allocated 71*7c478bd9Sstevel@tonic-gate */ 72*7c478bd9Sstevel@tonic-gate struct nfs_bfh4 { 73*7c478bd9Sstevel@tonic-gate uint_t len; 74*7c478bd9Sstevel@tonic-gate char data[NFS4_FHSIZE]; 75*7c478bd9Sstevel@tonic-gate }; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate /* 78*7c478bd9Sstevel@tonic-gate * Boot specific V3 fh with maximum allowed data statically allocated 79*7c478bd9Sstevel@tonic-gate */ 80*7c478bd9Sstevel@tonic-gate struct nfs_bfh3 { 81*7c478bd9Sstevel@tonic-gate uint_t len; 82*7c478bd9Sstevel@tonic-gate char data[NFS3_FHSIZE]; 83*7c478bd9Sstevel@tonic-gate }; 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate union _nfs_fh { 86*7c478bd9Sstevel@tonic-gate nfs_fh fh2; 87*7c478bd9Sstevel@tonic-gate struct nfs_bfh3 fh3; 88*7c478bd9Sstevel@tonic-gate struct nfs_bfh4 fh4; 89*7c478bd9Sstevel@tonic-gate }; 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate union _nfs_cookie { 92*7c478bd9Sstevel@tonic-gate nfscookie cookie2; 93*7c478bd9Sstevel@tonic-gate cookie3 cookie3; 94*7c478bd9Sstevel@tonic-gate nfs_cookie4 cookie4; 95*7c478bd9Sstevel@tonic-gate }; 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate union _nfs_ftype { 98*7c478bd9Sstevel@tonic-gate ftype type2; 99*7c478bd9Sstevel@tonic-gate ftype3 type3; 100*7c478bd9Sstevel@tonic-gate nfs_ftype4 type4; 101*7c478bd9Sstevel@tonic-gate }; 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* 104*7c478bd9Sstevel@tonic-gate * NFS: This structure represents the current open file. 105*7c478bd9Sstevel@tonic-gate */ 106*7c478bd9Sstevel@tonic-gate struct nfs_file { 107*7c478bd9Sstevel@tonic-gate int version; 108*7c478bd9Sstevel@tonic-gate ulong_t offset; 109*7c478bd9Sstevel@tonic-gate union _nfs_ftype ftype; 110*7c478bd9Sstevel@tonic-gate union _nfs_fh fh; 111*7c478bd9Sstevel@tonic-gate union _nfs_cookie cookie; 112*7c478bd9Sstevel@tonic-gate }; 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate struct nfs_fid { 115*7c478bd9Sstevel@tonic-gate ushort_t nf_len; 116*7c478bd9Sstevel@tonic-gate ushort_t nf_pad; 117*7c478bd9Sstevel@tonic-gate struct nfs_fh fh; 118*7c478bd9Sstevel@tonic-gate }; 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate #define cfile_is_dir(cf) (((cf)->version == NFS_VERSION) ? \ 121*7c478bd9Sstevel@tonic-gate ((cf)->ftype.type2 == NFDIR) : \ 122*7c478bd9Sstevel@tonic-gate (((cf)->version == NFS_V3) ? \ 123*7c478bd9Sstevel@tonic-gate ((cf)->ftype.type3 == NF3DIR) : \ 124*7c478bd9Sstevel@tonic-gate (((cf)->version == NFS_V4) ? \ 125*7c478bd9Sstevel@tonic-gate ((cf)->ftype.type4 == NF4DIR) : 0))) 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate #define cfile_is_lnk(cf) (((cf)->version == NFS_VERSION) ? \ 128*7c478bd9Sstevel@tonic-gate ((cf)->ftype.type2 == NFLNK) : \ 129*7c478bd9Sstevel@tonic-gate (((cf)->version == NFS_V3) ? \ 130*7c478bd9Sstevel@tonic-gate ((cf)->ftype.type3 == NF3LNK) : \ 131*7c478bd9Sstevel@tonic-gate (((cf)->version == NFS_V4) ? \ 132*7c478bd9Sstevel@tonic-gate ((cf)->ftype.type4 == NF4LNK) : 0))) 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate /* 135*7c478bd9Sstevel@tonic-gate * Predefine an attribute bitmap that inetboot will most likely be 136*7c478bd9Sstevel@tonic-gate * interested in. 137*7c478bd9Sstevel@tonic-gate */ 138*7c478bd9Sstevel@tonic-gate typedef union attr4_bitmap1_u { 139*7c478bd9Sstevel@tonic-gate struct { 140*7c478bd9Sstevel@tonic-gate unsigned int 141*7c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_HTOL 142*7c478bd9Sstevel@tonic-gate b_pad4: 11, 143*7c478bd9Sstevel@tonic-gate b_fattr4_fileid: 1, 144*7c478bd9Sstevel@tonic-gate b_fattr4_filehandle: 1, 145*7c478bd9Sstevel@tonic-gate b_pad3: 10, 146*7c478bd9Sstevel@tonic-gate b_fattr4_fsid: 1, 147*7c478bd9Sstevel@tonic-gate b_pad2: 3, 148*7c478bd9Sstevel@tonic-gate b_fattr4_size: 1, 149*7c478bd9Sstevel@tonic-gate b_pad1: 2, 150*7c478bd9Sstevel@tonic-gate b_fattr4_type: 1, 151*7c478bd9Sstevel@tonic-gate b_supported_attrs: 1; 152*7c478bd9Sstevel@tonic-gate #endif 153*7c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_LTOH 154*7c478bd9Sstevel@tonic-gate b_supported_attrs: 1, 155*7c478bd9Sstevel@tonic-gate b_fattr4_type: 1, 156*7c478bd9Sstevel@tonic-gate b_pad1: 2, 157*7c478bd9Sstevel@tonic-gate b_fattr4_size: 1, 158*7c478bd9Sstevel@tonic-gate b_pad2: 3, 159*7c478bd9Sstevel@tonic-gate b_fattr4_fsid: 1, 160*7c478bd9Sstevel@tonic-gate b_pad3: 10, 161*7c478bd9Sstevel@tonic-gate b_fattr4_filehandle: 1, 162*7c478bd9Sstevel@tonic-gate b_fattr4_fileid: 1, 163*7c478bd9Sstevel@tonic-gate b_pad4: 11; 164*7c478bd9Sstevel@tonic-gate #endif 165*7c478bd9Sstevel@tonic-gate } bitmap_s; 166*7c478bd9Sstevel@tonic-gate uint_t word; 167*7c478bd9Sstevel@tonic-gate } attr4_bitmap1_t; 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate #define bm_supported_attrs bitmap_s.b_supported_attrs 170*7c478bd9Sstevel@tonic-gate #define bm_fattr4_type bitmap_s.b_fattr4_type 171*7c478bd9Sstevel@tonic-gate #define bm_fattr4_size bitmap_s.b_fattr4_size 172*7c478bd9Sstevel@tonic-gate #define bm_fattr4_fsid bitmap_s.b_fattr4_fsid 173*7c478bd9Sstevel@tonic-gate #define bm_fattr4_fileid bitmap_s.b_fattr4_fileid 174*7c478bd9Sstevel@tonic-gate #define bm_fattr4_filehandle bitmap_s.b_fattr4_filehandle 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate typedef union attr4_bitmap2_u { 177*7c478bd9Sstevel@tonic-gate struct { 178*7c478bd9Sstevel@tonic-gate unsigned int 179*7c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_HTOL 180*7c478bd9Sstevel@tonic-gate b_pad4: 10, 181*7c478bd9Sstevel@tonic-gate b_fattr4_time_modify: 1, 182*7c478bd9Sstevel@tonic-gate b_fattr4_time_metadata: 1, 183*7c478bd9Sstevel@tonic-gate b_pad3: 4, 184*7c478bd9Sstevel@tonic-gate b_fattr4_time_access: 1, 185*7c478bd9Sstevel@tonic-gate b_pad2: 13, 186*7c478bd9Sstevel@tonic-gate b_fattr4_mode: 1, 187*7c478bd9Sstevel@tonic-gate b_pad1: 1; 188*7c478bd9Sstevel@tonic-gate #endif 189*7c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_LTOH 190*7c478bd9Sstevel@tonic-gate b_pad1: 1, 191*7c478bd9Sstevel@tonic-gate b_fattr4_mode: 1, 192*7c478bd9Sstevel@tonic-gate b_pad2: 13, 193*7c478bd9Sstevel@tonic-gate b_fattr4_time_access: 1, 194*7c478bd9Sstevel@tonic-gate b_pad3: 4, 195*7c478bd9Sstevel@tonic-gate b_fattr4_time_metadata: 1, 196*7c478bd9Sstevel@tonic-gate b_fattr4_time_modify: 1, 197*7c478bd9Sstevel@tonic-gate b_pad4: 10; 198*7c478bd9Sstevel@tonic-gate #endif 199*7c478bd9Sstevel@tonic-gate } bitmap_s; 200*7c478bd9Sstevel@tonic-gate uint_t word; 201*7c478bd9Sstevel@tonic-gate } attr4_bitmap2_t; 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate #define bm_fattr4_mode bitmap_s.b_fattr4_mode 204*7c478bd9Sstevel@tonic-gate #define bm_fattr4_time_access bitmap_s.b_fattr4_time_access 205*7c478bd9Sstevel@tonic-gate #define bm_fattr4_time_metadata bitmap_s.b_fattr4_time_metadata 206*7c478bd9Sstevel@tonic-gate #define bm_fattr4_time_modify bitmap_s.b_fattr4_time_modify 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate typedef struct b_bitmap4 { 209*7c478bd9Sstevel@tonic-gate uint_t b_bitmap_len; 210*7c478bd9Sstevel@tonic-gate uint_t b_bitmap_val[NFS4_MAX_BITWORDS]; 211*7c478bd9Sstevel@tonic-gate } b_bitmap4_t; 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* 214*7c478bd9Sstevel@tonic-gate * Define a usable set of v4 atttributes for inetboot. 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate typedef struct b_fattr4_s { 217*7c478bd9Sstevel@tonic-gate b_bitmap4_t b_supported_attrs; 218*7c478bd9Sstevel@tonic-gate nfs_ftype4 b_fattr4_type; 219*7c478bd9Sstevel@tonic-gate uint64_t b_fattr4_size; 220*7c478bd9Sstevel@tonic-gate fsid4 b_fattr4_fsid; 221*7c478bd9Sstevel@tonic-gate struct nfs_bfh4 b_fattr4_filehandle; 222*7c478bd9Sstevel@tonic-gate uint64_t b_fattr4_fileid; 223*7c478bd9Sstevel@tonic-gate mode4 b_fattr4_mode; 224*7c478bd9Sstevel@tonic-gate nfstime4 b_fattr4_time_access; 225*7c478bd9Sstevel@tonic-gate nfstime4 b_fattr4_time_metadata; 226*7c478bd9Sstevel@tonic-gate nfstime4 b_fattr4_time_modify; 227*7c478bd9Sstevel@tonic-gate } b_fattr4_t; 228*7c478bd9Sstevel@tonic-gate 229*7c478bd9Sstevel@tonic-gate /* 230*7c478bd9Sstevel@tonic-gate * common to putfh and putfhroot. 231*7c478bd9Sstevel@tonic-gate */ 232*7c478bd9Sstevel@tonic-gate typedef struct putfh4arg_s { 233*7c478bd9Sstevel@tonic-gate uint_t pf_opnum; /* can either be putfh or putrootfh */ 234*7c478bd9Sstevel@tonic-gate struct nfs_bfh4 pf_filehandle; /* only used by putfh */ 235*7c478bd9Sstevel@tonic-gate } putfh4arg_t; 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate /* 238*7c478bd9Sstevel@tonic-gate * Use this struct to construct our OTW compound procedures. Layout makes for 239*7c478bd9Sstevel@tonic-gate * easy XDR'ing. Include putfh. 240*7c478bd9Sstevel@tonic-gate */ 241*7c478bd9Sstevel@tonic-gate typedef union compound_u { 242*7c478bd9Sstevel@tonic-gate struct { 243*7c478bd9Sstevel@tonic-gate utf8string tag; 244*7c478bd9Sstevel@tonic-gate uint_t minorversion; /* 0 */ 245*7c478bd9Sstevel@tonic-gate uint_t argarray_len; /* 1 + n for putfh */ 246*7c478bd9Sstevel@tonic-gate bool_t isputrootfh; /* flag */ 247*7c478bd9Sstevel@tonic-gate putfh4arg_t opputfh; /* putfh args */ 248*7c478bd9Sstevel@tonic-gate } compound_ua_s; 249*7c478bd9Sstevel@tonic-gate struct { 250*7c478bd9Sstevel@tonic-gate nfsstat4 status; /* status of last op */ 251*7c478bd9Sstevel@tonic-gate utf8string tag; 252*7c478bd9Sstevel@tonic-gate uint_t resarray_len; /* 1 + n for putfh */ 253*7c478bd9Sstevel@tonic-gate uint_t opputfh; /* putfh opnum */ 254*7c478bd9Sstevel@tonic-gate nfsstat4 putfh_status; /* putfh status */ 255*7c478bd9Sstevel@tonic-gate } compound_ur_s; 256*7c478bd9Sstevel@tonic-gate } b_compound_t; 257*7c478bd9Sstevel@tonic-gate 258*7c478bd9Sstevel@tonic-gate /* 259*7c478bd9Sstevel@tonic-gate * Define some macros for easy access into the compound structrue 260*7c478bd9Sstevel@tonic-gate */ 261*7c478bd9Sstevel@tonic-gate #define ca_tag compound_ua_s.tag 262*7c478bd9Sstevel@tonic-gate #define ca_minorversion compound_ua_s.minorversion 263*7c478bd9Sstevel@tonic-gate #define ca_argarray_len compound_ua_s.argarray_len 264*7c478bd9Sstevel@tonic-gate #define ca_isputrootfh compound_ua_s.isputrootfh 265*7c478bd9Sstevel@tonic-gate #define ca_opputfh compound_ua_s.opputfh 266*7c478bd9Sstevel@tonic-gate 267*7c478bd9Sstevel@tonic-gate #define cr_status compound_ur_s.status 268*7c478bd9Sstevel@tonic-gate #define cr_tag compound_ur_s.tag 269*7c478bd9Sstevel@tonic-gate #define cr_resarray_len compound_ur_s.resarray_len 270*7c478bd9Sstevel@tonic-gate #define cr_opputfh compound_ur_s.opputfh 271*7c478bd9Sstevel@tonic-gate #define cr_putfh_status compound_ur_s.putfh_status 272*7c478bd9Sstevel@tonic-gate /* 273*7c478bd9Sstevel@tonic-gate * Define simple compound structs that include op specific data 274*7c478bd9Sstevel@tonic-gate */ 275*7c478bd9Sstevel@tonic-gate typedef struct getattrres_cmn { 276*7c478bd9Sstevel@tonic-gate uint_t gc_opgetattr; /* getattr opnum */ 277*7c478bd9Sstevel@tonic-gate nfsstat4 gc_attr_status; /* getattr result */ 278*7c478bd9Sstevel@tonic-gate b_bitmap4_t gc_retattr; /* getattr result */ 279*7c478bd9Sstevel@tonic-gate uint_t gc_attrlist_len; /* getattr result */ 280*7c478bd9Sstevel@tonic-gate b_fattr4_t gc_attrs; /* getattr result */ 281*7c478bd9Sstevel@tonic-gate } getattrres_cmn_t; 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate /* 284*7c478bd9Sstevel@tonic-gate * getattr: putfh/getattr 285*7c478bd9Sstevel@tonic-gate */ 286*7c478bd9Sstevel@tonic-gate typedef struct getattr4arg_s { 287*7c478bd9Sstevel@tonic-gate b_compound_t ga_arg; /* compound + putfh */ 288*7c478bd9Sstevel@tonic-gate uint_t ga_opgetattr; /* getattr opnum */ 289*7c478bd9Sstevel@tonic-gate b_bitmap4_t ga_attr_req; /* getattr arg */ 290*7c478bd9Sstevel@tonic-gate } getattr4arg_t; 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate typedef struct getattr4res_s { 293*7c478bd9Sstevel@tonic-gate b_compound_t gr_res; /* compound + putfh */ 294*7c478bd9Sstevel@tonic-gate getattrres_cmn_t gr_cmn; 295*7c478bd9Sstevel@tonic-gate } getattr4res_t; 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate #define gr_opgetattr gr_cmn.gc_opgetattr 298*7c478bd9Sstevel@tonic-gate #define gr_attr_status gr_cmn.gc_attr_status 299*7c478bd9Sstevel@tonic-gate #define gr_retattr gr_cmn.gc_retattr 300*7c478bd9Sstevel@tonic-gate #define gr_attrs gr_cmn.gc_attrs 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate /* 303*7c478bd9Sstevel@tonic-gate * lookup: putfh/lookup/getattr 304*7c478bd9Sstevel@tonic-gate */ 305*7c478bd9Sstevel@tonic-gate typedef struct lookup4arg_s { 306*7c478bd9Sstevel@tonic-gate b_compound_t la_arg; /* compound + putfh */ 307*7c478bd9Sstevel@tonic-gate uint_t la_oplookup; /* lookup opnum */ 308*7c478bd9Sstevel@tonic-gate component4 la_pathname; /* lookup arg */ 309*7c478bd9Sstevel@tonic-gate uint_t la_opgetattr; /* getattr opnum */ 310*7c478bd9Sstevel@tonic-gate b_bitmap4_t la_attr_req; /* getattr arg */ 311*7c478bd9Sstevel@tonic-gate } lookup4arg_t; 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate typedef struct lookup4res_s { 314*7c478bd9Sstevel@tonic-gate b_compound_t lr_res; /* compound + putfh */ 315*7c478bd9Sstevel@tonic-gate uint_t lr_oplookup; /* lookup opnum */ 316*7c478bd9Sstevel@tonic-gate nfsstat4 lr_lookup_status; /* lookup result */ 317*7c478bd9Sstevel@tonic-gate getattrres_cmn_t lr_gcmn; /* getattr result */ 318*7c478bd9Sstevel@tonic-gate } lookup4res_t; 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate #define lr_opgetattr lr_gcmn.gc_opgetattr 321*7c478bd9Sstevel@tonic-gate #define lr_attr_status lr_gcmn.gc_attr_status 322*7c478bd9Sstevel@tonic-gate #define lr_retattr lr_gcmn.gc_retattr 323*7c478bd9Sstevel@tonic-gate #define lr_attrs lr_gcmn.gc_attrs 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate /* 326*7c478bd9Sstevel@tonic-gate * lookupp: putfh/lookupp/getattr 327*7c478bd9Sstevel@tonic-gate * 328*7c478bd9Sstevel@tonic-gate * For results: use the lookup4res_t 329*7c478bd9Sstevel@tonic-gate */ 330*7c478bd9Sstevel@tonic-gate typedef struct lookupp4arg_s { 331*7c478bd9Sstevel@tonic-gate b_compound_t la_arg; /* compound + putfh */ 332*7c478bd9Sstevel@tonic-gate uint_t la_oplookupp; /* lookupp opnum */ 333*7c478bd9Sstevel@tonic-gate uint_t la_opgetattr; /* lookupp arg */ 334*7c478bd9Sstevel@tonic-gate b_bitmap4_t la_attr_req; /* lookupp arg */ 335*7c478bd9Sstevel@tonic-gate } lookupp4arg_t; 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate /* 338*7c478bd9Sstevel@tonic-gate * read: putfh/read 339*7c478bd9Sstevel@tonic-gate */ 340*7c478bd9Sstevel@tonic-gate typedef struct read4arg_s { 341*7c478bd9Sstevel@tonic-gate b_compound_t r_arg; /* compound + putfh */ 342*7c478bd9Sstevel@tonic-gate uint_t r_opread; /* read opnum */ 343*7c478bd9Sstevel@tonic-gate stateid4 r_stateid; /* read arg */ 344*7c478bd9Sstevel@tonic-gate offset4 r_offset; /* read arg */ 345*7c478bd9Sstevel@tonic-gate count4 r_count; /* read arg */ 346*7c478bd9Sstevel@tonic-gate } read4arg_t; 347*7c478bd9Sstevel@tonic-gate 348*7c478bd9Sstevel@tonic-gate typedef struct read4res_s { 349*7c478bd9Sstevel@tonic-gate b_compound_t r_res; /* compound + putfh */ 350*7c478bd9Sstevel@tonic-gate uint_t r_opread; /* read opnum */ 351*7c478bd9Sstevel@tonic-gate nfsstat4 r_status; /* read result */ 352*7c478bd9Sstevel@tonic-gate bool_t r_eof; /* read result */ 353*7c478bd9Sstevel@tonic-gate uint_t r_data_len; /* read result */ 354*7c478bd9Sstevel@tonic-gate char *r_data_val; /* read result */ 355*7c478bd9Sstevel@tonic-gate } read4res_t; 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate typedef struct b_entry4_s { 358*7c478bd9Sstevel@tonic-gate nfs_cookie4 b_cookie; 359*7c478bd9Sstevel@tonic-gate utf8string b_name; 360*7c478bd9Sstevel@tonic-gate uint64_t b_fileid; 361*7c478bd9Sstevel@tonic-gate struct b_entry4_s *b_nextentry; 362*7c478bd9Sstevel@tonic-gate } b_entry4_t; 363*7c478bd9Sstevel@tonic-gate 364*7c478bd9Sstevel@tonic-gate /* 365*7c478bd9Sstevel@tonic-gate * readdir: putfh/readdir/getattr 366*7c478bd9Sstevel@tonic-gate */ 367*7c478bd9Sstevel@tonic-gate typedef struct readdir4arg_s { 368*7c478bd9Sstevel@tonic-gate b_compound_t rd_arg; /* compoud + putfh */ 369*7c478bd9Sstevel@tonic-gate uint_t rd_opreaddir; /* readdir opnum */ 370*7c478bd9Sstevel@tonic-gate nfs_cookie4 rd_cookie; /* readdir arg */ 371*7c478bd9Sstevel@tonic-gate verifier4 rd_cookieverf; /* readdir arg */ 372*7c478bd9Sstevel@tonic-gate count4 rd_dircount; /* readdir arg */ 373*7c478bd9Sstevel@tonic-gate count4 rd_maxcount; /* readdir arg */ 374*7c478bd9Sstevel@tonic-gate b_bitmap4_t rd_attr_req; /* readdir arg */ 375*7c478bd9Sstevel@tonic-gate } readdir4arg_t; 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate typedef struct readdir4res_s { 378*7c478bd9Sstevel@tonic-gate b_compound_t rd_res; /* compound + putfh */ 379*7c478bd9Sstevel@tonic-gate uint_t rd_opreaddir; /* readdir opnum */ 380*7c478bd9Sstevel@tonic-gate nfsstat4 rd_status; /* readdir result */ 381*7c478bd9Sstevel@tonic-gate verifier4 rd_cookieverf; /* readdir result */ 382*7c478bd9Sstevel@tonic-gate b_entry4_t *rd_entries; /* readdir result */ 383*7c478bd9Sstevel@tonic-gate bool_t rd_eof; /* readdir result */ 384*7c478bd9Sstevel@tonic-gate } readdir4res_t; 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate /* 387*7c478bd9Sstevel@tonic-gate * readlink: putfh/readlink 388*7c478bd9Sstevel@tonic-gate */ 389*7c478bd9Sstevel@tonic-gate typedef struct readlink4arg_s { 390*7c478bd9Sstevel@tonic-gate b_compound_t rl_arg; /* compound + putfh */ 391*7c478bd9Sstevel@tonic-gate uint_t rl_opreadlink; /* readlink opnum */ 392*7c478bd9Sstevel@tonic-gate } readlink4arg_t; 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate typedef struct readlink4res_s { 395*7c478bd9Sstevel@tonic-gate b_compound_t rl_res; /* compound + putfh */ 396*7c478bd9Sstevel@tonic-gate uint_t rl_opreadlink; /* readlink opnum */ 397*7c478bd9Sstevel@tonic-gate nfsstat4 rl_status; /* readlink result */ 398*7c478bd9Sstevel@tonic-gate utf8string rl_link; /* readlink result */ 399*7c478bd9Sstevel@tonic-gate } readlink4res_t; 400*7c478bd9Sstevel@tonic-gate 401*7c478bd9Sstevel@tonic-gate /* 402*7c478bd9Sstevel@tonic-gate * Generic NFS functions 403*7c478bd9Sstevel@tonic-gate */ 404*7c478bd9Sstevel@tonic-gate extern int boot_nfs_mountroot(char *); 405*7c478bd9Sstevel@tonic-gate extern int boot_nfs_unmountroot(void); 406*7c478bd9Sstevel@tonic-gate extern int lookup(char *pathname, struct nfs_file *, bool_t); 407*7c478bd9Sstevel@tonic-gate extern bool_t whoami(void); 408*7c478bd9Sstevel@tonic-gate extern bool_t getfile(char *, char *, struct in_addr *, char *); 409*7c478bd9Sstevel@tonic-gate 410*7c478bd9Sstevel@tonic-gate /* 411*7c478bd9Sstevel@tonic-gate * NFS Version 2 specific functions 412*7c478bd9Sstevel@tonic-gate */ 413*7c478bd9Sstevel@tonic-gate extern void nfs_error(enum nfsstat); 414*7c478bd9Sstevel@tonic-gate extern ssize_t nfsread(struct nfs_file *, char *, size_t); 415*7c478bd9Sstevel@tonic-gate extern int nfsgetattr(struct nfs_file *, struct vattr *); 416*7c478bd9Sstevel@tonic-gate extern int nfsgetdents(struct nfs_file *, struct dirent *, unsigned); 417*7c478bd9Sstevel@tonic-gate extern struct nfs_file *nfslookup(struct nfs_file *, char *, int *); 418*7c478bd9Sstevel@tonic-gate extern int nfsgetsymlink(struct nfs_file *cfile, char **path); 419*7c478bd9Sstevel@tonic-gate 420*7c478bd9Sstevel@tonic-gate /* 421*7c478bd9Sstevel@tonic-gate * NFS Version 3 specific functions 422*7c478bd9Sstevel@tonic-gate */ 423*7c478bd9Sstevel@tonic-gate extern void nfs3_error(enum nfsstat3); 424*7c478bd9Sstevel@tonic-gate extern ssize_t nfs3read(struct nfs_file *, char *, size_t); 425*7c478bd9Sstevel@tonic-gate extern int nfs3getattr(struct nfs_file *, struct vattr *); 426*7c478bd9Sstevel@tonic-gate extern int nfs3getdents(struct nfs_file *, struct dirent *, unsigned); 427*7c478bd9Sstevel@tonic-gate extern struct nfs_file *nfs3lookup(struct nfs_file *, char *, int *); 428*7c478bd9Sstevel@tonic-gate extern int nfs3getsymlink(struct nfs_file *, char **); 429*7c478bd9Sstevel@tonic-gate 430*7c478bd9Sstevel@tonic-gate /* 431*7c478bd9Sstevel@tonic-gate * NFS Version 4 specific functions 432*7c478bd9Sstevel@tonic-gate */ 433*7c478bd9Sstevel@tonic-gate extern void nfs4_error(enum nfsstat4); 434*7c478bd9Sstevel@tonic-gate extern ssize_t nfs4read(struct nfs_file *, char *, size_t); 435*7c478bd9Sstevel@tonic-gate extern int nfs4getattr(struct nfs_file *, struct vattr *); 436*7c478bd9Sstevel@tonic-gate extern int nfs4_getdents(struct nfs_file *, struct dirent *, unsigned); 437*7c478bd9Sstevel@tonic-gate extern struct nfs_file *nfs4lookup(struct nfs_file *, char *, int *); 438*7c478bd9Sstevel@tonic-gate extern struct nfs_file *nfs4lookupp(struct nfs_file *, int *, uint64_t *); 439*7c478bd9Sstevel@tonic-gate extern int nfs4getsymlink(struct nfs_file *, char **); 440*7c478bd9Sstevel@tonic-gate extern void compound_init(b_compound_t *, utf8string *, uint_t, uint_t, 441*7c478bd9Sstevel@tonic-gate struct nfs_bfh4 *); 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate /* 444*7c478bd9Sstevel@tonic-gate * NFSv4 xdr ops 445*7c478bd9Sstevel@tonic-gate */ 446*7c478bd9Sstevel@tonic-gate extern bool_t xdr_getattr4_args(XDR *, getattr4arg_t *); 447*7c478bd9Sstevel@tonic-gate extern bool_t xdr_getattr4_res(XDR *, getattr4res_t *); 448*7c478bd9Sstevel@tonic-gate extern bool_t xdr_lookup4_args(XDR *, lookup4arg_t *); 449*7c478bd9Sstevel@tonic-gate extern bool_t xdr_lookup4_res(XDR *, lookup4res_t *); 450*7c478bd9Sstevel@tonic-gate extern bool_t xdr_lookupp4_args(XDR *, lookupp4arg_t *); 451*7c478bd9Sstevel@tonic-gate extern bool_t xdr_read4_args(XDR *, read4arg_t *); 452*7c478bd9Sstevel@tonic-gate extern bool_t xdr_read4_res(XDR *, read4res_t *); 453*7c478bd9Sstevel@tonic-gate extern bool_t xdr_readdir4_args(XDR *, readdir4arg_t *); 454*7c478bd9Sstevel@tonic-gate extern bool_t xdr_readdir4_res(XDR *, readdir4res_t *); 455*7c478bd9Sstevel@tonic-gate extern bool_t xdr_readlink4_args(XDR *, readlink4arg_t *); 456*7c478bd9Sstevel@tonic-gate extern bool_t xdr_readlink4_res(XDR *, readlink4res_t *); 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 459*7c478bd9Sstevel@tonic-gate } 460*7c478bd9Sstevel@tonic-gate #endif 461*7c478bd9Sstevel@tonic-gate 462*7c478bd9Sstevel@tonic-gate #endif /* _NFS_INET_H */ 463