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