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 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 27 /* All Rights Reserved */ 28 29 #ifndef _NFS_NFS_H 30 #define _NFS_NFS_H 31 32 /* nfs.h 2.38 88/08/19 SMI */ 33 34 #include <sys/isa_defs.h> 35 #include <sys/vfs.h> 36 #include <sys/stream.h> 37 #include <rpc/types.h> 38 #include <sys/types32.h> 39 #ifdef _KERNEL 40 #include <rpc/rpc_rdma.h> 41 #include <rpc/rpc.h> 42 #include <sys/fcntl.h> 43 #include <sys/kstat.h> 44 #include <sys/dirent.h> 45 #include <sys/zone.h> 46 #include <sys/tsol/label.h> 47 #include <sys/nvpair.h> 48 #include <nfs/mount.h> 49 #include <sys/vfs_opreg.h> 50 #endif 51 #include <vm/page.h> 52 #include <rpc/rpc_sztypes.h> 53 #include <sys/sysmacros.h> 54 #ifdef __cplusplus 55 extern "C" { 56 #endif 57 58 /* 59 * Solaris NFS daemons configuration file location 60 */ 61 #define NFSADMIN "/etc/default/nfs" 62 63 /* 64 * remote file service numbers 65 */ 66 #define NFS_PROGRAM ((rpcprog_t)100003) 67 #define NFS_VERSMIN ((rpcvers_t)2) 68 #define NFS_VERSMAX ((rpcvers_t)4) 69 #define NFS_VERSION ((rpcvers_t)2) 70 #define NFS_PORT 2049 71 72 /* 73 * Used to determine registration and service handling of versions 74 */ 75 #define NFS_VERSMIN_DEFAULT ((rpcvers_t)2) 76 #define NFS_VERSMAX_DEFAULT ((rpcvers_t)4) 77 78 extern rpcvers_t nfs_versmin; 79 extern rpcvers_t nfs_versmax; 80 81 /* 82 * Default delegation setting for the server ==> "on" 83 */ 84 #define NFS_SERVER_DELEGATION_DEFAULT (TRUE) 85 86 /* Maximum size of data portion of a remote request */ 87 #define NFS_MAXDATA 8192 88 #define NFS_MAXNAMLEN 255 89 #define NFS_MAXPATHLEN 1024 90 91 /* 92 * Rpc retransmission parameters 93 */ 94 #define NFS_TIMEO 11 /* initial timeout for clts in 10th of a sec */ 95 #define NFS_RETRIES 5 /* times to retry request */ 96 #define NFS_COTS_TIMEO 600 /* initial timeout for cots in 10th of a sec */ 97 98 /* 99 * The value of UID_NOBODY/GID_NOBODY presented to the world via NFS. 100 * UID_NOBODY/GID_NOBODY is translated to NFS_UID_NOBODY/NFS_GID_NOBODY 101 * when being sent out over the network and NFS_UID_NOBODY/NFS_GID_NOBODY 102 * is translated to UID_NOBODY/GID_NOBODY when received. 103 */ 104 #define NFS_UID_NOBODY -2 105 #define NFS_GID_NOBODY -2 106 107 /* 108 * maximum transfer size for different interfaces 109 */ 110 #define ECTSIZE 2048 111 #define IETSIZE 8192 112 113 /* 114 * WebNFS error status 115 */ 116 enum wnfsstat { 117 WNFSERR_CLNT_FLAVOR = 20001 /* invalid client sec flavor */ 118 }; 119 120 /* 121 * Error status 122 * Should include all possible net errors. 123 * For now we just cast errno into an enum nfsstat. 124 */ 125 enum nfsstat { 126 NFS_OK = 0, /* no error */ 127 NFSERR_PERM = 1, /* Not owner */ 128 NFSERR_NOENT = 2, /* No such file or directory */ 129 NFSERR_IO = 5, /* I/O error */ 130 NFSERR_NXIO = 6, /* No such device or address */ 131 NFSERR_ACCES = 13, /* Permission denied */ 132 NFSERR_EXIST = 17, /* File exists */ 133 NFSERR_XDEV = 18, /* Cross-device link */ 134 NFSERR_NODEV = 19, /* No such device */ 135 NFSERR_NOTDIR = 20, /* Not a directory */ 136 NFSERR_ISDIR = 21, /* Is a directory */ 137 NFSERR_INVAL = 22, /* Invalid argument */ 138 NFSERR_FBIG = 27, /* File too large */ 139 NFSERR_NOSPC = 28, /* No space left on device */ 140 NFSERR_ROFS = 30, /* Read-only file system */ 141 NFSERR_OPNOTSUPP = 45, /* Operation not supported */ 142 NFSERR_NAMETOOLONG = 63, /* File name too long */ 143 NFSERR_NOTEMPTY = 66, /* Directory not empty */ 144 NFSERR_DQUOT = 69, /* Disc quota exceeded */ 145 NFSERR_STALE = 70, /* Stale NFS file handle */ 146 NFSERR_REMOTE = 71, /* Object is remote */ 147 NFSERR_WFLUSH = 99 /* write cache flushed */ 148 }; 149 150 typedef enum nfsstat nfsstat; 151 152 /* 153 * File types 154 */ 155 enum nfsftype { 156 NFNON, 157 NFREG, /* regular file */ 158 NFDIR, /* directory */ 159 NFBLK, /* block special */ 160 NFCHR, /* character special */ 161 NFLNK, /* symbolic link */ 162 NFSOC /* socket */ 163 }; 164 165 /* 166 * Macros for converting device numbers to and from the format 167 * SunOS 4.x used. SVR4 uses 14 bit majors and 18 bits minors, 168 * SunOS 4.x used 8 bit majors and 8 bit minors. It isn't sufficient 169 * to use the cmpdev() and expdev() macros because they only compress 170 * 7 bit (and smaller) majors. We must compress 8 bit majors too. 171 * If the major or minor exceeds 8 bits, then we send it out in 172 * full 32 bit format and hope that the peer can deal with it. 173 */ 174 175 #define SO4_BITSMAJOR 8 /* # of SunOS 4.x major device bits */ 176 #define SO4_BITSMINOR 8 /* # of SunOS 4.x minor device bits */ 177 #define SO4_MAXMAJ 0xff /* SunOS 4.x max major value */ 178 #define SO4_MAXMIN 0xff /* SunOS 4.x max minor value */ 179 180 /* 181 * Convert to over-the-wire device number format 182 */ 183 #define nfsv2_cmpdev(x) \ 184 ((uint32_t) \ 185 ((getmajor(x) > SO4_MAXMAJ || getminor(x) > SO4_MAXMIN) ? NODEV : \ 186 ((getmajor(x) << SO4_BITSMINOR) | (getminor(x) & SO4_MAXMIN)))) 187 188 /* 189 * Convert from over-the-wire format to SVR4 device number format 190 */ 191 #define nfsv2_expdev(x) \ 192 makedevice((((x) >> SO4_BITSMINOR) & SO4_MAXMAJ), (x) & SO4_MAXMIN) 193 194 /* 195 * Special kludge for fifos (named pipes) [to adhere to NFS Protocol Spec] 196 * 197 * VFIFO is not in the protocol spec (VNON will be replaced by VFIFO) 198 * so the over-the-wire representation is VCHR with a '-1' device number. 199 * 200 * NOTE: This kludge becomes unnecessary with the Protocol Revision, 201 * but it may be necessary to support it (backwards compatibility). 202 */ 203 #define NFS_FIFO_TYPE NFCHR 204 #define NFS_FIFO_MODE S_IFCHR 205 #define NFS_FIFO_DEV ((uint32_t)-1) 206 207 /* identify fifo in nfs attributes */ 208 #define NA_ISFIFO(NA) (((NA)->na_type == NFS_FIFO_TYPE) && \ 209 ((NA)->na_rdev == NFS_FIFO_DEV)) 210 211 /* set fifo in nfs attributes */ 212 #define NA_SETFIFO(NA) { \ 213 (NA)->na_type = NFS_FIFO_TYPE; \ 214 (NA)->na_rdev = NFS_FIFO_DEV; \ 215 (NA)->na_mode = ((NA)->na_mode & ~S_IFMT) | NFS_FIFO_MODE; \ 216 } 217 218 /* 219 * Check for time overflow using a kernel tunable to determine whether 220 * we should accept or reject an unsigned 32-bit time value. Time value in NFS 221 * v2/3 protocol is unsigned 32 bit, but ILP32 kernel only allows 31 bits. 222 * In nfsv4, time value is a signed 64 bit, so needs to be checked for 223 * overflow as well (e.g. for setattr). So define the tunable as follows: 224 * nfs_allow_preepoch_time is TRUE if pre-epoch (negative) times are allowed 225 * and is FALSE (the default) otherwise. For nfsv2/3 this means that 226 * if negative times are allowed, the uint32_t time value is interpreted 227 * as a signed int, otherwise as a large positive number. For nfsv4, 228 * we use the value as is - except that if negative times are not allowed, 229 * we will not accept a negative value otw. 230 * 231 * So for nfsv2/3 (uint32_t): 232 * 233 * If nfs_allow_preepoch_time is 234 * FALSE, the maximum time value is INT32_MAX for 32-bit kernels and 235 * UINT32_MAX for 64-bit kernels (to allow times larger than 2038) 236 * and the minimum is zero. Note that in that case, a 32-bit application 237 * running on a 64-bit kernel will not be able to access files with 238 * the larger time values. 239 * If nfs_allow_preepoch_time is TRUE, the maximum time value is INT32_MAX 240 * for both kernel configurations and the minimum is INT32_MIN. 241 * 242 * And for nfsv4 (int64_t): 243 * 244 * nfsv4 allows for negative values in the protocol, and has a 64-bit 245 * time field, so nfs_allow_preepoch_time can be ignored. 246 */ 247 #ifdef _KERNEL 248 249 extern bool_t nfs_allow_preepoch_time; 250 251 #ifdef _LP64 252 253 /* 254 * If no negative otw values are allowed, may use the full 32-bits of the 255 * time to represent time later than 2038, by presenting the value as an 256 * unsigned (but this can only be used by 64-bit apps due to cstat32 257 * restrictions). If negative values are allowed, cannot represent times 258 * after 2038. Either way, all 32 bits have a valid representation. 259 */ 260 261 /* Check if nfstime4 seconds (int64_t) can be stored in the system time */ 262 #define NFS4_TIME_OK(tt) TRUE 263 264 265 #define NFS3_TIME_OVERFLOW(tt) (FALSE) 266 #define NFS2_TIME_OVERFLOW(tt) (FALSE) 267 268 /* 269 * check if a time_t (int64_t) is ok when preepoch times are allowed - 270 * nfsv2/3: every 32-bit value is accepted, but can't overflow 64->32. 271 * nfsv4: every value is valid. 272 */ 273 #define NFS_PREEPOCH_TIME_T_OK(tt) \ 274 (((tt) >= (time_t)INT32_MIN) && ((tt) <= (time_t)INT32_MAX)) 275 276 /* 277 * check if a time_t (int64_t) is ok when preepoch times are not allowed - 278 * nfsv2/3: every positive 32-bit value is accepted, but can't overflow 64->32. 279 * nfsv4: every value is valid. 280 */ 281 #define NFS_NO_PREEPOCH_TIME_T_OK(tt) \ 282 (((tt) >= 0) && ((tt) <= (time_t)(ulong_t)UINT32_MAX)) 283 284 #else /* not _LP64 */ 285 286 /* 287 * Cannot represent times after 2038 in a 32-bit kernel, but we may wish to 288 * restrict the use of negative values (which violate the protocol). 289 * So if negative times allowed, all uint32 time values are valid. Otherwise 290 * only those which are less than INT32_MAX (msb=0). 291 * 292 * NFSv4 uses int64_t for the time, so in a 32-bit kernel the nfsv4 value 293 * must fit in an int32_t. 294 */ 295 296 /* Only allow signed 32-bit time values */ 297 298 /* Check if an nfstime4 (int64_t) can be stored in the system time */ 299 #define NFS4_TIME_OK(tt) \ 300 (((tt) <= INT32_MAX) && ((tt) >= INT32_MIN)) 301 302 #define NFS3_TIME_OVERFLOW(tt) ((tt) > INT32_MAX) 303 #define NFS2_TIME_OVERFLOW(tt) ((tt) > INT32_MAX) 304 305 /* 306 * check if a time_t (int32_t) is ok when preepoch times are allowed - 307 * every 32-bit value is accepted 308 */ 309 #define NFS_PREEPOCH_TIME_T_OK(tt) TRUE 310 311 /* 312 * check if a time_t (int32_t) is ok when preepoch times are not allowed - 313 * only positive values are accepted. 314 */ 315 #define NFS_NO_PREEPOCH_TIME_T_OK(tt) ((tt) >= 0) 316 317 #endif /* _LP64 */ 318 319 /* Check if an nfstime3 (uint32_t) can be stored in the system time */ 320 #define NFS3_TIME_OK(tt) \ 321 (nfs_allow_preepoch_time || (!NFS3_TIME_OVERFLOW(tt))) 322 323 /* Check if an nfs2_timeval (uint32_t) can be stored in the system time. */ 324 #define NFS2_TIME_OK(tt) \ 325 (nfs_allow_preepoch_time || (!NFS2_TIME_OVERFLOW(tt))) 326 327 /* 328 * Test if time_t (signed long) can be sent over the wire - for v2/3 only if: 329 * 1. The time value can fit in a uint32_t; and 330 * 2. Either the time value is positive or allow preepoch times. 331 * No restrictions for nfsv4. 332 */ 333 #define NFS_TIME_T_OK(tt) \ 334 (nfs_allow_preepoch_time ? \ 335 NFS_PREEPOCH_TIME_T_OK(tt) : NFS_NO_PREEPOCH_TIME_T_OK(tt)) 336 337 #define NFS4_TIME_T_OK(tt) TRUE 338 339 /* Test if all attr times are valid */ 340 #define NFS_VAP_TIME_OK(vap) \ 341 (nfs_allow_preepoch_time ? \ 342 (NFS_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) && \ 343 NFS_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) && \ 344 NFS_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)) : \ 345 (NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) && \ 346 NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) && \ 347 NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec))) 348 349 #define NFS4_VAP_TIME_OK(vap) TRUE 350 351 /* 352 * To extend the sign or not extend the sign, that is the question. 353 * Note: The correct way is to code a macro: 354 * #define NFS_TIME_T_CONVERT(tt) \ 355 * (nfs_allow_preepoch_time ? (int32_t)(tt) : (uint32_t)(tt)) 356 * But the 64-bit compiler does not extend the sign in that case (why?) 357 * so we'll do it the ugly way... 358 */ 359 #define NFS_TIME_T_CONVERT(systt, tt) \ 360 if (nfs_allow_preepoch_time) { \ 361 systt = (int32_t)(tt); \ 362 } else { \ 363 systt = (uint32_t)(tt); \ 364 } 365 366 /* macro to check for overflowed time attribute fields - version 3 */ 367 #define NFS3_FATTR_TIME_OK(attrs) \ 368 (NFS3_TIME_OK((attrs)->atime.seconds) && \ 369 NFS3_TIME_OK((attrs)->mtime.seconds) && \ 370 NFS3_TIME_OK((attrs)->ctime.seconds)) 371 372 /* macro to check for overflowed time attribute fields - version 2 */ 373 #define NFS2_FATTR_TIME_OK(attrs) \ 374 (NFS2_TIME_OK((attrs)->na_atime.tv_sec) && \ 375 NFS2_TIME_OK((attrs)->na_mtime.tv_sec) && \ 376 NFS2_TIME_OK((attrs)->na_ctime.tv_sec)) 377 378 /* Check that a size3 value is not overflowed */ 379 #define NFS3_SIZE_OK(size) ((size) <= MAXOFFSET_T) 380 381 #endif /* _KERNEL */ 382 383 /* 384 * Size of an fhandle in bytes 385 */ 386 #define NFS_FHSIZE 32 387 388 struct nfs_fid { 389 ushort_t nf_len; 390 ushort_t nf_pad; 391 char nf_data[NFS_FHSIZE]; 392 }; 393 394 /* 395 * "Legacy" filehandles use NFS_FHMAXDATA (10) byte fids. Filesystems that 396 * return a larger fid than NFS_FHMAXDATA, such as ZFS's .zfs snapshot 397 * directory, can use up to (((64 - 8) / 2) - 2) bytes for their fid. 398 * This currently holds for both NFSv3 and NFSv4. 399 */ 400 #define NFS_FHMAXDATA 10 401 #define NFS_FH3MAXDATA 26 402 #define NFS_FH4MAXDATA 26 403 404 /* 405 * The original nfs file handle size for version 3 was 32 which was 406 * the same in version 2; now we're making it bigger to to deal with 407 * ZFS snapshot FIDs. 408 * 409 * If the size of fhandle3_t changes or if Version 3 uses some other 410 * filehandle format, this constant may need to change. 411 */ 412 413 #define NFS3_OLDFHSIZE 32 414 #define NFS3_MAXFHSIZE 64 415 416 /* 417 * This is the actual definition of a legacy filehandle. There is some 418 * dependence on this layout in NFS-related code, particularly in the 419 * user-level lock manager, so be careful about changing it. 420 * 421 * Currently only NFSv2 uses this structure. 422 */ 423 424 typedef struct svcfh { 425 fsid_t fh_fsid; /* filesystem id */ 426 ushort_t fh_len; /* file number length */ 427 char fh_data[NFS_FHMAXDATA]; /* and data */ 428 ushort_t fh_xlen; /* export file number length */ 429 char fh_xdata[NFS_FHMAXDATA]; /* and data */ 430 } fhandle_t; 431 432 /* 433 * This is the in-memory structure for an NFSv3 extended filehandle. 434 */ 435 typedef struct { 436 fsid_t _fh3_fsid; /* filesystem id */ 437 ushort_t _fh3_len; /* file number length */ 438 char _fh3_data[NFS_FH3MAXDATA]; /* and data */ 439 ushort_t _fh3_xlen; /* export file number length */ 440 char _fh3_xdata[NFS_FH3MAXDATA]; /* and data */ 441 } fhandle3_t; 442 443 /* 444 * This is the in-memory structure for an NFSv4 extended filehandle. 445 */ 446 typedef struct { 447 fsid_t fhx_fsid; /* filesystem id */ 448 ushort_t fhx_len; /* file number length */ 449 char fhx_data[NFS_FH4MAXDATA]; /* and data */ 450 ushort_t fhx_xlen; /* export file number length */ 451 char fhx_xdata[NFS_FH4MAXDATA]; /* and data */ 452 } fhandle4_t; 453 454 /* 455 * Arguments to remote write and writecache 456 */ 457 /* 458 * The `over the wire' representation of the first four arguments. 459 */ 460 struct otw_nfswriteargs { 461 fhandle_t otw_wa_fhandle; 462 uint32_t otw_wa_begoff; 463 uint32_t otw_wa_offset; 464 uint32_t otw_wa_totcount; 465 }; 466 467 struct nfswriteargs { 468 struct otw_nfswriteargs *wa_args; /* ptr to the otw arguments */ 469 struct otw_nfswriteargs wa_args_buf; /* space for otw arguments */ 470 uint32_t wa_count; 471 char *wa_data; /* data to write (up to NFS_MAXDATA) */ 472 mblk_t *wa_mblk; /* pointer to mblks containing data */ 473 #ifdef _KERNEL 474 /* rdma related info */ 475 struct clist *wa_rlist; 476 CONN *wa_conn; 477 #endif /* _KERNEL */ 478 }; 479 #define wa_fhandle wa_args->otw_wa_fhandle 480 #define wa_begoff wa_args->otw_wa_begoff 481 #define wa_offset wa_args->otw_wa_offset 482 #define wa_totcount wa_args->otw_wa_totcount 483 484 /* 485 * NFS timeval struct using unsigned int as specified in V2 protocol. 486 * tv_sec and tv_usec used to match existing code. 487 */ 488 struct nfs2_timeval { 489 uint32_t tv_sec; 490 uint32_t tv_usec; 491 }; 492 typedef struct nfs2_timeval nfs2_timeval; 493 494 /* 495 * File attributes 496 */ 497 struct nfsfattr { 498 enum nfsftype na_type; /* file type */ 499 uint32_t na_mode; /* protection mode bits */ 500 uint32_t na_nlink; /* # hard links */ 501 uint32_t na_uid; /* owner user id */ 502 uint32_t na_gid; /* owner group id */ 503 uint32_t na_size; /* file size in bytes */ 504 uint32_t na_blocksize; /* preferred block size */ 505 uint32_t na_rdev; /* special device # */ 506 uint32_t na_blocks; /* Kb of disk used by file */ 507 uint32_t na_fsid; /* device # */ 508 uint32_t na_nodeid; /* inode # */ 509 struct nfs2_timeval na_atime; /* time of last access */ 510 struct nfs2_timeval na_mtime; /* time of last modification */ 511 struct nfs2_timeval na_ctime; /* time of last change */ 512 }; 513 514 #define n2v_type(x) (NA_ISFIFO(x) ? VFIFO : nf_to_vt[(x)->na_type]) 515 #define n2v_rdev(x) (NA_ISFIFO(x) ? 0 : (x)->na_rdev) 516 517 /* 518 * Arguments to remote read 519 */ 520 struct nfsreadargs { 521 fhandle_t ra_fhandle; /* handle for file */ 522 uint32_t ra_offset; /* byte offset in file */ 523 uint32_t ra_count; /* immediate read count */ 524 uint32_t ra_totcount; /* total read cnt (from this offset) */ 525 #ifdef _KERNEL 526 /* used in rdma transports */ 527 caddr_t ra_data; /* destination for read data */ 528 struct clist *ra_wlist; 529 CONN *ra_conn; 530 #endif 531 }; 532 533 /* 534 * Status OK portion of remote read reply 535 */ 536 struct nfsrrok { 537 struct nfsfattr rrok_attr; /* attributes, need for pagin */ 538 uint32_t rrok_count; /* bytes of data */ 539 char *rrok_data; /* data (up to NFS_MAXDATA bytes) */ 540 uint_t rrok_bufsize; /* size of kmem_alloc'd buffer */ 541 mblk_t *rrok_mp; /* mblk_t contains data for reply */ 542 #ifdef _KERNEL 543 uint_t rrok_wlist_len; 544 struct clist *rrok_wlist; 545 #endif 546 }; 547 548 /* 549 * Reply from remote read 550 */ 551 struct nfsrdresult { 552 nfsstat rr_status; /* status of read */ 553 union { 554 struct nfsrrok rr_ok_u; /* attributes, need for pagin */ 555 } rr_u; 556 }; 557 #define rr_ok rr_u.rr_ok_u 558 #define rr_attr rr_u.rr_ok_u.rrok_attr 559 #define rr_count rr_u.rr_ok_u.rrok_count 560 #define rr_bufsize rr_u.rr_ok_u.rrok_bufsize 561 #define rr_data rr_u.rr_ok_u.rrok_data 562 #define rr_mp rr_u.rr_ok_u.rrok_mp 563 564 /* 565 * File attributes which can be set 566 */ 567 struct nfssattr { 568 uint32_t sa_mode; /* protection mode bits */ 569 uint32_t sa_uid; /* owner user id */ 570 uint32_t sa_gid; /* owner group id */ 571 uint32_t sa_size; /* file size in bytes */ 572 struct nfs2_timeval sa_atime; /* time of last access */ 573 struct nfs2_timeval sa_mtime; /* time of last modification */ 574 }; 575 576 577 /* 578 * Reply status with file attributes 579 */ 580 struct nfsattrstat { 581 nfsstat ns_status; /* reply status */ 582 union { 583 struct nfsfattr ns_attr_u; /* NFS_OK: file attributes */ 584 } ns_u; 585 }; 586 #define ns_attr ns_u.ns_attr_u 587 588 589 /* 590 * NFS_OK part of read sym link reply union 591 */ 592 struct nfssrok { 593 uint32_t srok_count; /* size of string */ 594 char *srok_data; /* string (up to NFS_MAXPATHLEN bytes) */ 595 }; 596 597 /* 598 * Result of reading symbolic link 599 */ 600 struct nfsrdlnres { 601 nfsstat rl_status; /* status of symlink read */ 602 union { 603 struct nfssrok rl_srok_u; /* name of linked to */ 604 } rl_u; 605 }; 606 #define rl_srok rl_u.rl_srok_u 607 #define rl_count rl_u.rl_srok_u.srok_count 608 #define rl_data rl_u.rl_srok_u.srok_data 609 610 611 /* 612 * Arguments to readdir 613 */ 614 struct nfsrddirargs { 615 fhandle_t rda_fh; /* directory handle */ 616 uint32_t rda_offset; /* offset in directory (opaque) */ 617 uint32_t rda_count; /* number of directory bytes to read */ 618 }; 619 620 /* 621 * NFS_OK part of readdir result 622 */ 623 struct nfsrdok { 624 uint32_t rdok_offset; /* next offset (opaque) */ 625 uint32_t rdok_size; /* size in bytes of entries */ 626 bool_t rdok_eof; /* true if last entry is in result */ 627 struct dirent64 *rdok_entries; /* variable number of entries */ 628 }; 629 630 /* 631 * Readdir result 632 */ 633 struct nfsrddirres { 634 nfsstat rd_status; 635 uint_t rd_bufsize; /* client request size (not xdr'ed) */ 636 union { 637 struct nfsrdok rd_rdok_u; 638 } rd_u; 639 }; 640 #define rd_rdok rd_u.rd_rdok_u 641 #define rd_offset rd_u.rd_rdok_u.rdok_offset 642 #define rd_size rd_u.rd_rdok_u.rdok_size 643 #define rd_eof rd_u.rd_rdok_u.rdok_eof 644 #define rd_entries rd_u.rd_rdok_u.rdok_entries 645 646 647 /* 648 * Arguments for directory operations 649 */ 650 struct nfsdiropargs { 651 fhandle_t *da_fhandle; /* pointer to directory file handle */ 652 char *da_name; /* name (up to NFS_MAXNAMLEN bytes) */ 653 fhandle_t da_fhandle_buf; /* directory file handle */ 654 int da_flags; /* flags, see below */ 655 }; 656 #define DA_FREENAME 1 657 658 /* 659 * NFS_OK part of directory operation result 660 */ 661 struct nfsdrok { 662 fhandle_t drok_fhandle; /* result file handle */ 663 struct nfsfattr drok_attr; /* result file attributes */ 664 }; 665 666 /* 667 * Results from directory operation 668 */ 669 struct nfsdiropres { 670 nfsstat dr_status; /* result status */ 671 union { 672 struct nfsdrok dr_drok_u; /* NFS_OK result */ 673 } dr_u; 674 }; 675 #define dr_drok dr_u.dr_drok_u 676 #define dr_fhandle dr_u.dr_drok_u.drok_fhandle 677 #define dr_attr dr_u.dr_drok_u.drok_attr 678 679 /* 680 * arguments to setattr 681 */ 682 struct nfssaargs { 683 fhandle_t saa_fh; /* fhandle of file to be set */ 684 struct nfssattr saa_sa; /* new attributes */ 685 }; 686 687 /* 688 * arguments to create and mkdir 689 */ 690 struct nfscreatargs { 691 struct nfsdiropargs ca_da; /* file name to create and parent dir */ 692 struct nfssattr *ca_sa; /* initial attributes */ 693 struct nfssattr ca_sa_buf; /* space to store attributes */ 694 }; 695 696 /* 697 * arguments to link 698 */ 699 struct nfslinkargs { 700 fhandle_t *la_from; /* old file */ 701 fhandle_t la_from_buf; /* old file */ 702 struct nfsdiropargs la_to; /* new file and parent dir */ 703 }; 704 705 /* 706 * arguments to rename 707 */ 708 struct nfsrnmargs { 709 struct nfsdiropargs rna_from; /* old file and parent dir */ 710 struct nfsdiropargs rna_to; /* new file and parent dir */ 711 }; 712 713 /* 714 * arguments to symlink 715 */ 716 struct nfsslargs { 717 struct nfsdiropargs sla_from; /* old file and parent dir */ 718 char *sla_tnm; /* new name */ 719 int sla_tnm_flags; /* flags for name */ 720 struct nfssattr *sla_sa; /* attributes */ 721 struct nfssattr sla_sa_buf; /* attributes buffer */ 722 }; 723 #define SLA_FREETNM 1 724 725 /* 726 * NFS_OK part of statfs operation 727 */ 728 struct nfsstatfsok { 729 uint32_t fsok_tsize; /* preferred transfer size in bytes */ 730 uint32_t fsok_bsize; /* fundamental file system block size */ 731 uint32_t fsok_blocks; /* total blocks in file system */ 732 uint32_t fsok_bfree; /* free blocks in fs */ 733 uint32_t fsok_bavail; /* free blocks avail to non-superuser */ 734 }; 735 736 /* 737 * Results of statfs operation 738 */ 739 struct nfsstatfs { 740 nfsstat fs_status; /* result status */ 741 union { 742 struct nfsstatfsok fs_fsok_u; /* NFS_OK result */ 743 } fs_u; 744 }; 745 #define fs_fsok fs_u.fs_fsok_u 746 #define fs_tsize fs_u.fs_fsok_u.fsok_tsize 747 #define fs_bsize fs_u.fs_fsok_u.fsok_bsize 748 #define fs_blocks fs_u.fs_fsok_u.fsok_blocks 749 #define fs_bfree fs_u.fs_fsok_u.fsok_bfree 750 #define fs_bavail fs_u.fs_fsok_u.fsok_bavail 751 752 #ifdef _KERNEL 753 /* 754 * XDR routines for handling structures defined above 755 */ 756 extern bool_t xdr_attrstat(XDR *, struct nfsattrstat *); 757 extern bool_t xdr_fastattrstat(XDR *, struct nfsattrstat *); 758 extern bool_t xdr_creatargs(XDR *, struct nfscreatargs *); 759 extern bool_t xdr_diropargs(XDR *, struct nfsdiropargs *); 760 extern bool_t xdr_diropres(XDR *, struct nfsdiropres *); 761 extern bool_t xdr_fastdiropres(XDR *, struct nfsdiropres *); 762 extern bool_t xdr_drok(XDR *, struct nfsdrok *); 763 #ifdef _LITTLE_ENDIAN 764 extern bool_t xdr_fastdrok(XDR *, struct nfsdrok *); 765 extern bool_t xdr_fastfattr(XDR *, struct nfsfattr *); 766 #endif 767 extern bool_t xdr_fattr(XDR *, struct nfsfattr *); 768 extern bool_t xdr_fhandle(XDR *, fhandle_t *); 769 extern bool_t xdr_fastfhandle(XDR *, fhandle_t **); 770 extern bool_t xdr_linkargs(XDR *, struct nfslinkargs *); 771 extern bool_t xdr_rddirargs(XDR *, struct nfsrddirargs *); 772 extern bool_t xdr_putrddirres(XDR *, struct nfsrddirres *); 773 extern bool_t xdr_getrddirres(XDR *, struct nfsrddirres *); 774 extern bool_t xdr_rdlnres(XDR *, struct nfsrdlnres *); 775 extern bool_t xdr_rdresult(XDR *, struct nfsrdresult *); 776 extern bool_t xdr_readargs(XDR *, struct nfsreadargs *); 777 extern bool_t xdr_readlink(XDR *, fhandle_t *); 778 extern bool_t xdr_rnmargs(XDR *, struct nfsrnmargs *); 779 extern bool_t xdr_rrok(XDR *, struct nfsrrok *); 780 extern bool_t xdr_saargs(XDR *, struct nfssaargs *); 781 extern bool_t xdr_sattr(XDR *, struct nfssattr *); 782 extern bool_t xdr_slargs(XDR *, struct nfsslargs *); 783 extern bool_t xdr_srok(XDR *, struct nfssrok *); 784 extern bool_t xdr_nfs2_timeval(XDR *, struct nfs2_timeval *); 785 extern bool_t xdr_writeargs(XDR *, struct nfswriteargs *); 786 extern bool_t xdr_fsok(XDR *, struct nfsstatfsok *); 787 #ifdef _LITTLE_ENDIAN 788 extern bool_t xdr_fastfsok(XDR *, struct nfsstatfsok *); 789 extern bool_t xdr_fastenum(XDR *, enum_t *); 790 #endif 791 extern bool_t xdr_statfs(XDR *, struct nfsstatfs *); 792 extern bool_t xdr_faststatfs(XDR *, struct nfsstatfs *); 793 #endif 794 795 /* 796 * Remote file service routines 797 */ 798 #define RFS_NULL 0 799 #define RFS_GETATTR 1 800 #define RFS_SETATTR 2 801 #define RFS_ROOT 3 802 #define RFS_LOOKUP 4 803 #define RFS_READLINK 5 804 #define RFS_READ 6 805 #define RFS_WRITECACHE 7 806 #define RFS_WRITE 8 807 #define RFS_CREATE 9 808 #define RFS_REMOVE 10 809 #define RFS_RENAME 11 810 #define RFS_LINK 12 811 #define RFS_SYMLINK 13 812 #define RFS_MKDIR 14 813 #define RFS_RMDIR 15 814 #define RFS_READDIR 16 815 #define RFS_STATFS 17 816 #define RFS_NPROC 18 817 818 #ifdef _KERNEL 819 /* 820 * The NFS Version 2 service procedures 821 */ 822 struct exportinfo; /* defined in nfs/export.h */ 823 struct servinfo; /* defined in nfs/nfs_clnt.h */ 824 struct mntinfo; /* defined in nfs/nfs_clnt.h */ 825 826 extern void rfs_getattr(fhandle_t *, struct nfsattrstat *, 827 struct exportinfo *, struct svc_req *, cred_t *); 828 extern void *rfs_getattr_getfh(fhandle_t *); 829 extern void rfs_setattr(struct nfssaargs *, struct nfsattrstat *, 830 struct exportinfo *, struct svc_req *, cred_t *); 831 extern void *rfs_setattr_getfh(struct nfssaargs *); 832 extern void rfs_lookup(struct nfsdiropargs *, struct nfsdiropres *, 833 struct exportinfo *, struct svc_req *, cred_t *); 834 extern void *rfs_lookup_getfh(struct nfsdiropargs *); 835 extern void rfs_readlink(fhandle_t *, struct nfsrdlnres *, 836 struct exportinfo *, struct svc_req *, cred_t *); 837 extern void *rfs_readlink_getfh(fhandle_t *); 838 extern void rfs_rlfree(struct nfsrdlnres *); 839 extern void rfs_read(struct nfsreadargs *, struct nfsrdresult *, 840 struct exportinfo *, struct svc_req *, cred_t *); 841 extern void *rfs_read_getfh(struct nfsreadargs *); 842 extern void rfs_rdfree(struct nfsrdresult *); 843 extern void rfs_write_sync(struct nfswriteargs *, struct nfsattrstat *, 844 struct exportinfo *, struct svc_req *, cred_t *); 845 extern void rfs_write(struct nfswriteargs *, struct nfsattrstat *, 846 struct exportinfo *, struct svc_req *, cred_t *); 847 extern void *rfs_write_getfh(struct nfswriteargs *); 848 extern void rfs_create(struct nfscreatargs *, struct nfsdiropres *, 849 struct exportinfo *, struct svc_req *, cred_t *); 850 extern void *rfs_create_getfh(struct nfscreatargs *); 851 extern void rfs_remove(struct nfsdiropargs *, enum nfsstat *, 852 struct exportinfo *, struct svc_req *, cred_t *); 853 extern void *rfs_remove_getfh(struct nfsdiropargs *); 854 extern void rfs_rename(struct nfsrnmargs *, enum nfsstat *, 855 struct exportinfo *, struct svc_req *, cred_t *); 856 extern void *rfs_rename_getfh(struct nfsrnmargs *); 857 extern void rfs_link(struct nfslinkargs *, enum nfsstat *, 858 struct exportinfo *, struct svc_req *, cred_t *); 859 extern void *rfs_link_getfh(struct nfslinkargs *); 860 extern void rfs_symlink(struct nfsslargs *, enum nfsstat *, 861 struct exportinfo *, struct svc_req *, cred_t *); 862 extern void *rfs_symlink_getfh(struct nfsslargs *); 863 extern void rfs_mkdir(struct nfscreatargs *, struct nfsdiropres *, 864 struct exportinfo *, struct svc_req *, cred_t *); 865 extern void *rfs_mkdir_getfh(struct nfscreatargs *); 866 extern void rfs_rmdir(struct nfsdiropargs *, enum nfsstat *, 867 struct exportinfo *, struct svc_req *, cred_t *); 868 extern void *rfs_rmdir_getfh(struct nfsdiropargs *); 869 extern void rfs_readdir(struct nfsrddirargs *, struct nfsrddirres *, 870 struct exportinfo *, struct svc_req *, cred_t *); 871 extern void *rfs_readdir_getfh(struct nfsrddirargs *); 872 extern void rfs_rddirfree(struct nfsrddirres *); 873 extern void rfs_statfs(fhandle_t *, struct nfsstatfs *, 874 struct exportinfo *, struct svc_req *, cred_t *); 875 extern void *rfs_statfs_getfh(fhandle_t *); 876 extern void rfs_srvrinit(void); 877 extern void rfs_srvrfini(void); 878 879 /* 880 * flags to define path types during Multi Component Lookups 881 * using the public filehandle 882 */ 883 #define URLPATH 0x01 /* Universal Resource Locator path */ 884 #define NATIVEPATH 0x02 /* Native path, i.e., via mount protocol */ 885 #define SECURITY_QUERY 0x04 /* Security query */ 886 887 /* index for svstat_ptr */ 888 enum nfs_svccounts {NFS_CALLS, NFS_BADCALLS, NFS_REFERRALS, NFS_REFERLINKS}; 889 890 /* function defs for NFS kernel */ 891 extern int nfs_waitfor_purge_complete(vnode_t *); 892 extern int nfs_validate_caches(vnode_t *, cred_t *); 893 extern void nfs_purge_caches(vnode_t *, int, cred_t *); 894 extern void nfs_purge_rddir_cache(vnode_t *); 895 extern void nfs_attrcache(vnode_t *, struct nfsfattr *, hrtime_t); 896 extern int nfs_cache_fattr(vnode_t *, struct nfsfattr *, vattr_t *, 897 hrtime_t, cred_t *); 898 extern void nfs_attr_cache(vnode_t *, vattr_t *, hrtime_t, cred_t *); 899 extern void nfs_attrcache_va(vnode_t *, struct vattr *); 900 extern int nfs_getattr_otw(vnode_t *, struct vattr *, cred_t *); 901 extern int nfsgetattr(vnode_t *, struct vattr *, cred_t *); 902 extern int nattr_to_vattr(vnode_t *, struct nfsfattr *, struct vattr *); 903 extern void nfs_async_manager(struct vfs *); 904 extern void nfs_async_manager_stop(struct vfs *); 905 extern void nfs_async_stop(struct vfs *); 906 extern int nfs_async_stop_sig(struct vfs *); 907 extern int nfs_clntinit(void); 908 extern void nfs_clntfini(void); 909 extern int nfstsize(void); 910 extern int nfs_srvinit(void); 911 extern void nfs_srvfini(void); 912 extern int vattr_to_sattr(struct vattr *, struct nfssattr *); 913 extern void setdiropargs(struct nfsdiropargs *, char *, vnode_t *); 914 extern int setdirgid(vnode_t *, gid_t *, cred_t *); 915 extern int setdirmode(vnode_t *, mode_t *, cred_t *); 916 extern int newnum(void); 917 extern char *newname(void); 918 extern int nfs_subrinit(void); 919 extern void nfs_subrfini(void); 920 extern enum nfsstat puterrno(int); 921 extern int geterrno(enum nfsstat); 922 extern int nfsinit(int, char *); 923 extern void nfsfini(void); 924 extern int nfs_vfsinit(void); 925 extern void nfs_vfsfini(void); 926 extern int nfs_dump(vnode_t *, caddr_t, offset_t, offset_t, 927 caller_context_t *); 928 extern void nfs_perror(int error, char *fmt, ...); 929 extern void nfs_cmn_err(int error, int level, char *fmt, ...); 930 extern int nfs_addcllock(vnode_t *vp, struct flock64 *bfp); 931 extern void nfs_rmcllock(vnode_t *vp, struct flock64 *bfp); 932 extern void nfs_lockrelease(vnode_t *vp, int flag, 933 offset_t offset, cred_t *credp); 934 extern int vattr_to_nattr(struct vattr *, struct nfsfattr *); 935 extern int mount_root(char *, char *, int, struct nfs_args *, int *); 936 extern void nfs_lockcompletion(vnode_t *vp, int cmd); 937 extern void nfs_add_locking_id(vnode_t *, pid_t, int, char *, int); 938 extern void nfs3copyfh(caddr_t, vnode_t *); 939 extern void nfscopyfh(caddr_t, vnode_t *); 940 extern int nfs3lookup(vnode_t *, char *, vnode_t **, struct pathname *, 941 int, vnode_t *, cred_t *, int); 942 extern int nfslookup(vnode_t *, char *, vnode_t **, struct pathname *, 943 int, vnode_t *, cred_t *, int); 944 extern void sv_free(struct servinfo *); 945 extern int nfsauth_access(struct exportinfo *exi, struct svc_req *req); 946 extern void nfsauth_init(); 947 extern void nfsauth_fini(); 948 extern int nfs_setopts(vnode_t *vp, model_t model, struct nfs_args *args); 949 extern int nfs_mount_label_policy(vfs_t *vfsp, struct netbuf *addr, 950 struct knetconfig *knconf, cred_t *cr); 951 extern boolean_t nfs_has_ctty(void); 952 extern void nfs_srv_stop_all(void); 953 extern void nfs_srv_quiesce_all(void); 954 extern void (*nfs_srv_quiesce_func)(void); 955 extern int rfs4_dss_setpaths(char *, size_t); 956 extern int (*nfs_srv_dss_func)(char *, size_t); 957 extern time_t rfs4_lease_time; 958 extern time_t rfs4_grace_period; 959 extern nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths; 960 961 962 extern kstat_named_t *global_svstat_ptr[]; 963 964 extern krwlock_t rroklock; 965 extern vtype_t nf_to_vt[]; 966 extern kstat_named_t *rfsproccnt_v2_ptr; 967 extern kmutex_t nfs_minor_lock; 968 extern int nfs_major; 969 extern int nfs_minor; 970 extern vfsops_t *nfs_vfsops; 971 extern struct vnodeops *nfs_vnodeops; 972 extern const struct fs_operation_def nfs_vnodeops_template[]; 973 extern int nfsfstyp; 974 975 /* 976 * Per-zone stats as consumed by nfsstat(1m) 977 */ 978 struct nfs_version_stats { 979 kstat_named_t *aclreqcnt_ptr; /* nfs_acl:0:aclreqcnt_v? */ 980 kstat_named_t *aclproccnt_ptr; /* nfs_acl:0:aclproccnt_v? */ 981 kstat_named_t *rfsreqcnt_ptr; /* nfs:0:rfsreqcnt_v? */ 982 kstat_named_t *rfsproccnt_ptr; /* nfs:0:rfsproccnt_v? */ 983 }; 984 985 /* 986 * A bit of asymmetry: nfs:0:nfs_client isn't part of this structure. 987 */ 988 struct nfs_stats { 989 kstat_named_t *nfs_stats_svstat_ptr[NFS_VERSMAX + 1]; 990 struct nfs_version_stats nfs_stats_v2; 991 struct nfs_version_stats nfs_stats_v3; 992 struct nfs_version_stats nfs_stats_v4; 993 }; 994 995 /* 996 * Key used to retrieve counters. 997 */ 998 extern zone_key_t nfsstat_zone_key; 999 1000 /* 1001 * Zone callback functions. 1002 */ 1003 extern void *nfsstat_zone_init(zoneid_t); 1004 extern void nfsstat_zone_fini(zoneid_t, void *); 1005 1006 #endif /* _KERNEL */ 1007 1008 /* 1009 * Version 3 declarations and definitions. 1010 */ 1011 1012 #define NFS3_FHSIZE 64 1013 #define NFS3_COOKIEVERFSIZE 8 1014 #define NFS3_CREATEVERFSIZE 8 1015 #define NFS3_WRITEVERFSIZE 8 1016 1017 typedef char *filename3; 1018 1019 typedef char *nfspath3; 1020 1021 #define nfs3nametoolong ((char *)-1) 1022 1023 typedef uint64 fileid3; 1024 1025 typedef uint64 cookie3; 1026 1027 typedef uint32 uid3; 1028 1029 typedef uint32 gid3; 1030 1031 typedef uint64 size3; 1032 1033 typedef uint64 offset3; 1034 1035 typedef uint32 mode3; 1036 1037 typedef uint32 count3; 1038 1039 /* 1040 * These three are really opaque arrays, but we treat them as 1041 * uint64 for efficiency sake 1042 */ 1043 typedef uint64 cookieverf3; 1044 1045 typedef uint64 createverf3; 1046 1047 typedef uint64 writeverf3; 1048 1049 typedef struct nfs_fh3 { 1050 uint_t fh3_length; 1051 union nfs_fh3_u { 1052 struct nfs_fh3_i { 1053 fhandle3_t fh3_i; 1054 } nfs_fh3_i; 1055 char data[NFS3_FHSIZE]; 1056 } fh3_u; 1057 uint_t fh3_flags; 1058 } nfs_fh3; 1059 #define fh3_fsid fh3_u.nfs_fh3_i.fh3_i._fh3_fsid 1060 #define fh3_len fh3_u.nfs_fh3_i.fh3_i._fh3_len 1061 #define fh3_data fh3_u.nfs_fh3_i.fh3_i._fh3_data 1062 #define fh3_xlen fh3_u.nfs_fh3_i.fh3_i._fh3_xlen 1063 #define fh3_xdata fh3_u.nfs_fh3_i.fh3_i._fh3_xdata 1064 #define FH3TOFIDP(fh) ((fid_t *)&((fh)->fh3_len)) 1065 #define FH3TOXFIDP(fh) ((fid_t *)&((fh)->fh3_xlen)) 1066 1067 /* 1068 * nfs_fh3.fh3_flags values 1069 */ 1070 #define FH_WEBNFS 0x1 /* fh is WebNFS overloaded - see makefh3_ol() */ 1071 1072 /* 1073 * Two elements were added to the 1074 * diropargs3 structure for performance (xdr-inlining). 1075 * They are not included as part of the args 1076 * that are encoded or decoded: 1077 * dirp - ptr to the nfs_fh3 1078 * flag indicating when to free the name that was 1079 * allocated during decode. 1080 */ 1081 struct diropargs3 { 1082 nfs_fh3 *dirp; 1083 nfs_fh3 dir; 1084 filename3 name; 1085 int flags; 1086 }; 1087 typedef struct diropargs3 diropargs3; 1088 1089 struct nfstime3 { 1090 uint32 seconds; 1091 uint32 nseconds; 1092 }; 1093 typedef struct nfstime3 nfstime3; 1094 1095 struct specdata3 { 1096 uint32 specdata1; 1097 uint32 specdata2; 1098 }; 1099 typedef struct specdata3 specdata3; 1100 1101 enum nfsstat3 { 1102 NFS3_OK = 0, 1103 NFS3ERR_PERM = 1, 1104 NFS3ERR_NOENT = 2, 1105 NFS3ERR_IO = 5, 1106 NFS3ERR_NXIO = 6, 1107 NFS3ERR_ACCES = 13, 1108 NFS3ERR_EXIST = 17, 1109 NFS3ERR_XDEV = 18, 1110 NFS3ERR_NODEV = 19, 1111 NFS3ERR_NOTDIR = 20, 1112 NFS3ERR_ISDIR = 21, 1113 NFS3ERR_INVAL = 22, 1114 NFS3ERR_FBIG = 27, 1115 NFS3ERR_NOSPC = 28, 1116 NFS3ERR_ROFS = 30, 1117 NFS3ERR_MLINK = 31, 1118 NFS3ERR_NAMETOOLONG = 63, 1119 NFS3ERR_NOTEMPTY = 66, 1120 NFS3ERR_DQUOT = 69, 1121 NFS3ERR_STALE = 70, 1122 NFS3ERR_REMOTE = 71, 1123 NFS3ERR_BADHANDLE = 10001, 1124 NFS3ERR_NOT_SYNC = 10002, 1125 NFS3ERR_BAD_COOKIE = 10003, 1126 NFS3ERR_NOTSUPP = 10004, 1127 NFS3ERR_TOOSMALL = 10005, 1128 NFS3ERR_SERVERFAULT = 10006, 1129 NFS3ERR_BADTYPE = 10007, 1130 NFS3ERR_JUKEBOX = 10008 1131 }; 1132 typedef enum nfsstat3 nfsstat3; 1133 1134 enum ftype3 { 1135 NF3REG = 1, 1136 NF3DIR = 2, 1137 NF3BLK = 3, 1138 NF3CHR = 4, 1139 NF3LNK = 5, 1140 NF3SOCK = 6, 1141 NF3FIFO = 7 1142 }; 1143 typedef enum ftype3 ftype3; 1144 1145 struct fattr3 { 1146 ftype3 type; 1147 mode3 mode; 1148 uint32 nlink; 1149 uid3 uid; 1150 gid3 gid; 1151 size3 size; 1152 size3 used; 1153 specdata3 rdev; 1154 uint64 fsid; 1155 fileid3 fileid; 1156 nfstime3 atime; 1157 nfstime3 mtime; 1158 nfstime3 ctime; 1159 }; 1160 typedef struct fattr3 fattr3; 1161 1162 #define NFS3_SIZEOF_FATTR3 (21) 1163 1164 #ifdef _KERNEL 1165 struct fattr3_res { 1166 nfsstat3 status; 1167 vattr_t *vap; 1168 vnode_t *vp; 1169 }; 1170 typedef struct fattr3_res fattr3_res; 1171 #endif /* _KERNEL */ 1172 1173 struct post_op_attr { 1174 bool_t attributes; 1175 fattr3 attr; 1176 }; 1177 typedef struct post_op_attr post_op_attr; 1178 1179 #ifdef _KERNEL 1180 struct post_op_vattr { 1181 bool_t attributes; 1182 fattr3_res fres; 1183 }; 1184 typedef struct post_op_vattr post_op_vattr; 1185 #endif /* _KERNEL */ 1186 1187 struct wcc_attr { 1188 size3 size; 1189 nfstime3 mtime; 1190 nfstime3 ctime; 1191 }; 1192 typedef struct wcc_attr wcc_attr; 1193 1194 struct pre_op_attr { 1195 bool_t attributes; 1196 wcc_attr attr; 1197 }; 1198 typedef struct pre_op_attr pre_op_attr; 1199 1200 struct wcc_data { 1201 pre_op_attr before; 1202 post_op_attr after; 1203 }; 1204 typedef struct wcc_data wcc_data; 1205 1206 struct post_op_fh3 { 1207 bool_t handle_follows; 1208 nfs_fh3 handle; 1209 }; 1210 typedef struct post_op_fh3 post_op_fh3; 1211 1212 enum time_how { 1213 DONT_CHANGE = 0, 1214 SET_TO_SERVER_TIME = 1, 1215 SET_TO_CLIENT_TIME = 2 1216 }; 1217 typedef enum time_how time_how; 1218 1219 struct set_mode3 { 1220 bool_t set_it; 1221 mode3 mode; 1222 }; 1223 typedef struct set_mode3 set_mode3; 1224 1225 struct set_uid3 { 1226 bool_t set_it; 1227 uid3 uid; 1228 }; 1229 typedef struct set_uid3 set_uid3; 1230 1231 struct set_gid3 { 1232 bool_t set_it; 1233 gid3 gid; 1234 }; 1235 typedef struct set_gid3 set_gid3; 1236 1237 struct set_size3 { 1238 bool_t set_it; 1239 size3 size; 1240 }; 1241 typedef struct set_size3 set_size3; 1242 1243 struct set_atime { 1244 time_how set_it; 1245 nfstime3 atime; 1246 }; 1247 typedef struct set_atime set_atime; 1248 1249 struct set_mtime { 1250 time_how set_it; 1251 nfstime3 mtime; 1252 }; 1253 typedef struct set_mtime set_mtime; 1254 1255 struct sattr3 { 1256 set_mode3 mode; 1257 set_uid3 uid; 1258 set_gid3 gid; 1259 set_size3 size; 1260 set_atime atime; 1261 set_mtime mtime; 1262 }; 1263 typedef struct sattr3 sattr3; 1264 1265 /* 1266 * A couple of defines to make resok and resfail look like the 1267 * correct things in a response type independent manner. 1268 */ 1269 #define resok res_u.ok 1270 #define resfail res_u.fail 1271 1272 struct GETATTR3args { 1273 nfs_fh3 object; 1274 }; 1275 typedef struct GETATTR3args GETATTR3args; 1276 1277 struct GETATTR3resok { 1278 fattr3 obj_attributes; 1279 }; 1280 typedef struct GETATTR3resok GETATTR3resok; 1281 1282 struct GETATTR3res { 1283 nfsstat3 status; 1284 union { 1285 GETATTR3resok ok; 1286 } res_u; 1287 }; 1288 typedef struct GETATTR3res GETATTR3res; 1289 1290 #ifdef _KERNEL 1291 struct GETATTR3vres { 1292 nfsstat3 status; 1293 fattr3_res fres; 1294 }; 1295 typedef struct GETATTR3vres GETATTR3vres; 1296 #endif /* _KERNEL */ 1297 1298 struct sattrguard3 { 1299 bool_t check; 1300 nfstime3 obj_ctime; 1301 }; 1302 typedef struct sattrguard3 sattrguard3; 1303 1304 struct SETATTR3args { 1305 nfs_fh3 object; 1306 sattr3 new_attributes; 1307 sattrguard3 guard; 1308 }; 1309 typedef struct SETATTR3args SETATTR3args; 1310 1311 struct SETATTR3resok { 1312 wcc_data obj_wcc; 1313 }; 1314 typedef struct SETATTR3resok SETATTR3resok; 1315 1316 struct SETATTR3resfail { 1317 wcc_data obj_wcc; 1318 }; 1319 typedef struct SETATTR3resfail SETATTR3resfail; 1320 1321 struct SETATTR3res { 1322 nfsstat3 status; 1323 union { 1324 SETATTR3resok ok; 1325 SETATTR3resfail fail; 1326 } res_u; 1327 }; 1328 typedef struct SETATTR3res SETATTR3res; 1329 1330 struct LOOKUP3args { 1331 diropargs3 what; 1332 }; 1333 typedef struct LOOKUP3args LOOKUP3args; 1334 1335 struct LOOKUP3resok { 1336 nfs_fh3 object; 1337 post_op_attr obj_attributes; 1338 post_op_attr dir_attributes; 1339 }; 1340 typedef struct LOOKUP3resok LOOKUP3resok; 1341 1342 struct LOOKUP3resfail { 1343 post_op_attr dir_attributes; 1344 }; 1345 typedef struct LOOKUP3resfail LOOKUP3resfail; 1346 1347 struct LOOKUP3res { 1348 nfsstat3 status; 1349 union { 1350 LOOKUP3resok ok; 1351 LOOKUP3resfail fail; 1352 } res_u; 1353 }; 1354 typedef struct LOOKUP3res LOOKUP3res; 1355 1356 #ifdef _KERNEL 1357 struct LOOKUP3vres { 1358 nfsstat3 status; 1359 nfs_fh3 object; 1360 post_op_vattr dir_attributes; 1361 post_op_vattr obj_attributes; 1362 }; 1363 typedef struct LOOKUP3vres LOOKUP3vres; 1364 #endif /* _KERNEL */ 1365 1366 struct ACCESS3args { 1367 nfs_fh3 object; 1368 uint32 access; 1369 }; 1370 typedef struct ACCESS3args ACCESS3args; 1371 #define ACCESS3_READ 0x1 1372 #define ACCESS3_LOOKUP 0x2 1373 #define ACCESS3_MODIFY 0x4 1374 #define ACCESS3_EXTEND 0x8 1375 #define ACCESS3_DELETE 0x10 1376 #define ACCESS3_EXECUTE 0x20 1377 1378 struct ACCESS3resok { 1379 post_op_attr obj_attributes; 1380 uint32 access; 1381 }; 1382 typedef struct ACCESS3resok ACCESS3resok; 1383 1384 struct ACCESS3resfail { 1385 post_op_attr obj_attributes; 1386 }; 1387 typedef struct ACCESS3resfail ACCESS3resfail; 1388 1389 struct ACCESS3res { 1390 nfsstat3 status; 1391 union { 1392 ACCESS3resok ok; 1393 ACCESS3resfail fail; 1394 } res_u; 1395 }; 1396 typedef struct ACCESS3res ACCESS3res; 1397 1398 struct READLINK3args { 1399 nfs_fh3 symlink; 1400 }; 1401 typedef struct READLINK3args READLINK3args; 1402 1403 struct READLINK3resok { 1404 post_op_attr symlink_attributes; 1405 nfspath3 data; 1406 }; 1407 typedef struct READLINK3resok READLINK3resok; 1408 1409 struct READLINK3resfail { 1410 post_op_attr symlink_attributes; 1411 }; 1412 typedef struct READLINK3resfail READLINK3resfail; 1413 1414 struct READLINK3res { 1415 nfsstat3 status; 1416 union { 1417 READLINK3resok ok; 1418 READLINK3resfail fail; 1419 } res_u; 1420 }; 1421 typedef struct READLINK3res READLINK3res; 1422 1423 struct READ3args { 1424 nfs_fh3 file; 1425 offset3 offset; 1426 count3 count; 1427 #ifdef _KERNEL 1428 /* for read using rdma */ 1429 char *res_data_val_alt; 1430 struct uio *res_uiop; 1431 struct clist *wlist; 1432 CONN *conn; 1433 #endif 1434 }; 1435 typedef struct READ3args READ3args; 1436 1437 struct READ3resok { 1438 post_op_attr file_attributes; 1439 count3 count; 1440 bool_t eof; 1441 struct { 1442 uint_t data_len; 1443 char *data_val; 1444 mblk_t *mp; 1445 } data; 1446 uint_t size; 1447 #ifdef _KERNEL 1448 uint_t wlist_len; 1449 struct clist *wlist; 1450 frtn_t zcopy; 1451 #endif 1452 }; 1453 typedef struct READ3resok READ3resok; 1454 1455 struct READ3resfail { 1456 post_op_attr file_attributes; 1457 }; 1458 typedef struct READ3resfail READ3resfail; 1459 1460 struct READ3res { 1461 nfsstat3 status; 1462 union { 1463 READ3resok ok; 1464 READ3resfail fail; 1465 } res_u; 1466 }; 1467 typedef struct READ3res READ3res; 1468 1469 #ifdef _KERNEL 1470 /* 1471 * READ3 reply that directly decodes fattr3 directly into vattr 1472 */ 1473 struct READ3vres { 1474 nfsstat3 status; 1475 struct post_op_vattr pov; 1476 count3 count; 1477 bool_t eof; 1478 struct { 1479 uint_t data_len; 1480 char *data_val; 1481 } data; 1482 uint_t size; 1483 1484 uint_t wlist_len; 1485 struct clist *wlist; 1486 }; 1487 typedef struct READ3vres READ3vres; 1488 #endif /* _KERNEL */ 1489 1490 /* 1491 * READ3 reply that uiomoves data directly into a struct uio 1492 * ignores any attributes returned 1493 */ 1494 struct READ3uiores { 1495 nfsstat3 status; 1496 count3 count; 1497 bool_t eof; 1498 struct uio *uiop; 1499 uint_t size; /* maximum reply size */ 1500 #ifdef _KERNEL 1501 uint_t wlist_len; 1502 struct clist *wlist; 1503 #endif 1504 }; 1505 typedef struct READ3uiores READ3uiores; 1506 1507 enum stable_how { 1508 UNSTABLE = 0, 1509 DATA_SYNC = 1, 1510 FILE_SYNC = 2 1511 }; 1512 typedef enum stable_how stable_how; 1513 1514 struct WRITE3args { 1515 nfs_fh3 file; 1516 offset3 offset; 1517 count3 count; 1518 stable_how stable; 1519 struct { 1520 uint_t data_len; 1521 char *data_val; 1522 } data; 1523 mblk_t *mblk; 1524 #ifdef _KERNEL 1525 struct clist *rlist; 1526 CONN *conn; 1527 #endif 1528 }; 1529 typedef struct WRITE3args WRITE3args; 1530 1531 struct WRITE3resok { 1532 wcc_data file_wcc; 1533 count3 count; 1534 stable_how committed; 1535 writeverf3 verf; 1536 }; 1537 typedef struct WRITE3resok WRITE3resok; 1538 1539 struct WRITE3resfail { 1540 wcc_data file_wcc; 1541 }; 1542 typedef struct WRITE3resfail WRITE3resfail; 1543 1544 struct WRITE3res { 1545 nfsstat3 status; 1546 union { 1547 WRITE3resok ok; 1548 WRITE3resfail fail; 1549 } res_u; 1550 }; 1551 typedef struct WRITE3res WRITE3res; 1552 1553 enum createmode3 { 1554 UNCHECKED = 0, 1555 GUARDED = 1, 1556 EXCLUSIVE = 2 1557 }; 1558 typedef enum createmode3 createmode3; 1559 1560 struct createhow3 { 1561 createmode3 mode; 1562 union { 1563 sattr3 obj_attributes; 1564 createverf3 verf; 1565 } createhow3_u; 1566 }; 1567 typedef struct createhow3 createhow3; 1568 1569 struct CREATE3args { 1570 diropargs3 where; 1571 createhow3 how; 1572 }; 1573 typedef struct CREATE3args CREATE3args; 1574 1575 struct CREATE3resok { 1576 post_op_fh3 obj; 1577 post_op_attr obj_attributes; 1578 wcc_data dir_wcc; 1579 }; 1580 typedef struct CREATE3resok CREATE3resok; 1581 1582 struct CREATE3resfail { 1583 wcc_data dir_wcc; 1584 }; 1585 typedef struct CREATE3resfail CREATE3resfail; 1586 1587 struct CREATE3res { 1588 nfsstat3 status; 1589 union { 1590 CREATE3resok ok; 1591 CREATE3resfail fail; 1592 } res_u; 1593 }; 1594 typedef struct CREATE3res CREATE3res; 1595 1596 struct MKDIR3args { 1597 diropargs3 where; 1598 sattr3 attributes; 1599 }; 1600 typedef struct MKDIR3args MKDIR3args; 1601 1602 struct MKDIR3resok { 1603 post_op_fh3 obj; 1604 post_op_attr obj_attributes; 1605 wcc_data dir_wcc; 1606 }; 1607 typedef struct MKDIR3resok MKDIR3resok; 1608 1609 struct MKDIR3resfail { 1610 wcc_data dir_wcc; 1611 }; 1612 typedef struct MKDIR3resfail MKDIR3resfail; 1613 1614 struct MKDIR3res { 1615 nfsstat3 status; 1616 union { 1617 MKDIR3resok ok; 1618 MKDIR3resfail fail; 1619 } res_u; 1620 }; 1621 typedef struct MKDIR3res MKDIR3res; 1622 1623 struct symlinkdata3 { 1624 sattr3 symlink_attributes; 1625 nfspath3 symlink_data; 1626 }; 1627 typedef struct symlinkdata3 symlinkdata3; 1628 1629 struct SYMLINK3args { 1630 diropargs3 where; 1631 symlinkdata3 symlink; 1632 }; 1633 typedef struct SYMLINK3args SYMLINK3args; 1634 1635 struct SYMLINK3resok { 1636 post_op_fh3 obj; 1637 post_op_attr obj_attributes; 1638 wcc_data dir_wcc; 1639 }; 1640 typedef struct SYMLINK3resok SYMLINK3resok; 1641 1642 struct SYMLINK3resfail { 1643 wcc_data dir_wcc; 1644 }; 1645 typedef struct SYMLINK3resfail SYMLINK3resfail; 1646 1647 struct SYMLINK3res { 1648 nfsstat3 status; 1649 union { 1650 SYMLINK3resok ok; 1651 SYMLINK3resfail fail; 1652 } res_u; 1653 }; 1654 typedef struct SYMLINK3res SYMLINK3res; 1655 1656 struct devicedata3 { 1657 sattr3 dev_attributes; 1658 specdata3 spec; 1659 }; 1660 typedef struct devicedata3 devicedata3; 1661 1662 struct mknoddata3 { 1663 ftype3 type; 1664 union { 1665 devicedata3 device; 1666 sattr3 pipe_attributes; 1667 } mknoddata3_u; 1668 }; 1669 typedef struct mknoddata3 mknoddata3; 1670 1671 struct MKNOD3args { 1672 diropargs3 where; 1673 mknoddata3 what; 1674 }; 1675 typedef struct MKNOD3args MKNOD3args; 1676 1677 struct MKNOD3resok { 1678 post_op_fh3 obj; 1679 post_op_attr obj_attributes; 1680 wcc_data dir_wcc; 1681 }; 1682 typedef struct MKNOD3resok MKNOD3resok; 1683 1684 struct MKNOD3resfail { 1685 wcc_data dir_wcc; 1686 }; 1687 typedef struct MKNOD3resfail MKNOD3resfail; 1688 1689 struct MKNOD3res { 1690 nfsstat3 status; 1691 union { 1692 MKNOD3resok ok; 1693 MKNOD3resfail fail; 1694 } res_u; 1695 }; 1696 typedef struct MKNOD3res MKNOD3res; 1697 1698 struct REMOVE3args { 1699 diropargs3 object; 1700 }; 1701 typedef struct REMOVE3args REMOVE3args; 1702 1703 struct REMOVE3resok { 1704 wcc_data dir_wcc; 1705 }; 1706 typedef struct REMOVE3resok REMOVE3resok; 1707 1708 struct REMOVE3resfail { 1709 wcc_data dir_wcc; 1710 }; 1711 typedef struct REMOVE3resfail REMOVE3resfail; 1712 1713 struct REMOVE3res { 1714 nfsstat3 status; 1715 union { 1716 REMOVE3resok ok; 1717 REMOVE3resfail fail; 1718 } res_u; 1719 }; 1720 typedef struct REMOVE3res REMOVE3res; 1721 1722 struct RMDIR3args { 1723 diropargs3 object; 1724 }; 1725 typedef struct RMDIR3args RMDIR3args; 1726 1727 struct RMDIR3resok { 1728 wcc_data dir_wcc; 1729 }; 1730 typedef struct RMDIR3resok RMDIR3resok; 1731 1732 struct RMDIR3resfail { 1733 wcc_data dir_wcc; 1734 }; 1735 typedef struct RMDIR3resfail RMDIR3resfail; 1736 1737 struct RMDIR3res { 1738 nfsstat3 status; 1739 union { 1740 RMDIR3resok ok; 1741 RMDIR3resfail fail; 1742 } res_u; 1743 }; 1744 typedef struct RMDIR3res RMDIR3res; 1745 1746 struct RENAME3args { 1747 diropargs3 from; 1748 diropargs3 to; 1749 }; 1750 typedef struct RENAME3args RENAME3args; 1751 1752 struct RENAME3resok { 1753 wcc_data fromdir_wcc; 1754 wcc_data todir_wcc; 1755 }; 1756 typedef struct RENAME3resok RENAME3resok; 1757 1758 struct RENAME3resfail { 1759 wcc_data fromdir_wcc; 1760 wcc_data todir_wcc; 1761 }; 1762 typedef struct RENAME3resfail RENAME3resfail; 1763 1764 struct RENAME3res { 1765 nfsstat3 status; 1766 union { 1767 RENAME3resok ok; 1768 RENAME3resfail fail; 1769 } res_u; 1770 }; 1771 typedef struct RENAME3res RENAME3res; 1772 1773 struct LINK3args { 1774 nfs_fh3 file; 1775 diropargs3 link; 1776 }; 1777 typedef struct LINK3args LINK3args; 1778 1779 struct LINK3resok { 1780 post_op_attr file_attributes; 1781 wcc_data linkdir_wcc; 1782 }; 1783 typedef struct LINK3resok LINK3resok; 1784 1785 struct LINK3resfail { 1786 post_op_attr file_attributes; 1787 wcc_data linkdir_wcc; 1788 }; 1789 typedef struct LINK3resfail LINK3resfail; 1790 1791 struct LINK3res { 1792 nfsstat3 status; 1793 union { 1794 LINK3resok ok; 1795 LINK3resfail fail; 1796 } res_u; 1797 }; 1798 typedef struct LINK3res LINK3res; 1799 1800 struct READDIR3args { 1801 nfs_fh3 dir; 1802 cookie3 cookie; 1803 cookieverf3 cookieverf; 1804 count3 count; 1805 }; 1806 typedef struct READDIR3args READDIR3args; 1807 1808 struct entry3 { 1809 fileid3 fileid; 1810 filename3 name; 1811 cookie3 cookie; 1812 struct entry3 *nextentry; 1813 }; 1814 typedef struct entry3 entry3; 1815 1816 struct dirlist3 { 1817 entry3 *entries; 1818 bool_t eof; 1819 }; 1820 typedef struct dirlist3 dirlist3; 1821 1822 struct READDIR3resok { 1823 post_op_attr dir_attributes; 1824 cookieverf3 cookieverf; 1825 dirlist3 reply; 1826 uint_t size; 1827 uint_t count; 1828 uint_t freecount; 1829 cookie3 cookie; 1830 }; 1831 typedef struct READDIR3resok READDIR3resok; 1832 1833 struct READDIR3resfail { 1834 post_op_attr dir_attributes; 1835 }; 1836 typedef struct READDIR3resfail READDIR3resfail; 1837 1838 struct READDIR3res { 1839 nfsstat3 status; 1840 union { 1841 READDIR3resok ok; 1842 READDIR3resfail fail; 1843 } res_u; 1844 }; 1845 typedef struct READDIR3res READDIR3res; 1846 1847 #ifdef _KERNEL 1848 struct READDIR3vres { 1849 nfsstat3 status; 1850 post_op_vattr dir_attributes; 1851 cookieverf3 cookieverf; 1852 dirent64_t *entries; /* decoded dirent64s */ 1853 uint_t size; /* actual size of entries */ 1854 uint_t entries_size; /* max size of entries */ 1855 off64_t loff; /* last offset/cookie */ 1856 bool_t eof; /* End of directory */ 1857 }; 1858 typedef struct READDIR3vres READDIR3vres; 1859 #endif /* _KERNEL */ 1860 1861 struct READDIRPLUS3args { 1862 nfs_fh3 dir; 1863 cookie3 cookie; 1864 cookieverf3 cookieverf; 1865 count3 dircount; 1866 count3 maxcount; 1867 }; 1868 typedef struct READDIRPLUS3args READDIRPLUS3args; 1869 1870 struct entryplus3 { 1871 fileid3 fileid; 1872 filename3 name; 1873 cookie3 cookie; 1874 post_op_attr name_attributes; 1875 post_op_fh3 name_handle; 1876 struct entryplus3 *nextentry; 1877 }; 1878 typedef struct entryplus3 entryplus3; 1879 1880 struct dirlistplus3 { 1881 entryplus3 *entries; 1882 bool_t eof; 1883 }; 1884 typedef struct dirlistplus3 dirlistplus3; 1885 1886 struct entryplus3_info { 1887 post_op_attr attr; 1888 post_op_fh3 fh; 1889 uint_t namelen; 1890 }; 1891 typedef struct entryplus3_info entryplus3_info; 1892 1893 struct READDIRPLUS3resok { 1894 post_op_attr dir_attributes; 1895 cookieverf3 cookieverf; 1896 dirlistplus3 reply; 1897 uint_t size; 1898 uint_t count; 1899 uint_t maxcount; 1900 entryplus3_info *infop; 1901 }; 1902 typedef struct READDIRPLUS3resok READDIRPLUS3resok; 1903 1904 struct READDIRPLUS3resfail { 1905 post_op_attr dir_attributes; 1906 }; 1907 typedef struct READDIRPLUS3resfail READDIRPLUS3resfail; 1908 1909 struct READDIRPLUS3res { 1910 nfsstat3 status; 1911 union { 1912 READDIRPLUS3resok ok; 1913 READDIRPLUS3resfail fail; 1914 } res_u; 1915 }; 1916 typedef struct READDIRPLUS3res READDIRPLUS3res; 1917 1918 #ifdef _KERNEL 1919 struct entryplus3_va_fh { 1920 int va_valid; 1921 int fh_valid; 1922 vattr_t va; 1923 nfs_fh3 fh; 1924 char *d_name; /* back pointer into entries */ 1925 }; 1926 1927 struct READDIRPLUS3vres { 1928 nfsstat3 status; 1929 post_op_vattr dir_attributes; 1930 cookieverf3 cookieverf; 1931 dirent64_t *entries; /* decoded dirent64s */ 1932 uint_t size; /* actual size of entries */ 1933 uint_t entries_size; /* max size of entries */ 1934 bool_t eof; /* End of directory */ 1935 off64_t loff; /* last offset/cookie */ 1936 cred_t *credentials; /* caller's credentials */ 1937 hrtime_t time; /* time of READDIRPLUS call */ 1938 }; 1939 typedef struct READDIRPLUS3vres READDIRPLUS3vres; 1940 #endif /* _KERNEL */ 1941 1942 struct FSSTAT3args { 1943 nfs_fh3 fsroot; 1944 }; 1945 typedef struct FSSTAT3args FSSTAT3args; 1946 1947 struct FSSTAT3resok { 1948 post_op_attr obj_attributes; 1949 size3 tbytes; 1950 size3 fbytes; 1951 size3 abytes; 1952 size3 tfiles; 1953 size3 ffiles; 1954 size3 afiles; 1955 uint32 invarsec; 1956 }; 1957 typedef struct FSSTAT3resok FSSTAT3resok; 1958 1959 struct FSSTAT3resfail { 1960 post_op_attr obj_attributes; 1961 }; 1962 typedef struct FSSTAT3resfail FSSTAT3resfail; 1963 1964 struct FSSTAT3res { 1965 nfsstat3 status; 1966 union { 1967 FSSTAT3resok ok; 1968 FSSTAT3resfail fail; 1969 } res_u; 1970 }; 1971 typedef struct FSSTAT3res FSSTAT3res; 1972 1973 struct FSINFO3args { 1974 nfs_fh3 fsroot; 1975 }; 1976 typedef struct FSINFO3args FSINFO3args; 1977 1978 struct FSINFO3resok { 1979 post_op_attr obj_attributes; 1980 uint32 rtmax; 1981 uint32 rtpref; 1982 uint32 rtmult; 1983 uint32 wtmax; 1984 uint32 wtpref; 1985 uint32 wtmult; 1986 uint32 dtpref; 1987 size3 maxfilesize; 1988 nfstime3 time_delta; 1989 uint32 properties; 1990 }; 1991 typedef struct FSINFO3resok FSINFO3resok; 1992 1993 struct FSINFO3resfail { 1994 post_op_attr obj_attributes; 1995 }; 1996 typedef struct FSINFO3resfail FSINFO3resfail; 1997 #define FSF3_LINK 0x1 1998 #define FSF3_SYMLINK 0x2 1999 #define FSF3_HOMOGENEOUS 0x8 2000 #define FSF3_CANSETTIME 0x10 2001 2002 struct FSINFO3res { 2003 nfsstat3 status; 2004 union { 2005 FSINFO3resok ok; 2006 FSINFO3resfail fail; 2007 } res_u; 2008 }; 2009 typedef struct FSINFO3res FSINFO3res; 2010 2011 struct PATHCONF3args { 2012 nfs_fh3 object; 2013 }; 2014 typedef struct PATHCONF3args PATHCONF3args; 2015 2016 struct nfs3_pathconf_info { 2017 uint32 link_max; 2018 uint32 name_max; 2019 bool_t no_trunc; 2020 bool_t chown_restricted; 2021 bool_t case_insensitive; 2022 bool_t case_preserving; 2023 }; 2024 typedef struct nfs3_pathconf_info nfs3_pathconf_info; 2025 2026 struct PATHCONF3resok { 2027 post_op_attr obj_attributes; 2028 nfs3_pathconf_info info; 2029 }; 2030 typedef struct PATHCONF3resok PATHCONF3resok; 2031 2032 struct PATHCONF3resfail { 2033 post_op_attr obj_attributes; 2034 }; 2035 typedef struct PATHCONF3resfail PATHCONF3resfail; 2036 2037 struct PATHCONF3res { 2038 nfsstat3 status; 2039 union { 2040 PATHCONF3resok ok; 2041 PATHCONF3resfail fail; 2042 } res_u; 2043 }; 2044 typedef struct PATHCONF3res PATHCONF3res; 2045 2046 struct COMMIT3args { 2047 nfs_fh3 file; 2048 offset3 offset; 2049 count3 count; 2050 }; 2051 typedef struct COMMIT3args COMMIT3args; 2052 2053 struct COMMIT3resok { 2054 wcc_data file_wcc; 2055 writeverf3 verf; 2056 }; 2057 typedef struct COMMIT3resok COMMIT3resok; 2058 2059 struct COMMIT3resfail { 2060 wcc_data file_wcc; 2061 }; 2062 typedef struct COMMIT3resfail COMMIT3resfail; 2063 2064 struct COMMIT3res { 2065 nfsstat3 status; 2066 union { 2067 COMMIT3resok ok; 2068 COMMIT3resfail fail; 2069 } res_u; 2070 }; 2071 typedef struct COMMIT3res COMMIT3res; 2072 2073 #define NFS3_PROGRAM ((rpcprog_t)100003) 2074 #define NFS_V3 ((rpcvers_t)3) 2075 #define NFSPROC3_NULL ((rpcproc_t)0) 2076 #define NFSPROC3_GETATTR ((rpcproc_t)1) 2077 #define NFSPROC3_SETATTR ((rpcproc_t)2) 2078 #define NFSPROC3_LOOKUP ((rpcproc_t)3) 2079 #define NFSPROC3_ACCESS ((rpcproc_t)4) 2080 #define NFSPROC3_READLINK ((rpcproc_t)5) 2081 #define NFSPROC3_READ ((rpcproc_t)6) 2082 #define NFSPROC3_WRITE ((rpcproc_t)7) 2083 #define NFSPROC3_CREATE ((rpcproc_t)8) 2084 #define NFSPROC3_MKDIR ((rpcproc_t)9) 2085 #define NFSPROC3_SYMLINK ((rpcproc_t)10) 2086 #define NFSPROC3_MKNOD ((rpcproc_t)11) 2087 #define NFSPROC3_REMOVE ((rpcproc_t)12) 2088 #define NFSPROC3_RMDIR ((rpcproc_t)13) 2089 #define NFSPROC3_RENAME ((rpcproc_t)14) 2090 #define NFSPROC3_LINK ((rpcproc_t)15) 2091 #define NFSPROC3_READDIR ((rpcproc_t)16) 2092 #define NFSPROC3_READDIRPLUS ((rpcproc_t)17) 2093 #define NFSPROC3_FSSTAT ((rpcproc_t)18) 2094 #define NFSPROC3_FSINFO ((rpcproc_t)19) 2095 #define NFSPROC3_PATHCONF ((rpcproc_t)20) 2096 #define NFSPROC3_COMMIT ((rpcproc_t)21) 2097 2098 #ifndef _KERNEL 2099 extern void * nfsproc3_null_3(); 2100 extern GETATTR3res * nfsproc3_getattr_3(); 2101 extern SETATTR3res * nfsproc3_setattr_3(); 2102 extern LOOKUP3res * nfsproc3_lookup_3(); 2103 extern ACCESS3res * nfsproc3_access_3(); 2104 extern READLINK3res * nfsproc3_readlink_3(); 2105 extern READ3res * nfsproc3_read_3(); 2106 extern WRITE3res * nfsproc3_write_3(); 2107 extern CREATE3res * nfsproc3_create_3(); 2108 extern MKDIR3res * nfsproc3_mkdir_3(); 2109 extern SYMLINK3res * nfsproc3_symlink_3(); 2110 extern MKNOD3res * nfsproc3_mknod_3(); 2111 extern REMOVE3res * nfsproc3_remove_3(); 2112 extern RMDIR3res * nfsproc3_rmdir_3(); 2113 extern RENAME3res * nfsproc3_rename_3(); 2114 extern LINK3res * nfsproc3_link_3(); 2115 extern READDIR3res * nfsproc3_readdir_3(); 2116 extern READDIRPLUS3res * nfsproc3_readdirplus_3(); 2117 extern FSSTAT3res * nfsproc3_fsstat_3(); 2118 extern FSINFO3res * nfsproc3_fsinfo_3(); 2119 extern PATHCONF3res * nfsproc3_pathconf_3(); 2120 extern COMMIT3res * nfsproc3_commit_3(); 2121 #endif /* !_KERNEL */ 2122 2123 #ifdef _KERNEL 2124 /* the NFS Version 3 XDR functions */ 2125 2126 extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3 *); 2127 extern bool_t xdr_nfslog_nfs_fh3(XDR *, nfs_fh3 *); 2128 extern bool_t xdr_nfs_fh3_server(XDR *, nfs_fh3 *); 2129 extern bool_t xdr_diropargs3(XDR *, diropargs3 *); 2130 extern bool_t xdr_post_op_attr(XDR *, post_op_attr *); 2131 extern bool_t xdr_post_op_fh3(XDR *, post_op_fh3 *); 2132 extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res *); 2133 extern bool_t xdr_GETATTR3vres(XDR *, GETATTR3vres *); 2134 extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args *); 2135 extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res *); 2136 extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res *); 2137 extern bool_t xdr_LOOKUP3vres(XDR *, LOOKUP3vres *); 2138 extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args *); 2139 extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res *); 2140 extern bool_t xdr_READLINK3args(XDR *, READLINK3args *); 2141 extern bool_t xdr_READLINK3res(XDR *, READLINK3res *); 2142 extern bool_t xdr_READ3args(XDR *, READ3args *); 2143 extern bool_t xdr_READ3res(XDR *, READ3res *); 2144 extern bool_t xdr_READ3vres(XDR *, READ3vres *); 2145 extern bool_t xdr_READ3uiores(XDR *, READ3uiores *); 2146 extern bool_t xdr_WRITE3args(XDR *, WRITE3args *); 2147 extern bool_t xdr_WRITE3res(XDR *, WRITE3res *); 2148 extern bool_t xdr_CREATE3args(XDR *, CREATE3args *); 2149 extern bool_t xdr_CREATE3res(XDR *, CREATE3res *); 2150 extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args *); 2151 extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res *); 2152 extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args *); 2153 extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res *); 2154 extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args *); 2155 extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res *); 2156 extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res *); 2157 extern bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail *); 2158 extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res *); 2159 extern bool_t xdr_RENAME3args(XDR *, RENAME3args *); 2160 extern bool_t xdr_RENAME3res(XDR *, RENAME3res *); 2161 extern bool_t xdr_LINK3args(XDR *, LINK3args *); 2162 extern bool_t xdr_LINK3res(XDR *, LINK3res *); 2163 extern bool_t xdr_READDIR3args(XDR *, READDIR3args *); 2164 extern bool_t xdr_READDIR3res(XDR *, READDIR3res *); 2165 extern bool_t xdr_READDIR3vres(XDR *, READDIR3vres *); 2166 extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args *); 2167 extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res *); 2168 extern bool_t xdr_READDIRPLUS3vres(XDR *, READDIRPLUS3vres *); 2169 extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res *); 2170 extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res *); 2171 extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res *); 2172 extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args *); 2173 extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res *); 2174 extern bool_t xdr_fastnfs_fh3(XDR *, nfs_fh3 **); 2175 2176 /* 2177 * The NFS Version 3 service procedures. 2178 */ 2179 struct exportinfo; /* defined in nfs/export.h */ 2180 struct servinfo; /* defined in nfs/nfs_clnt.h */ 2181 struct mntinfo; /* defined in nfs/nfs_clnt.h */ 2182 struct sec_ol; /* defined in nfs/export.h */ 2183 2184 extern void rfs3_getattr(GETATTR3args *, GETATTR3res *, 2185 struct exportinfo *, struct svc_req *, cred_t *); 2186 extern void *rfs3_getattr_getfh(GETATTR3args *); 2187 extern void rfs3_setattr(SETATTR3args *, SETATTR3res *, 2188 struct exportinfo *, struct svc_req *, cred_t *); 2189 extern void *rfs3_setattr_getfh(SETATTR3args *); 2190 extern void rfs3_lookup(LOOKUP3args *, LOOKUP3res *, 2191 struct exportinfo *, struct svc_req *, cred_t *); 2192 extern void *rfs3_lookup_getfh(LOOKUP3args *); 2193 extern void rfs3_access(ACCESS3args *, ACCESS3res *, 2194 struct exportinfo *, struct svc_req *, cred_t *); 2195 extern void *rfs3_access_getfh(ACCESS3args *); 2196 extern void rfs3_readlink(READLINK3args *, READLINK3res *, 2197 struct exportinfo *, struct svc_req *, cred_t *); 2198 extern void *rfs3_readlink_getfh(READLINK3args *); 2199 extern void rfs3_readlink_free(READLINK3res *); 2200 extern void rfs3_read(READ3args *, READ3res *, 2201 struct exportinfo *, struct svc_req *, cred_t *); 2202 extern void *rfs3_read_getfh(READ3args *); 2203 extern void rfs3_read_free(READ3res *); 2204 extern void rfs3_write(WRITE3args *, WRITE3res *, 2205 struct exportinfo *, struct svc_req *, cred_t *); 2206 extern void *rfs3_write_getfh(WRITE3args *); 2207 extern void rfs3_create(CREATE3args *, CREATE3res *, 2208 struct exportinfo *, struct svc_req *, cred_t *); 2209 extern void *rfs3_create_getfh(CREATE3args *); 2210 extern void rfs3_mkdir(MKDIR3args *, MKDIR3res *, 2211 struct exportinfo *, struct svc_req *, cred_t *); 2212 extern void *rfs3_mkdir_getfh(MKDIR3args *); 2213 extern void rfs3_symlink(SYMLINK3args *, SYMLINK3res *, 2214 struct exportinfo *, struct svc_req *, cred_t *); 2215 extern void *rfs3_symlink_getfh(SYMLINK3args *); 2216 extern void rfs3_mknod(MKNOD3args *, MKNOD3res *, 2217 struct exportinfo *, struct svc_req *, cred_t *); 2218 extern void *rfs3_mknod_getfh(MKNOD3args *); 2219 extern void rfs3_remove(REMOVE3args *, REMOVE3res *, 2220 struct exportinfo *, struct svc_req *, cred_t *); 2221 extern void *rfs3_remove_getfh(REMOVE3args *); 2222 extern void rfs3_rmdir(RMDIR3args *, RMDIR3res *, 2223 struct exportinfo *, struct svc_req *, cred_t *); 2224 extern void *rfs3_rmdir_getfh(RMDIR3args *); 2225 extern void rfs3_rename(RENAME3args *, RENAME3res *, 2226 struct exportinfo *, struct svc_req *, cred_t *); 2227 extern void *rfs3_rename_getfh(RENAME3args *); 2228 extern void rfs3_link(LINK3args *, LINK3res *, 2229 struct exportinfo *, struct svc_req *, cred_t *); 2230 extern void *rfs3_link_getfh(LINK3args *); 2231 extern void rfs3_readdir(READDIR3args *, READDIR3res *, 2232 struct exportinfo *, struct svc_req *, cred_t *); 2233 extern void *rfs3_readdir_getfh(READDIR3args *); 2234 extern void rfs3_readdir_free(READDIR3res *); 2235 extern void rfs3_readdirplus(READDIRPLUS3args *, READDIRPLUS3res *, 2236 struct exportinfo *, struct svc_req *, cred_t *); 2237 extern void *rfs3_readdirplus_getfh(READDIRPLUS3args *); 2238 extern void rfs3_readdirplus_free(READDIRPLUS3res *); 2239 extern void rfs3_fsstat(FSSTAT3args *, FSSTAT3res *, 2240 struct exportinfo *, struct svc_req *, cred_t *); 2241 extern void *rfs3_fsstat_getfh(FSSTAT3args *); 2242 extern void rfs3_fsinfo(FSINFO3args *, FSINFO3res *, 2243 struct exportinfo *, struct svc_req *, cred_t *); 2244 extern void *rfs3_fsinfo_getfh(FSINFO3args *); 2245 extern void rfs3_pathconf(PATHCONF3args *, PATHCONF3res *, 2246 struct exportinfo *, struct svc_req *, cred_t *); 2247 extern void *rfs3_pathconf_getfh(PATHCONF3args *); 2248 extern void rfs3_commit(COMMIT3args *, COMMIT3res *, 2249 struct exportinfo *, struct svc_req *, cred_t *); 2250 extern void *rfs3_commit_getfh(COMMIT3args *); 2251 extern void rfs3_srvrinit(void); 2252 extern void rfs3_srvrfini(void); 2253 2254 extern int nfs3_validate_caches(vnode_t *, cred_t *); 2255 extern void nfs3_cache_post_op_attr(vnode_t *, post_op_attr *, hrtime_t, 2256 cred_t *); 2257 extern void nfs3_cache_post_op_vattr(vnode_t *, post_op_vattr *, hrtime_t, 2258 cred_t *); 2259 extern void nfs3_cache_wcc_data(vnode_t *, wcc_data *, hrtime_t, cred_t *); 2260 extern void nfs3_attrcache(vnode_t *, fattr3 *, hrtime_t); 2261 extern int nfs3_cache_fattr3(vnode_t *, fattr3 *, vattr_t *, hrtime_t, 2262 cred_t *); 2263 extern int nfs3_getattr_otw(vnode_t *, struct vattr *, cred_t *); 2264 extern int nfs3getattr(vnode_t *, struct vattr *, cred_t *); 2265 extern int fattr3_to_vattr(vnode_t *, fattr3 *, struct vattr *); 2266 extern int nfs3tsize(void); 2267 extern uint_t nfs3_tsize(struct knetconfig *); 2268 extern uint_t rfs3_tsize(struct svc_req *); 2269 extern int vattr_to_sattr3(struct vattr *, sattr3 *); 2270 extern void setdiropargs3(diropargs3 *, char *, vnode_t *); 2271 extern enum nfsstat3 puterrno3(int); 2272 extern int geterrno3(enum nfsstat3); 2273 extern int nfs3init(int, char *); 2274 extern void nfs3fini(void); 2275 extern int nfs3_vfsinit(void); 2276 extern void nfs3_vfsfini(void); 2277 extern void vattr_to_post_op_attr(struct vattr *, post_op_attr *); 2278 extern void mblk_to_iov(mblk_t *, int, struct iovec *); 2279 extern int rfs_publicfh_mclookup(char *, vnode_t *, cred_t *, 2280 vnode_t **, struct exportinfo **, struct sec_ol *); 2281 extern int rfs_pathname(char *, vnode_t **, vnode_t **, 2282 vnode_t *, cred_t *, int); 2283 extern vtype_t nf3_to_vt[]; 2284 extern kstat_named_t *rfsproccnt_v3_ptr; 2285 extern vfsops_t *nfs3_vfsops; 2286 extern struct vnodeops *nfs3_vnodeops; 2287 extern const struct fs_operation_def nfs3_vnodeops_template[]; 2288 #ifdef DEBUG 2289 extern int rfs3_do_pre_op_attr; 2290 extern int rfs3_do_post_op_attr; 2291 extern int rfs3_do_post_op_fh3; 2292 #endif 2293 /* 2294 * Some servers do not properly update the attributes of the 2295 * directory when changes are made. To allow interoperability 2296 * with these broken servers, the nfs_disable_rddir_cache 2297 * parameter can be used to disable readdir response caching. 2298 */ 2299 extern int nfs_disable_rddir_cache; 2300 2301 /* 2302 * External functions called by the v2/v3 code into the v4 code 2303 */ 2304 extern void nfs4_clnt_init(void); 2305 extern void nfs4_clnt_fini(void); 2306 2307 /* 2308 * Does NFS4 server have a vnode delegated? TRUE if so, FALSE if not. 2309 */ 2310 extern bool_t rfs4_check_delegated(int mode, vnode_t *, bool_t trunc); 2311 /* 2312 * VOP_GETATTR call. If a NFS4 delegation is present on the supplied vnode 2313 * call back to the delegated client to get attributes for AT_MTIME and 2314 * AT_SIZE. Invoke VOP_GETATTR to get all other attributes or all attributes 2315 * if no delegation is present. 2316 */ 2317 extern int rfs4_delegated_getattr(vnode_t *, vattr_t *, int, cred_t *); 2318 extern void rfs4_hold_deleg_policy(void); 2319 extern void rfs4_rele_deleg_policy(void); 2320 2321 extern int do_xattr_exists_check(vnode_t *, ulong_t *, cred_t *); 2322 2323 extern ts_label_t *nfs_getflabel(vnode_t *, struct exportinfo *); 2324 extern boolean_t do_rfs_label_check(bslabel_t *, vnode_t *, int, 2325 struct exportinfo *); 2326 2327 /* 2328 * Copy Reduction support. 2329 * xuio_t wrapper with additional private data. 2330 */ 2331 2332 typedef struct nfs_xuio { 2333 xuio_t nu_uio; 2334 vnode_t *nu_vp; 2335 uint_t nu_ref; 2336 frtn_t nu_frtn; 2337 } nfs_xuio_t; 2338 2339 xuio_t *rfs_setup_xuio(vnode_t *); 2340 mblk_t *uio_to_mblk(uio_t *); 2341 void rfs_rndup_mblks(mblk_t *, uint_t, int); 2342 void rfs_free_xuio(void *); 2343 2344 #endif /* _KERNEL */ 2345 2346 #ifdef __cplusplus 2347 } 2348 #endif 2349 2350 #endif /* _NFS_NFS_H */ 2351