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 2008 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 #pragma ident "%Z%%M% %I% %E% SMI" 33 /* nfs.h 2.38 88/08/19 SMI */ 34 35 #include <sys/isa_defs.h> 36 #include <sys/vfs.h> 37 #include <sys/stream.h> 38 #include <rpc/types.h> 39 #include <sys/types32.h> 40 #ifdef _KERNEL 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 #endif 50 #include <vm/page.h> 51 #include <rpc/rpc_sztypes.h> 52 #include <sys/sysmacros.h> 53 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 }; 474 #define wa_fhandle wa_args->otw_wa_fhandle 475 #define wa_begoff wa_args->otw_wa_begoff 476 #define wa_offset wa_args->otw_wa_offset 477 #define wa_totcount wa_args->otw_wa_totcount 478 479 /* 480 * NFS timeval struct using unsigned int as specified in V2 protocol. 481 * tv_sec and tv_usec used to match existing code. 482 */ 483 struct nfs2_timeval { 484 uint32_t tv_sec; 485 uint32_t tv_usec; 486 }; 487 typedef struct nfs2_timeval nfs2_timeval; 488 489 /* 490 * File attributes 491 */ 492 struct nfsfattr { 493 enum nfsftype na_type; /* file type */ 494 uint32_t na_mode; /* protection mode bits */ 495 uint32_t na_nlink; /* # hard links */ 496 uint32_t na_uid; /* owner user id */ 497 uint32_t na_gid; /* owner group id */ 498 uint32_t na_size; /* file size in bytes */ 499 uint32_t na_blocksize; /* preferred block size */ 500 uint32_t na_rdev; /* special device # */ 501 uint32_t na_blocks; /* Kb of disk used by file */ 502 uint32_t na_fsid; /* device # */ 503 uint32_t na_nodeid; /* inode # */ 504 struct nfs2_timeval na_atime; /* time of last access */ 505 struct nfs2_timeval na_mtime; /* time of last modification */ 506 struct nfs2_timeval na_ctime; /* time of last change */ 507 }; 508 509 #define n2v_type(x) (NA_ISFIFO(x) ? VFIFO : nf_to_vt[(x)->na_type]) 510 #define n2v_rdev(x) (NA_ISFIFO(x) ? 0 : (x)->na_rdev) 511 512 /* 513 * Arguments to remote read 514 */ 515 struct nfsreadargs { 516 fhandle_t ra_fhandle; /* handle for file */ 517 uint32_t ra_offset; /* byte offset in file */ 518 uint32_t ra_count; /* immediate read count */ 519 uint32_t ra_totcount; /* total read cnt (from this offset) */ 520 }; 521 522 /* 523 * Status OK portion of remote read reply 524 */ 525 struct nfsrrok { 526 struct nfsfattr rrok_attr; /* attributes, need for pagin */ 527 uint32_t rrok_count; /* bytes of data */ 528 char *rrok_data; /* data (up to NFS_MAXDATA bytes) */ 529 uint_t rrok_bufsize; /* size of kmem_alloc'd buffer */ 530 mblk_t *rrok_mp; /* mblk_t contains data for reply */ 531 }; 532 533 /* 534 * Reply from remote read 535 */ 536 struct nfsrdresult { 537 nfsstat rr_status; /* status of read */ 538 union { 539 struct nfsrrok rr_ok_u; /* attributes, need for pagin */ 540 } rr_u; 541 }; 542 #define rr_ok rr_u.rr_ok_u 543 #define rr_attr rr_u.rr_ok_u.rrok_attr 544 #define rr_count rr_u.rr_ok_u.rrok_count 545 #define rr_bufsize rr_u.rr_ok_u.rrok_bufsize 546 #define rr_data rr_u.rr_ok_u.rrok_data 547 #define rr_mp rr_u.rr_ok_u.rrok_mp 548 549 /* 550 * File attributes which can be set 551 */ 552 struct nfssattr { 553 uint32_t sa_mode; /* protection mode bits */ 554 uint32_t sa_uid; /* owner user id */ 555 uint32_t sa_gid; /* owner group id */ 556 uint32_t sa_size; /* file size in bytes */ 557 struct nfs2_timeval sa_atime; /* time of last access */ 558 struct nfs2_timeval sa_mtime; /* time of last modification */ 559 }; 560 561 562 /* 563 * Reply status with file attributes 564 */ 565 struct nfsattrstat { 566 nfsstat ns_status; /* reply status */ 567 union { 568 struct nfsfattr ns_attr_u; /* NFS_OK: file attributes */ 569 } ns_u; 570 }; 571 #define ns_attr ns_u.ns_attr_u 572 573 574 /* 575 * NFS_OK part of read sym link reply union 576 */ 577 struct nfssrok { 578 uint32_t srok_count; /* size of string */ 579 char *srok_data; /* string (up to NFS_MAXPATHLEN bytes) */ 580 }; 581 582 /* 583 * Result of reading symbolic link 584 */ 585 struct nfsrdlnres { 586 nfsstat rl_status; /* status of symlink read */ 587 union { 588 struct nfssrok rl_srok_u; /* name of linked to */ 589 } rl_u; 590 }; 591 #define rl_srok rl_u.rl_srok_u 592 #define rl_count rl_u.rl_srok_u.srok_count 593 #define rl_data rl_u.rl_srok_u.srok_data 594 595 596 /* 597 * Arguments to readdir 598 */ 599 struct nfsrddirargs { 600 fhandle_t rda_fh; /* directory handle */ 601 uint32_t rda_offset; /* offset in directory (opaque) */ 602 uint32_t rda_count; /* number of directory bytes to read */ 603 }; 604 605 /* 606 * NFS_OK part of readdir result 607 */ 608 struct nfsrdok { 609 uint32_t rdok_offset; /* next offset (opaque) */ 610 uint32_t rdok_size; /* size in bytes of entries */ 611 bool_t rdok_eof; /* true if last entry is in result */ 612 struct dirent64 *rdok_entries; /* variable number of entries */ 613 }; 614 615 /* 616 * Readdir result 617 */ 618 struct nfsrddirres { 619 nfsstat rd_status; 620 uint_t rd_bufsize; /* client request size (not xdr'ed) */ 621 union { 622 struct nfsrdok rd_rdok_u; 623 } rd_u; 624 }; 625 #define rd_rdok rd_u.rd_rdok_u 626 #define rd_offset rd_u.rd_rdok_u.rdok_offset 627 #define rd_size rd_u.rd_rdok_u.rdok_size 628 #define rd_eof rd_u.rd_rdok_u.rdok_eof 629 #define rd_entries rd_u.rd_rdok_u.rdok_entries 630 631 632 /* 633 * Arguments for directory operations 634 */ 635 struct nfsdiropargs { 636 fhandle_t *da_fhandle; /* pointer to directory file handle */ 637 char *da_name; /* name (up to NFS_MAXNAMLEN bytes) */ 638 fhandle_t da_fhandle_buf; /* directory file handle */ 639 int da_flags; /* flags, see below */ 640 }; 641 #define DA_FREENAME 1 642 643 /* 644 * NFS_OK part of directory operation result 645 */ 646 struct nfsdrok { 647 fhandle_t drok_fhandle; /* result file handle */ 648 struct nfsfattr drok_attr; /* result file attributes */ 649 }; 650 651 /* 652 * Results from directory operation 653 */ 654 struct nfsdiropres { 655 nfsstat dr_status; /* result status */ 656 union { 657 struct nfsdrok dr_drok_u; /* NFS_OK result */ 658 } dr_u; 659 }; 660 #define dr_drok dr_u.dr_drok_u 661 #define dr_fhandle dr_u.dr_drok_u.drok_fhandle 662 #define dr_attr dr_u.dr_drok_u.drok_attr 663 664 /* 665 * arguments to setattr 666 */ 667 struct nfssaargs { 668 fhandle_t saa_fh; /* fhandle of file to be set */ 669 struct nfssattr saa_sa; /* new attributes */ 670 }; 671 672 /* 673 * arguments to create and mkdir 674 */ 675 struct nfscreatargs { 676 struct nfsdiropargs ca_da; /* file name to create and parent dir */ 677 struct nfssattr *ca_sa; /* initial attributes */ 678 struct nfssattr ca_sa_buf; /* space to store attributes */ 679 }; 680 681 /* 682 * arguments to link 683 */ 684 struct nfslinkargs { 685 fhandle_t *la_from; /* old file */ 686 fhandle_t la_from_buf; /* old file */ 687 struct nfsdiropargs la_to; /* new file and parent dir */ 688 }; 689 690 /* 691 * arguments to rename 692 */ 693 struct nfsrnmargs { 694 struct nfsdiropargs rna_from; /* old file and parent dir */ 695 struct nfsdiropargs rna_to; /* new file and parent dir */ 696 }; 697 698 /* 699 * arguments to symlink 700 */ 701 struct nfsslargs { 702 struct nfsdiropargs sla_from; /* old file and parent dir */ 703 char *sla_tnm; /* new name */ 704 int sla_tnm_flags; /* flags for name */ 705 struct nfssattr *sla_sa; /* attributes */ 706 struct nfssattr sla_sa_buf; /* attributes buffer */ 707 }; 708 #define SLA_FREETNM 1 709 710 /* 711 * NFS_OK part of statfs operation 712 */ 713 struct nfsstatfsok { 714 uint32_t fsok_tsize; /* preferred transfer size in bytes */ 715 uint32_t fsok_bsize; /* fundamental file system block size */ 716 uint32_t fsok_blocks; /* total blocks in file system */ 717 uint32_t fsok_bfree; /* free blocks in fs */ 718 uint32_t fsok_bavail; /* free blocks avail to non-superuser */ 719 }; 720 721 /* 722 * Results of statfs operation 723 */ 724 struct nfsstatfs { 725 nfsstat fs_status; /* result status */ 726 union { 727 struct nfsstatfsok fs_fsok_u; /* NFS_OK result */ 728 } fs_u; 729 }; 730 #define fs_fsok fs_u.fs_fsok_u 731 #define fs_tsize fs_u.fs_fsok_u.fsok_tsize 732 #define fs_bsize fs_u.fs_fsok_u.fsok_bsize 733 #define fs_blocks fs_u.fs_fsok_u.fsok_blocks 734 #define fs_bfree fs_u.fs_fsok_u.fsok_bfree 735 #define fs_bavail fs_u.fs_fsok_u.fsok_bavail 736 737 #ifdef _KERNEL 738 /* 739 * XDR routines for handling structures defined above 740 */ 741 extern bool_t xdr_attrstat(XDR *, struct nfsattrstat *); 742 extern bool_t xdr_fastattrstat(XDR *, struct nfsattrstat *); 743 extern bool_t xdr_creatargs(XDR *, struct nfscreatargs *); 744 extern bool_t xdr_diropargs(XDR *, struct nfsdiropargs *); 745 extern bool_t xdr_diropres(XDR *, struct nfsdiropres *); 746 extern bool_t xdr_fastdiropres(XDR *, struct nfsdiropres *); 747 extern bool_t xdr_drok(XDR *, struct nfsdrok *); 748 #ifdef _LITTLE_ENDIAN 749 extern bool_t xdr_fastdrok(XDR *, struct nfsdrok *); 750 extern bool_t xdr_fastfattr(XDR *, struct nfsfattr *); 751 #endif 752 extern bool_t xdr_fattr(XDR *, struct nfsfattr *); 753 extern bool_t xdr_fhandle(XDR *, fhandle_t *); 754 extern bool_t xdr_fastfhandle(XDR *, fhandle_t **); 755 extern bool_t xdr_linkargs(XDR *, struct nfslinkargs *); 756 extern bool_t xdr_rddirargs(XDR *, struct nfsrddirargs *); 757 extern bool_t xdr_putrddirres(XDR *, struct nfsrddirres *); 758 extern bool_t xdr_getrddirres(XDR *, struct nfsrddirres *); 759 extern bool_t xdr_rdlnres(XDR *, struct nfsrdlnres *); 760 extern bool_t xdr_rdresult(XDR *, struct nfsrdresult *); 761 extern bool_t xdr_readargs(XDR *, struct nfsreadargs *); 762 extern bool_t xdr_rnmargs(XDR *, struct nfsrnmargs *); 763 extern bool_t xdr_rrok(XDR *, struct nfsrrok *); 764 extern bool_t xdr_saargs(XDR *, struct nfssaargs *); 765 extern bool_t xdr_sattr(XDR *, struct nfssattr *); 766 extern bool_t xdr_slargs(XDR *, struct nfsslargs *); 767 extern bool_t xdr_srok(XDR *, struct nfssrok *); 768 extern bool_t xdr_nfs2_timeval(XDR *, struct nfs2_timeval *); 769 extern bool_t xdr_writeargs(XDR *, struct nfswriteargs *); 770 extern bool_t xdr_fsok(XDR *, struct nfsstatfsok *); 771 #ifdef _LITTLE_ENDIAN 772 extern bool_t xdr_fastfsok(XDR *, struct nfsstatfsok *); 773 extern bool_t xdr_fastenum(XDR *, enum_t *); 774 #endif 775 extern bool_t xdr_statfs(XDR *, struct nfsstatfs *); 776 extern bool_t xdr_faststatfs(XDR *, struct nfsstatfs *); 777 #endif 778 779 /* 780 * Remote file service routines 781 */ 782 #define RFS_NULL 0 783 #define RFS_GETATTR 1 784 #define RFS_SETATTR 2 785 #define RFS_ROOT 3 786 #define RFS_LOOKUP 4 787 #define RFS_READLINK 5 788 #define RFS_READ 6 789 #define RFS_WRITECACHE 7 790 #define RFS_WRITE 8 791 #define RFS_CREATE 9 792 #define RFS_REMOVE 10 793 #define RFS_RENAME 11 794 #define RFS_LINK 12 795 #define RFS_SYMLINK 13 796 #define RFS_MKDIR 14 797 #define RFS_RMDIR 15 798 #define RFS_READDIR 16 799 #define RFS_STATFS 17 800 #define RFS_NPROC 18 801 802 #ifdef _KERNEL 803 /* 804 * The NFS Version 2 service procedures 805 */ 806 struct exportinfo; /* defined in nfs/export.h */ 807 struct servinfo; /* defined in nfs/nfs_clnt.h */ 808 struct mntinfo; /* defined in nfs/nfs_clnt.h */ 809 810 extern void rfs_getattr(fhandle_t *, struct nfsattrstat *, 811 struct exportinfo *, struct svc_req *, cred_t *); 812 extern void *rfs_getattr_getfh(fhandle_t *); 813 extern void rfs_setattr(struct nfssaargs *, struct nfsattrstat *, 814 struct exportinfo *, struct svc_req *, cred_t *); 815 extern void *rfs_setattr_getfh(struct nfssaargs *); 816 extern void rfs_lookup(struct nfsdiropargs *, struct nfsdiropres *, 817 struct exportinfo *, struct svc_req *, cred_t *); 818 extern void *rfs_lookup_getfh(struct nfsdiropargs *); 819 extern void rfs_readlink(fhandle_t *, struct nfsrdlnres *, 820 struct exportinfo *, struct svc_req *, cred_t *); 821 extern void *rfs_readlink_getfh(fhandle_t *); 822 extern void rfs_rlfree(struct nfsrdlnres *); 823 extern void rfs_read(struct nfsreadargs *, struct nfsrdresult *, 824 struct exportinfo *, struct svc_req *, cred_t *); 825 extern void *rfs_read_getfh(struct nfsreadargs *); 826 extern void rfs_rdfree(struct nfsrdresult *); 827 extern void rfs_write_sync(struct nfswriteargs *, struct nfsattrstat *, 828 struct exportinfo *, struct svc_req *, cred_t *); 829 extern void rfs_write(struct nfswriteargs *, struct nfsattrstat *, 830 struct exportinfo *, struct svc_req *, cred_t *); 831 extern void *rfs_write_getfh(struct nfswriteargs *); 832 extern void rfs_create(struct nfscreatargs *, struct nfsdiropres *, 833 struct exportinfo *, struct svc_req *, cred_t *); 834 extern void *rfs_create_getfh(struct nfscreatargs *); 835 extern void rfs_remove(struct nfsdiropargs *, enum nfsstat *, 836 struct exportinfo *, struct svc_req *, cred_t *); 837 extern void *rfs_remove_getfh(struct nfsdiropargs *); 838 extern void rfs_rename(struct nfsrnmargs *, enum nfsstat *, 839 struct exportinfo *, struct svc_req *, cred_t *); 840 extern void *rfs_rename_getfh(struct nfsrnmargs *); 841 extern void rfs_link(struct nfslinkargs *, enum nfsstat *, 842 struct exportinfo *, struct svc_req *, cred_t *); 843 extern void *rfs_link_getfh(struct nfslinkargs *); 844 extern void rfs_symlink(struct nfsslargs *, enum nfsstat *, 845 struct exportinfo *, struct svc_req *, cred_t *); 846 extern void *rfs_symlink_getfh(struct nfsslargs *); 847 extern void rfs_mkdir(struct nfscreatargs *, struct nfsdiropres *, 848 struct exportinfo *, struct svc_req *, cred_t *); 849 extern void *rfs_mkdir_getfh(struct nfscreatargs *); 850 extern void rfs_rmdir(struct nfsdiropargs *, enum nfsstat *, 851 struct exportinfo *, struct svc_req *, cred_t *); 852 extern void *rfs_rmdir_getfh(struct nfsdiropargs *); 853 extern void rfs_readdir(struct nfsrddirargs *, struct nfsrddirres *, 854 struct exportinfo *, struct svc_req *, cred_t *); 855 extern void *rfs_readdir_getfh(struct nfsrddirargs *); 856 extern void rfs_rddirfree(struct nfsrddirres *); 857 extern void rfs_statfs(fhandle_t *, struct nfsstatfs *, 858 struct exportinfo *, struct svc_req *, cred_t *); 859 extern void *rfs_statfs_getfh(fhandle_t *); 860 extern void rfs_srvrinit(void); 861 extern void rfs_srvrfini(void); 862 863 /* 864 * flags to define path types during Multi Component Lookups 865 * using the public filehandle 866 */ 867 #define URLPATH 0x01 /* Universal Resource Locator path */ 868 #define NATIVEPATH 0x02 /* Native path, i.e., via mount protocol */ 869 #define SECURITY_QUERY 0x04 /* Security query */ 870 871 enum nfs_svccounts {NFS_CALLS, NFS_BADCALLS}; /* index for svstat_ptr */ 872 873 /* function defs for NFS kernel */ 874 extern int nfs_waitfor_purge_complete(vnode_t *); 875 extern int nfs_validate_caches(vnode_t *, cred_t *); 876 extern void nfs_purge_caches(vnode_t *, int, cred_t *); 877 extern void nfs_purge_rddir_cache(vnode_t *); 878 extern void nfs_attrcache(vnode_t *, struct nfsfattr *, hrtime_t); 879 extern int nfs_cache_fattr(vnode_t *, struct nfsfattr *, vattr_t *, 880 hrtime_t, cred_t *); 881 extern void nfs_attr_cache(vnode_t *, vattr_t *, hrtime_t, cred_t *); 882 extern void nfs_attrcache_va(vnode_t *, struct vattr *); 883 extern int nfs_getattr_otw(vnode_t *, struct vattr *, cred_t *); 884 extern int nfsgetattr(vnode_t *, struct vattr *, cred_t *); 885 extern int nattr_to_vattr(vnode_t *, struct nfsfattr *, struct vattr *); 886 extern void nfs_async_manager(struct vfs *); 887 extern void nfs_async_manager_stop(struct vfs *); 888 extern void nfs_async_stop(struct vfs *); 889 extern int nfs_async_stop_sig(struct vfs *); 890 extern int nfs_clntinit(void); 891 extern void nfs_clntfini(void); 892 extern int nfstsize(void); 893 extern int nfs_srvinit(void); 894 extern void nfs_srvfini(void); 895 extern int vattr_to_sattr(struct vattr *, struct nfssattr *); 896 extern void setdiropargs(struct nfsdiropargs *, char *, vnode_t *); 897 extern int setdirgid(vnode_t *, gid_t *, cred_t *); 898 extern int setdirmode(vnode_t *, mode_t *, cred_t *); 899 extern int newnum(void); 900 extern char *newname(void); 901 extern int nfs_atoi(char *); 902 extern int nfs_subrinit(void); 903 extern void nfs_subrfini(void); 904 extern enum nfsstat puterrno(int); 905 extern int geterrno(enum nfsstat); 906 extern int nfsinit(int, char *); 907 extern void nfsfini(void); 908 extern int nfs_vfsinit(void); 909 extern void nfs_vfsfini(void); 910 extern int nfs_dump(vnode_t *, caddr_t, offset_t, offset_t, 911 caller_context_t *); 912 extern void nfs_perror(int error, char *fmt, ...); 913 extern void nfs_cmn_err(int error, int level, char *fmt, ...); 914 extern int nfs_addcllock(vnode_t *vp, struct flock64 *bfp); 915 extern void nfs_rmcllock(vnode_t *vp, struct flock64 *bfp); 916 extern void nfs_lockrelease(vnode_t *vp, int flag, 917 offset_t offset, cred_t *credp); 918 extern int vattr_to_nattr(struct vattr *, struct nfsfattr *); 919 extern int mount_root(char *, char *, int, struct nfs_args *, int *); 920 extern void nfs_lockcompletion(vnode_t *vp, int cmd); 921 extern void nfs_add_locking_id(vnode_t *, pid_t, int, char *, int); 922 extern void nfs3copyfh(caddr_t, vnode_t *); 923 extern void nfscopyfh(caddr_t, vnode_t *); 924 extern int nfs3lookup(vnode_t *, char *, vnode_t **, struct pathname *, 925 int, vnode_t *, cred_t *, int); 926 extern int nfslookup(vnode_t *, char *, vnode_t **, struct pathname *, 927 int, vnode_t *, cred_t *, int); 928 extern void sv_free(struct servinfo *); 929 extern int nfsauth_access(struct exportinfo *exi, struct svc_req *req); 930 extern void nfsauth_init(); 931 extern void nfsauth_fini(); 932 extern int nfs_setopts(vnode_t *vp, model_t model, struct nfs_args *args); 933 extern int nfs_mount_label_policy(vfs_t *vfsp, struct netbuf *addr, 934 struct knetconfig *knconf, cred_t *cr); 935 extern boolean_t nfs_has_ctty(void); 936 extern void nfs_srv_stop_all(void); 937 extern void nfs_srv_quiesce_all(void); 938 extern void (*nfs_srv_quiesce_func)(void); 939 extern int rfs4_dss_setpaths(char *, size_t); 940 extern int (*nfs_srv_dss_func)(char *, size_t); 941 extern time_t rfs4_lease_time; 942 extern time_t rfs4_grace_period; 943 extern nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths; 944 945 946 extern kstat_named_t *global_svstat_ptr[]; 947 948 extern krwlock_t rroklock; 949 extern vtype_t nf_to_vt[]; 950 extern kstat_named_t *rfsproccnt_v2_ptr; 951 extern kmutex_t nfs_minor_lock; 952 extern int nfs_major; 953 extern int nfs_minor; 954 extern vfsops_t *nfs_vfsops; 955 extern struct vnodeops *nfs_vnodeops; 956 extern const struct fs_operation_def nfs_vnodeops_template[]; 957 extern int nfsfstyp; 958 959 /* 960 * Per-zone stats as consumed by nfsstat(1m) 961 */ 962 struct nfs_version_stats { 963 kstat_named_t *aclreqcnt_ptr; /* nfs_acl:0:aclreqcnt_v? */ 964 kstat_named_t *aclproccnt_ptr; /* nfs_acl:0:aclproccnt_v? */ 965 kstat_named_t *rfsreqcnt_ptr; /* nfs:0:rfsreqcnt_v? */ 966 kstat_named_t *rfsproccnt_ptr; /* nfs:0:rfsproccnt_v? */ 967 }; 968 969 /* 970 * A bit of asymmetry: nfs:0:nfs_client isn't part of this structure. 971 */ 972 struct nfs_stats { 973 kstat_named_t *nfs_stats_svstat_ptr[NFS_VERSMAX + 1]; 974 struct nfs_version_stats nfs_stats_v2; 975 struct nfs_version_stats nfs_stats_v3; 976 struct nfs_version_stats nfs_stats_v4; 977 }; 978 979 /* 980 * Key used to retrieve counters. 981 */ 982 extern zone_key_t nfsstat_zone_key; 983 984 /* 985 * Zone callback functions. 986 */ 987 extern void *nfsstat_zone_init(zoneid_t); 988 extern void nfsstat_zone_fini(zoneid_t, void *); 989 990 #endif /* _KERNEL */ 991 992 /* 993 * Version 3 declarations and definitions. 994 */ 995 996 #define NFS3_FHSIZE 64 997 #define NFS3_COOKIEVERFSIZE 8 998 #define NFS3_CREATEVERFSIZE 8 999 #define NFS3_WRITEVERFSIZE 8 1000 1001 typedef char *filename3; 1002 1003 typedef char *nfspath3; 1004 1005 #define nfs3nametoolong ((char *)-1) 1006 1007 typedef uint64 fileid3; 1008 1009 typedef uint64 cookie3; 1010 1011 typedef uint32 uid3; 1012 1013 typedef uint32 gid3; 1014 1015 typedef uint64 size3; 1016 1017 typedef uint64 offset3; 1018 1019 typedef uint32 mode3; 1020 1021 typedef uint32 count3; 1022 1023 /* 1024 * These three are really opaque arrays, but we treat them as 1025 * uint64 for efficiency sake 1026 */ 1027 typedef uint64 cookieverf3; 1028 1029 typedef uint64 createverf3; 1030 1031 typedef uint64 writeverf3; 1032 1033 typedef struct nfs_fh3 { 1034 uint_t fh3_length; 1035 union nfs_fh3_u { 1036 struct nfs_fh3_i { 1037 fhandle3_t fh3_i; 1038 } nfs_fh3_i; 1039 char data[NFS3_FHSIZE]; 1040 } fh3_u; 1041 uint_t fh3_flags; 1042 } nfs_fh3; 1043 #define fh3_fsid fh3_u.nfs_fh3_i.fh3_i._fh3_fsid 1044 #define fh3_len fh3_u.nfs_fh3_i.fh3_i._fh3_len 1045 #define fh3_data fh3_u.nfs_fh3_i.fh3_i._fh3_data 1046 #define fh3_xlen fh3_u.nfs_fh3_i.fh3_i._fh3_xlen 1047 #define fh3_xdata fh3_u.nfs_fh3_i.fh3_i._fh3_xdata 1048 #define FH3TOFIDP(fh) ((fid_t *)&((fh)->fh3_len)) 1049 #define FH3TOXFIDP(fh) ((fid_t *)&((fh)->fh3_xlen)) 1050 1051 /* 1052 * nfs_fh3.fh3_flags values 1053 */ 1054 #define FH_WEBNFS 0x1 /* fh is WebNFS overloaded - see makefh3_ol() */ 1055 1056 /* 1057 * Two elements were added to the 1058 * diropargs3 structure for performance (xdr-inlining). 1059 * They are not included as part of the args 1060 * that are encoded or decoded: 1061 * dirp - ptr to the nfs_fh3 1062 * flag indicating when to free the name that was 1063 * allocated during decode. 1064 */ 1065 struct diropargs3 { 1066 nfs_fh3 *dirp; 1067 nfs_fh3 dir; 1068 filename3 name; 1069 int flags; 1070 }; 1071 typedef struct diropargs3 diropargs3; 1072 1073 struct nfstime3 { 1074 uint32 seconds; 1075 uint32 nseconds; 1076 }; 1077 typedef struct nfstime3 nfstime3; 1078 1079 struct specdata3 { 1080 uint32 specdata1; 1081 uint32 specdata2; 1082 }; 1083 typedef struct specdata3 specdata3; 1084 1085 enum nfsstat3 { 1086 NFS3_OK = 0, 1087 NFS3ERR_PERM = 1, 1088 NFS3ERR_NOENT = 2, 1089 NFS3ERR_IO = 5, 1090 NFS3ERR_NXIO = 6, 1091 NFS3ERR_ACCES = 13, 1092 NFS3ERR_EXIST = 17, 1093 NFS3ERR_XDEV = 18, 1094 NFS3ERR_NODEV = 19, 1095 NFS3ERR_NOTDIR = 20, 1096 NFS3ERR_ISDIR = 21, 1097 NFS3ERR_INVAL = 22, 1098 NFS3ERR_FBIG = 27, 1099 NFS3ERR_NOSPC = 28, 1100 NFS3ERR_ROFS = 30, 1101 NFS3ERR_MLINK = 31, 1102 NFS3ERR_NAMETOOLONG = 63, 1103 NFS3ERR_NOTEMPTY = 66, 1104 NFS3ERR_DQUOT = 69, 1105 NFS3ERR_STALE = 70, 1106 NFS3ERR_REMOTE = 71, 1107 NFS3ERR_BADHANDLE = 10001, 1108 NFS3ERR_NOT_SYNC = 10002, 1109 NFS3ERR_BAD_COOKIE = 10003, 1110 NFS3ERR_NOTSUPP = 10004, 1111 NFS3ERR_TOOSMALL = 10005, 1112 NFS3ERR_SERVERFAULT = 10006, 1113 NFS3ERR_BADTYPE = 10007, 1114 NFS3ERR_JUKEBOX = 10008 1115 }; 1116 typedef enum nfsstat3 nfsstat3; 1117 1118 enum ftype3 { 1119 NF3REG = 1, 1120 NF3DIR = 2, 1121 NF3BLK = 3, 1122 NF3CHR = 4, 1123 NF3LNK = 5, 1124 NF3SOCK = 6, 1125 NF3FIFO = 7 1126 }; 1127 typedef enum ftype3 ftype3; 1128 1129 struct fattr3 { 1130 ftype3 type; 1131 mode3 mode; 1132 uint32 nlink; 1133 uid3 uid; 1134 gid3 gid; 1135 size3 size; 1136 size3 used; 1137 specdata3 rdev; 1138 uint64 fsid; 1139 fileid3 fileid; 1140 nfstime3 atime; 1141 nfstime3 mtime; 1142 nfstime3 ctime; 1143 }; 1144 typedef struct fattr3 fattr3; 1145 1146 #define NFS3_SIZEOF_FATTR3 (21) 1147 1148 #ifdef _KERNEL 1149 struct fattr3_res { 1150 nfsstat3 status; 1151 vattr_t *vap; 1152 vnode_t *vp; 1153 }; 1154 typedef struct fattr3_res fattr3_res; 1155 #endif /* _KERNEL */ 1156 1157 struct post_op_attr { 1158 bool_t attributes; 1159 fattr3 attr; 1160 }; 1161 typedef struct post_op_attr post_op_attr; 1162 1163 #ifdef _KERNEL 1164 struct post_op_vattr { 1165 bool_t attributes; 1166 fattr3_res fres; 1167 }; 1168 typedef struct post_op_vattr post_op_vattr; 1169 #endif /* _KERNEL */ 1170 1171 struct wcc_attr { 1172 size3 size; 1173 nfstime3 mtime; 1174 nfstime3 ctime; 1175 }; 1176 typedef struct wcc_attr wcc_attr; 1177 1178 struct pre_op_attr { 1179 bool_t attributes; 1180 wcc_attr attr; 1181 }; 1182 typedef struct pre_op_attr pre_op_attr; 1183 1184 struct wcc_data { 1185 pre_op_attr before; 1186 post_op_attr after; 1187 }; 1188 typedef struct wcc_data wcc_data; 1189 1190 struct post_op_fh3 { 1191 bool_t handle_follows; 1192 nfs_fh3 handle; 1193 }; 1194 typedef struct post_op_fh3 post_op_fh3; 1195 1196 enum time_how { 1197 DONT_CHANGE = 0, 1198 SET_TO_SERVER_TIME = 1, 1199 SET_TO_CLIENT_TIME = 2 1200 }; 1201 typedef enum time_how time_how; 1202 1203 struct set_mode3 { 1204 bool_t set_it; 1205 mode3 mode; 1206 }; 1207 typedef struct set_mode3 set_mode3; 1208 1209 struct set_uid3 { 1210 bool_t set_it; 1211 uid3 uid; 1212 }; 1213 typedef struct set_uid3 set_uid3; 1214 1215 struct set_gid3 { 1216 bool_t set_it; 1217 gid3 gid; 1218 }; 1219 typedef struct set_gid3 set_gid3; 1220 1221 struct set_size3 { 1222 bool_t set_it; 1223 size3 size; 1224 }; 1225 typedef struct set_size3 set_size3; 1226 1227 struct set_atime { 1228 time_how set_it; 1229 nfstime3 atime; 1230 }; 1231 typedef struct set_atime set_atime; 1232 1233 struct set_mtime { 1234 time_how set_it; 1235 nfstime3 mtime; 1236 }; 1237 typedef struct set_mtime set_mtime; 1238 1239 struct sattr3 { 1240 set_mode3 mode; 1241 set_uid3 uid; 1242 set_gid3 gid; 1243 set_size3 size; 1244 set_atime atime; 1245 set_mtime mtime; 1246 }; 1247 typedef struct sattr3 sattr3; 1248 1249 /* 1250 * A couple of defines to make resok and resfail look like the 1251 * correct things in a response type independent manner. 1252 */ 1253 #define resok res_u.ok 1254 #define resfail res_u.fail 1255 1256 struct GETATTR3args { 1257 nfs_fh3 object; 1258 }; 1259 typedef struct GETATTR3args GETATTR3args; 1260 1261 struct GETATTR3resok { 1262 fattr3 obj_attributes; 1263 }; 1264 typedef struct GETATTR3resok GETATTR3resok; 1265 1266 struct GETATTR3res { 1267 nfsstat3 status; 1268 union { 1269 GETATTR3resok ok; 1270 } res_u; 1271 }; 1272 typedef struct GETATTR3res GETATTR3res; 1273 1274 #ifdef _KERNEL 1275 struct GETATTR3vres { 1276 nfsstat3 status; 1277 fattr3_res fres; 1278 }; 1279 typedef struct GETATTR3vres GETATTR3vres; 1280 #endif /* _KERNEL */ 1281 1282 struct sattrguard3 { 1283 bool_t check; 1284 nfstime3 obj_ctime; 1285 }; 1286 typedef struct sattrguard3 sattrguard3; 1287 1288 struct SETATTR3args { 1289 nfs_fh3 object; 1290 sattr3 new_attributes; 1291 sattrguard3 guard; 1292 }; 1293 typedef struct SETATTR3args SETATTR3args; 1294 1295 struct SETATTR3resok { 1296 wcc_data obj_wcc; 1297 }; 1298 typedef struct SETATTR3resok SETATTR3resok; 1299 1300 struct SETATTR3resfail { 1301 wcc_data obj_wcc; 1302 }; 1303 typedef struct SETATTR3resfail SETATTR3resfail; 1304 1305 struct SETATTR3res { 1306 nfsstat3 status; 1307 union { 1308 SETATTR3resok ok; 1309 SETATTR3resfail fail; 1310 } res_u; 1311 }; 1312 typedef struct SETATTR3res SETATTR3res; 1313 1314 struct LOOKUP3args { 1315 diropargs3 what; 1316 }; 1317 typedef struct LOOKUP3args LOOKUP3args; 1318 1319 struct LOOKUP3resok { 1320 nfs_fh3 object; 1321 post_op_attr obj_attributes; 1322 post_op_attr dir_attributes; 1323 }; 1324 typedef struct LOOKUP3resok LOOKUP3resok; 1325 1326 struct LOOKUP3resfail { 1327 post_op_attr dir_attributes; 1328 }; 1329 typedef struct LOOKUP3resfail LOOKUP3resfail; 1330 1331 struct LOOKUP3res { 1332 nfsstat3 status; 1333 union { 1334 LOOKUP3resok ok; 1335 LOOKUP3resfail fail; 1336 } res_u; 1337 }; 1338 typedef struct LOOKUP3res LOOKUP3res; 1339 1340 #ifdef _KERNEL 1341 struct LOOKUP3vres { 1342 nfsstat3 status; 1343 nfs_fh3 object; 1344 post_op_vattr dir_attributes; 1345 post_op_vattr obj_attributes; 1346 }; 1347 typedef struct LOOKUP3vres LOOKUP3vres; 1348 #endif /* _KERNEL */ 1349 1350 struct ACCESS3args { 1351 nfs_fh3 object; 1352 uint32 access; 1353 }; 1354 typedef struct ACCESS3args ACCESS3args; 1355 #define ACCESS3_READ 0x1 1356 #define ACCESS3_LOOKUP 0x2 1357 #define ACCESS3_MODIFY 0x4 1358 #define ACCESS3_EXTEND 0x8 1359 #define ACCESS3_DELETE 0x10 1360 #define ACCESS3_EXECUTE 0x20 1361 1362 struct ACCESS3resok { 1363 post_op_attr obj_attributes; 1364 uint32 access; 1365 }; 1366 typedef struct ACCESS3resok ACCESS3resok; 1367 1368 struct ACCESS3resfail { 1369 post_op_attr obj_attributes; 1370 }; 1371 typedef struct ACCESS3resfail ACCESS3resfail; 1372 1373 struct ACCESS3res { 1374 nfsstat3 status; 1375 union { 1376 ACCESS3resok ok; 1377 ACCESS3resfail fail; 1378 } res_u; 1379 }; 1380 typedef struct ACCESS3res ACCESS3res; 1381 1382 struct READLINK3args { 1383 nfs_fh3 symlink; 1384 }; 1385 typedef struct READLINK3args READLINK3args; 1386 1387 struct READLINK3resok { 1388 post_op_attr symlink_attributes; 1389 nfspath3 data; 1390 }; 1391 typedef struct READLINK3resok READLINK3resok; 1392 1393 struct READLINK3resfail { 1394 post_op_attr symlink_attributes; 1395 }; 1396 typedef struct READLINK3resfail READLINK3resfail; 1397 1398 struct READLINK3res { 1399 nfsstat3 status; 1400 union { 1401 READLINK3resok ok; 1402 READLINK3resfail fail; 1403 } res_u; 1404 }; 1405 typedef struct READLINK3res READLINK3res; 1406 1407 struct READ3args { 1408 nfs_fh3 file; 1409 offset3 offset; 1410 count3 count; 1411 }; 1412 typedef struct READ3args READ3args; 1413 1414 struct READ3resok { 1415 post_op_attr file_attributes; 1416 count3 count; 1417 bool_t eof; 1418 struct { 1419 uint_t data_len; 1420 char *data_val; 1421 mblk_t *mp; 1422 } data; 1423 uint_t size; 1424 }; 1425 typedef struct READ3resok READ3resok; 1426 1427 struct READ3resfail { 1428 post_op_attr file_attributes; 1429 }; 1430 typedef struct READ3resfail READ3resfail; 1431 1432 struct READ3res { 1433 nfsstat3 status; 1434 union { 1435 READ3resok ok; 1436 READ3resfail fail; 1437 } res_u; 1438 }; 1439 typedef struct READ3res READ3res; 1440 1441 #ifdef _KERNEL 1442 /* 1443 * READ3 reply that directly decodes fattr3 directly into vattr 1444 */ 1445 struct READ3vres { 1446 nfsstat3 status; 1447 struct post_op_vattr pov; 1448 count3 count; 1449 bool_t eof; 1450 struct { 1451 uint_t data_len; 1452 char *data_val; 1453 } data; 1454 uint_t size; 1455 }; 1456 typedef struct READ3vres READ3vres; 1457 #endif /* _KERNEL */ 1458 1459 /* 1460 * READ3 reply that uiomoves data directly into a struct uio 1461 * ignores any attributes returned 1462 */ 1463 struct READ3uiores { 1464 nfsstat3 status; 1465 count3 count; 1466 bool_t eof; 1467 struct uio *uiop; 1468 uint_t size; /* maximum reply size */ 1469 }; 1470 typedef struct READ3uiores READ3uiores; 1471 1472 enum stable_how { 1473 UNSTABLE = 0, 1474 DATA_SYNC = 1, 1475 FILE_SYNC = 2 1476 }; 1477 typedef enum stable_how stable_how; 1478 1479 struct WRITE3args { 1480 nfs_fh3 file; 1481 offset3 offset; 1482 count3 count; 1483 stable_how stable; 1484 struct { 1485 uint_t data_len; 1486 char *data_val; 1487 } data; 1488 mblk_t *mblk; 1489 }; 1490 typedef struct WRITE3args WRITE3args; 1491 1492 struct WRITE3resok { 1493 wcc_data file_wcc; 1494 count3 count; 1495 stable_how committed; 1496 writeverf3 verf; 1497 }; 1498 typedef struct WRITE3resok WRITE3resok; 1499 1500 struct WRITE3resfail { 1501 wcc_data file_wcc; 1502 }; 1503 typedef struct WRITE3resfail WRITE3resfail; 1504 1505 struct WRITE3res { 1506 nfsstat3 status; 1507 union { 1508 WRITE3resok ok; 1509 WRITE3resfail fail; 1510 } res_u; 1511 }; 1512 typedef struct WRITE3res WRITE3res; 1513 1514 enum createmode3 { 1515 UNCHECKED = 0, 1516 GUARDED = 1, 1517 EXCLUSIVE = 2 1518 }; 1519 typedef enum createmode3 createmode3; 1520 1521 struct createhow3 { 1522 createmode3 mode; 1523 union { 1524 sattr3 obj_attributes; 1525 createverf3 verf; 1526 } createhow3_u; 1527 }; 1528 typedef struct createhow3 createhow3; 1529 1530 struct CREATE3args { 1531 diropargs3 where; 1532 createhow3 how; 1533 }; 1534 typedef struct CREATE3args CREATE3args; 1535 1536 struct CREATE3resok { 1537 post_op_fh3 obj; 1538 post_op_attr obj_attributes; 1539 wcc_data dir_wcc; 1540 }; 1541 typedef struct CREATE3resok CREATE3resok; 1542 1543 struct CREATE3resfail { 1544 wcc_data dir_wcc; 1545 }; 1546 typedef struct CREATE3resfail CREATE3resfail; 1547 1548 struct CREATE3res { 1549 nfsstat3 status; 1550 union { 1551 CREATE3resok ok; 1552 CREATE3resfail fail; 1553 } res_u; 1554 }; 1555 typedef struct CREATE3res CREATE3res; 1556 1557 struct MKDIR3args { 1558 diropargs3 where; 1559 sattr3 attributes; 1560 }; 1561 typedef struct MKDIR3args MKDIR3args; 1562 1563 struct MKDIR3resok { 1564 post_op_fh3 obj; 1565 post_op_attr obj_attributes; 1566 wcc_data dir_wcc; 1567 }; 1568 typedef struct MKDIR3resok MKDIR3resok; 1569 1570 struct MKDIR3resfail { 1571 wcc_data dir_wcc; 1572 }; 1573 typedef struct MKDIR3resfail MKDIR3resfail; 1574 1575 struct MKDIR3res { 1576 nfsstat3 status; 1577 union { 1578 MKDIR3resok ok; 1579 MKDIR3resfail fail; 1580 } res_u; 1581 }; 1582 typedef struct MKDIR3res MKDIR3res; 1583 1584 struct symlinkdata3 { 1585 sattr3 symlink_attributes; 1586 nfspath3 symlink_data; 1587 }; 1588 typedef struct symlinkdata3 symlinkdata3; 1589 1590 struct SYMLINK3args { 1591 diropargs3 where; 1592 symlinkdata3 symlink; 1593 }; 1594 typedef struct SYMLINK3args SYMLINK3args; 1595 1596 struct SYMLINK3resok { 1597 post_op_fh3 obj; 1598 post_op_attr obj_attributes; 1599 wcc_data dir_wcc; 1600 }; 1601 typedef struct SYMLINK3resok SYMLINK3resok; 1602 1603 struct SYMLINK3resfail { 1604 wcc_data dir_wcc; 1605 }; 1606 typedef struct SYMLINK3resfail SYMLINK3resfail; 1607 1608 struct SYMLINK3res { 1609 nfsstat3 status; 1610 union { 1611 SYMLINK3resok ok; 1612 SYMLINK3resfail fail; 1613 } res_u; 1614 }; 1615 typedef struct SYMLINK3res SYMLINK3res; 1616 1617 struct devicedata3 { 1618 sattr3 dev_attributes; 1619 specdata3 spec; 1620 }; 1621 typedef struct devicedata3 devicedata3; 1622 1623 struct mknoddata3 { 1624 ftype3 type; 1625 union { 1626 devicedata3 device; 1627 sattr3 pipe_attributes; 1628 } mknoddata3_u; 1629 }; 1630 typedef struct mknoddata3 mknoddata3; 1631 1632 struct MKNOD3args { 1633 diropargs3 where; 1634 mknoddata3 what; 1635 }; 1636 typedef struct MKNOD3args MKNOD3args; 1637 1638 struct MKNOD3resok { 1639 post_op_fh3 obj; 1640 post_op_attr obj_attributes; 1641 wcc_data dir_wcc; 1642 }; 1643 typedef struct MKNOD3resok MKNOD3resok; 1644 1645 struct MKNOD3resfail { 1646 wcc_data dir_wcc; 1647 }; 1648 typedef struct MKNOD3resfail MKNOD3resfail; 1649 1650 struct MKNOD3res { 1651 nfsstat3 status; 1652 union { 1653 MKNOD3resok ok; 1654 MKNOD3resfail fail; 1655 } res_u; 1656 }; 1657 typedef struct MKNOD3res MKNOD3res; 1658 1659 struct REMOVE3args { 1660 diropargs3 object; 1661 }; 1662 typedef struct REMOVE3args REMOVE3args; 1663 1664 struct REMOVE3resok { 1665 wcc_data dir_wcc; 1666 }; 1667 typedef struct REMOVE3resok REMOVE3resok; 1668 1669 struct REMOVE3resfail { 1670 wcc_data dir_wcc; 1671 }; 1672 typedef struct REMOVE3resfail REMOVE3resfail; 1673 1674 struct REMOVE3res { 1675 nfsstat3 status; 1676 union { 1677 REMOVE3resok ok; 1678 REMOVE3resfail fail; 1679 } res_u; 1680 }; 1681 typedef struct REMOVE3res REMOVE3res; 1682 1683 struct RMDIR3args { 1684 diropargs3 object; 1685 }; 1686 typedef struct RMDIR3args RMDIR3args; 1687 1688 struct RMDIR3resok { 1689 wcc_data dir_wcc; 1690 }; 1691 typedef struct RMDIR3resok RMDIR3resok; 1692 1693 struct RMDIR3resfail { 1694 wcc_data dir_wcc; 1695 }; 1696 typedef struct RMDIR3resfail RMDIR3resfail; 1697 1698 struct RMDIR3res { 1699 nfsstat3 status; 1700 union { 1701 RMDIR3resok ok; 1702 RMDIR3resfail fail; 1703 } res_u; 1704 }; 1705 typedef struct RMDIR3res RMDIR3res; 1706 1707 struct RENAME3args { 1708 diropargs3 from; 1709 diropargs3 to; 1710 }; 1711 typedef struct RENAME3args RENAME3args; 1712 1713 struct RENAME3resok { 1714 wcc_data fromdir_wcc; 1715 wcc_data todir_wcc; 1716 }; 1717 typedef struct RENAME3resok RENAME3resok; 1718 1719 struct RENAME3resfail { 1720 wcc_data fromdir_wcc; 1721 wcc_data todir_wcc; 1722 }; 1723 typedef struct RENAME3resfail RENAME3resfail; 1724 1725 struct RENAME3res { 1726 nfsstat3 status; 1727 union { 1728 RENAME3resok ok; 1729 RENAME3resfail fail; 1730 } res_u; 1731 }; 1732 typedef struct RENAME3res RENAME3res; 1733 1734 struct LINK3args { 1735 nfs_fh3 file; 1736 diropargs3 link; 1737 }; 1738 typedef struct LINK3args LINK3args; 1739 1740 struct LINK3resok { 1741 post_op_attr file_attributes; 1742 wcc_data linkdir_wcc; 1743 }; 1744 typedef struct LINK3resok LINK3resok; 1745 1746 struct LINK3resfail { 1747 post_op_attr file_attributes; 1748 wcc_data linkdir_wcc; 1749 }; 1750 typedef struct LINK3resfail LINK3resfail; 1751 1752 struct LINK3res { 1753 nfsstat3 status; 1754 union { 1755 LINK3resok ok; 1756 LINK3resfail fail; 1757 } res_u; 1758 }; 1759 typedef struct LINK3res LINK3res; 1760 1761 struct READDIR3args { 1762 nfs_fh3 dir; 1763 cookie3 cookie; 1764 cookieverf3 cookieverf; 1765 count3 count; 1766 }; 1767 typedef struct READDIR3args READDIR3args; 1768 1769 struct entry3 { 1770 fileid3 fileid; 1771 filename3 name; 1772 cookie3 cookie; 1773 struct entry3 *nextentry; 1774 }; 1775 typedef struct entry3 entry3; 1776 1777 struct dirlist3 { 1778 entry3 *entries; 1779 bool_t eof; 1780 }; 1781 typedef struct dirlist3 dirlist3; 1782 1783 struct READDIR3resok { 1784 post_op_attr dir_attributes; 1785 cookieverf3 cookieverf; 1786 dirlist3 reply; 1787 uint_t size; 1788 uint_t count; 1789 uint_t freecount; 1790 cookie3 cookie; 1791 }; 1792 typedef struct READDIR3resok READDIR3resok; 1793 1794 struct READDIR3resfail { 1795 post_op_attr dir_attributes; 1796 }; 1797 typedef struct READDIR3resfail READDIR3resfail; 1798 1799 struct READDIR3res { 1800 nfsstat3 status; 1801 union { 1802 READDIR3resok ok; 1803 READDIR3resfail fail; 1804 } res_u; 1805 }; 1806 typedef struct READDIR3res READDIR3res; 1807 1808 #ifdef _KERNEL 1809 struct READDIR3vres { 1810 nfsstat3 status; 1811 post_op_vattr dir_attributes; 1812 cookieverf3 cookieverf; 1813 dirent64_t *entries; /* decoded dirent64s */ 1814 uint_t size; /* actual size of entries */ 1815 uint_t entries_size; /* max size of entries */ 1816 off64_t loff; /* last offset/cookie */ 1817 bool_t eof; /* End of directory */ 1818 }; 1819 typedef struct READDIR3vres READDIR3vres; 1820 #endif /* _KERNEL */ 1821 1822 struct READDIRPLUS3args { 1823 nfs_fh3 dir; 1824 cookie3 cookie; 1825 cookieverf3 cookieverf; 1826 count3 dircount; 1827 count3 maxcount; 1828 }; 1829 typedef struct READDIRPLUS3args READDIRPLUS3args; 1830 1831 struct entryplus3 { 1832 fileid3 fileid; 1833 filename3 name; 1834 cookie3 cookie; 1835 post_op_attr name_attributes; 1836 post_op_fh3 name_handle; 1837 struct entryplus3 *nextentry; 1838 }; 1839 typedef struct entryplus3 entryplus3; 1840 1841 struct dirlistplus3 { 1842 entryplus3 *entries; 1843 bool_t eof; 1844 }; 1845 typedef struct dirlistplus3 dirlistplus3; 1846 1847 struct entryplus3_info { 1848 post_op_attr attr; 1849 post_op_fh3 fh; 1850 uint_t namelen; 1851 }; 1852 typedef struct entryplus3_info entryplus3_info; 1853 1854 struct READDIRPLUS3resok { 1855 post_op_attr dir_attributes; 1856 cookieverf3 cookieverf; 1857 dirlistplus3 reply; 1858 uint_t size; 1859 uint_t count; 1860 uint_t maxcount; 1861 entryplus3_info *infop; 1862 }; 1863 typedef struct READDIRPLUS3resok READDIRPLUS3resok; 1864 1865 struct READDIRPLUS3resfail { 1866 post_op_attr dir_attributes; 1867 }; 1868 typedef struct READDIRPLUS3resfail READDIRPLUS3resfail; 1869 1870 struct READDIRPLUS3res { 1871 nfsstat3 status; 1872 union { 1873 READDIRPLUS3resok ok; 1874 READDIRPLUS3resfail fail; 1875 } res_u; 1876 }; 1877 typedef struct READDIRPLUS3res READDIRPLUS3res; 1878 1879 #ifdef _KERNEL 1880 struct entryplus3_va_fh { 1881 int va_valid; 1882 int fh_valid; 1883 vattr_t va; 1884 nfs_fh3 fh; 1885 char *d_name; /* back pointer into entries */ 1886 }; 1887 1888 struct READDIRPLUS3vres { 1889 nfsstat3 status; 1890 post_op_vattr dir_attributes; 1891 cookieverf3 cookieverf; 1892 dirent64_t *entries; /* decoded dirent64s */ 1893 uint_t size; /* actual size of entries */ 1894 uint_t entries_size; /* max size of entries */ 1895 bool_t eof; /* End of directory */ 1896 off64_t loff; /* last offset/cookie */ 1897 cred_t *credentials; /* caller's credentials */ 1898 hrtime_t time; /* time of READDIRPLUS call */ 1899 }; 1900 typedef struct READDIRPLUS3vres READDIRPLUS3vres; 1901 #endif /* _KERNEL */ 1902 1903 struct FSSTAT3args { 1904 nfs_fh3 fsroot; 1905 }; 1906 typedef struct FSSTAT3args FSSTAT3args; 1907 1908 struct FSSTAT3resok { 1909 post_op_attr obj_attributes; 1910 size3 tbytes; 1911 size3 fbytes; 1912 size3 abytes; 1913 size3 tfiles; 1914 size3 ffiles; 1915 size3 afiles; 1916 uint32 invarsec; 1917 }; 1918 typedef struct FSSTAT3resok FSSTAT3resok; 1919 1920 struct FSSTAT3resfail { 1921 post_op_attr obj_attributes; 1922 }; 1923 typedef struct FSSTAT3resfail FSSTAT3resfail; 1924 1925 struct FSSTAT3res { 1926 nfsstat3 status; 1927 union { 1928 FSSTAT3resok ok; 1929 FSSTAT3resfail fail; 1930 } res_u; 1931 }; 1932 typedef struct FSSTAT3res FSSTAT3res; 1933 1934 struct FSINFO3args { 1935 nfs_fh3 fsroot; 1936 }; 1937 typedef struct FSINFO3args FSINFO3args; 1938 1939 struct FSINFO3resok { 1940 post_op_attr obj_attributes; 1941 uint32 rtmax; 1942 uint32 rtpref; 1943 uint32 rtmult; 1944 uint32 wtmax; 1945 uint32 wtpref; 1946 uint32 wtmult; 1947 uint32 dtpref; 1948 size3 maxfilesize; 1949 nfstime3 time_delta; 1950 uint32 properties; 1951 }; 1952 typedef struct FSINFO3resok FSINFO3resok; 1953 1954 struct FSINFO3resfail { 1955 post_op_attr obj_attributes; 1956 }; 1957 typedef struct FSINFO3resfail FSINFO3resfail; 1958 #define FSF3_LINK 0x1 1959 #define FSF3_SYMLINK 0x2 1960 #define FSF3_HOMOGENEOUS 0x8 1961 #define FSF3_CANSETTIME 0x10 1962 1963 struct FSINFO3res { 1964 nfsstat3 status; 1965 union { 1966 FSINFO3resok ok; 1967 FSINFO3resfail fail; 1968 } res_u; 1969 }; 1970 typedef struct FSINFO3res FSINFO3res; 1971 1972 struct PATHCONF3args { 1973 nfs_fh3 object; 1974 }; 1975 typedef struct PATHCONF3args PATHCONF3args; 1976 1977 struct nfs3_pathconf_info { 1978 uint32 link_max; 1979 uint32 name_max; 1980 bool_t no_trunc; 1981 bool_t chown_restricted; 1982 bool_t case_insensitive; 1983 bool_t case_preserving; 1984 }; 1985 typedef struct nfs3_pathconf_info nfs3_pathconf_info; 1986 1987 struct PATHCONF3resok { 1988 post_op_attr obj_attributes; 1989 nfs3_pathconf_info info; 1990 }; 1991 typedef struct PATHCONF3resok PATHCONF3resok; 1992 1993 struct PATHCONF3resfail { 1994 post_op_attr obj_attributes; 1995 }; 1996 typedef struct PATHCONF3resfail PATHCONF3resfail; 1997 1998 struct PATHCONF3res { 1999 nfsstat3 status; 2000 union { 2001 PATHCONF3resok ok; 2002 PATHCONF3resfail fail; 2003 } res_u; 2004 }; 2005 typedef struct PATHCONF3res PATHCONF3res; 2006 2007 struct COMMIT3args { 2008 nfs_fh3 file; 2009 offset3 offset; 2010 count3 count; 2011 }; 2012 typedef struct COMMIT3args COMMIT3args; 2013 2014 struct COMMIT3resok { 2015 wcc_data file_wcc; 2016 writeverf3 verf; 2017 }; 2018 typedef struct COMMIT3resok COMMIT3resok; 2019 2020 struct COMMIT3resfail { 2021 wcc_data file_wcc; 2022 }; 2023 typedef struct COMMIT3resfail COMMIT3resfail; 2024 2025 struct COMMIT3res { 2026 nfsstat3 status; 2027 union { 2028 COMMIT3resok ok; 2029 COMMIT3resfail fail; 2030 } res_u; 2031 }; 2032 typedef struct COMMIT3res COMMIT3res; 2033 2034 #define NFS3_PROGRAM ((rpcprog_t)100003) 2035 #define NFS_V3 ((rpcvers_t)3) 2036 #define NFSPROC3_NULL ((rpcproc_t)0) 2037 #define NFSPROC3_GETATTR ((rpcproc_t)1) 2038 #define NFSPROC3_SETATTR ((rpcproc_t)2) 2039 #define NFSPROC3_LOOKUP ((rpcproc_t)3) 2040 #define NFSPROC3_ACCESS ((rpcproc_t)4) 2041 #define NFSPROC3_READLINK ((rpcproc_t)5) 2042 #define NFSPROC3_READ ((rpcproc_t)6) 2043 #define NFSPROC3_WRITE ((rpcproc_t)7) 2044 #define NFSPROC3_CREATE ((rpcproc_t)8) 2045 #define NFSPROC3_MKDIR ((rpcproc_t)9) 2046 #define NFSPROC3_SYMLINK ((rpcproc_t)10) 2047 #define NFSPROC3_MKNOD ((rpcproc_t)11) 2048 #define NFSPROC3_REMOVE ((rpcproc_t)12) 2049 #define NFSPROC3_RMDIR ((rpcproc_t)13) 2050 #define NFSPROC3_RENAME ((rpcproc_t)14) 2051 #define NFSPROC3_LINK ((rpcproc_t)15) 2052 #define NFSPROC3_READDIR ((rpcproc_t)16) 2053 #define NFSPROC3_READDIRPLUS ((rpcproc_t)17) 2054 #define NFSPROC3_FSSTAT ((rpcproc_t)18) 2055 #define NFSPROC3_FSINFO ((rpcproc_t)19) 2056 #define NFSPROC3_PATHCONF ((rpcproc_t)20) 2057 #define NFSPROC3_COMMIT ((rpcproc_t)21) 2058 2059 #ifndef _KERNEL 2060 extern void * nfsproc3_null_3(); 2061 extern GETATTR3res * nfsproc3_getattr_3(); 2062 extern SETATTR3res * nfsproc3_setattr_3(); 2063 extern LOOKUP3res * nfsproc3_lookup_3(); 2064 extern ACCESS3res * nfsproc3_access_3(); 2065 extern READLINK3res * nfsproc3_readlink_3(); 2066 extern READ3res * nfsproc3_read_3(); 2067 extern WRITE3res * nfsproc3_write_3(); 2068 extern CREATE3res * nfsproc3_create_3(); 2069 extern MKDIR3res * nfsproc3_mkdir_3(); 2070 extern SYMLINK3res * nfsproc3_symlink_3(); 2071 extern MKNOD3res * nfsproc3_mknod_3(); 2072 extern REMOVE3res * nfsproc3_remove_3(); 2073 extern RMDIR3res * nfsproc3_rmdir_3(); 2074 extern RENAME3res * nfsproc3_rename_3(); 2075 extern LINK3res * nfsproc3_link_3(); 2076 extern READDIR3res * nfsproc3_readdir_3(); 2077 extern READDIRPLUS3res * nfsproc3_readdirplus_3(); 2078 extern FSSTAT3res * nfsproc3_fsstat_3(); 2079 extern FSINFO3res * nfsproc3_fsinfo_3(); 2080 extern PATHCONF3res * nfsproc3_pathconf_3(); 2081 extern COMMIT3res * nfsproc3_commit_3(); 2082 #endif /* !_KERNEL */ 2083 2084 #ifdef _KERNEL 2085 /* the NFS Version 3 XDR functions */ 2086 2087 extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3 *); 2088 extern bool_t xdr_nfslog_nfs_fh3(XDR *, nfs_fh3 *); 2089 extern bool_t xdr_nfs_fh3_server(XDR *, nfs_fh3 *); 2090 extern bool_t xdr_diropargs3(XDR *, diropargs3 *); 2091 extern bool_t xdr_post_op_attr(XDR *, post_op_attr *); 2092 extern bool_t xdr_post_op_fh3(XDR *, post_op_fh3 *); 2093 extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res *); 2094 extern bool_t xdr_GETATTR3vres(XDR *, GETATTR3vres *); 2095 extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args *); 2096 extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res *); 2097 extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res *); 2098 extern bool_t xdr_LOOKUP3vres(XDR *, LOOKUP3vres *); 2099 extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args *); 2100 extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res *); 2101 extern bool_t xdr_READLINK3args(XDR *, READLINK3args *); 2102 extern bool_t xdr_READLINK3res(XDR *, READLINK3res *); 2103 extern bool_t xdr_READ3args(XDR *, READ3args *); 2104 extern bool_t xdr_READ3res(XDR *, READ3res *); 2105 extern bool_t xdr_READ3vres(XDR *, READ3vres *); 2106 extern bool_t xdr_READ3uiores(XDR *, READ3uiores *); 2107 extern bool_t xdr_WRITE3args(XDR *, WRITE3args *); 2108 extern bool_t xdr_WRITE3res(XDR *, WRITE3res *); 2109 extern bool_t xdr_CREATE3args(XDR *, CREATE3args *); 2110 extern bool_t xdr_CREATE3res(XDR *, CREATE3res *); 2111 extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args *); 2112 extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res *); 2113 extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args *); 2114 extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res *); 2115 extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args *); 2116 extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res *); 2117 extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res *); 2118 extern bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail *); 2119 extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res *); 2120 extern bool_t xdr_RENAME3args(XDR *, RENAME3args *); 2121 extern bool_t xdr_RENAME3res(XDR *, RENAME3res *); 2122 extern bool_t xdr_LINK3args(XDR *, LINK3args *); 2123 extern bool_t xdr_LINK3res(XDR *, LINK3res *); 2124 extern bool_t xdr_READDIR3args(XDR *, READDIR3args *); 2125 extern bool_t xdr_READDIR3res(XDR *, READDIR3res *); 2126 extern bool_t xdr_READDIR3vres(XDR *, READDIR3vres *); 2127 extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args *); 2128 extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res *); 2129 extern bool_t xdr_READDIRPLUS3vres(XDR *, READDIRPLUS3vres *); 2130 extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res *); 2131 extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res *); 2132 extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res *); 2133 extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args *); 2134 extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res *); 2135 extern bool_t xdr_fastnfs_fh3(XDR *, nfs_fh3 **); 2136 2137 /* 2138 * The NFS Version 3 service procedures. 2139 */ 2140 struct exportinfo; /* defined in nfs/export.h */ 2141 struct servinfo; /* defined in nfs/nfs_clnt.h */ 2142 struct mntinfo; /* defined in nfs/nfs_clnt.h */ 2143 struct sec_ol; /* defined in nfs/export.h */ 2144 2145 extern void rfs3_getattr(GETATTR3args *, GETATTR3res *, 2146 struct exportinfo *, struct svc_req *, cred_t *); 2147 extern void *rfs3_getattr_getfh(GETATTR3args *); 2148 extern void rfs3_setattr(SETATTR3args *, SETATTR3res *, 2149 struct exportinfo *, struct svc_req *, cred_t *); 2150 extern void *rfs3_setattr_getfh(SETATTR3args *); 2151 extern void rfs3_lookup(LOOKUP3args *, LOOKUP3res *, 2152 struct exportinfo *, struct svc_req *, cred_t *); 2153 extern void *rfs3_lookup_getfh(LOOKUP3args *); 2154 extern void rfs3_access(ACCESS3args *, ACCESS3res *, 2155 struct exportinfo *, struct svc_req *, cred_t *); 2156 extern void *rfs3_access_getfh(ACCESS3args *); 2157 extern void rfs3_readlink(READLINK3args *, READLINK3res *, 2158 struct exportinfo *, struct svc_req *, cred_t *); 2159 extern void *rfs3_readlink_getfh(READLINK3args *); 2160 extern void rfs3_readlink_free(READLINK3res *); 2161 extern void rfs3_read(READ3args *, READ3res *, 2162 struct exportinfo *, struct svc_req *, cred_t *); 2163 extern void *rfs3_read_getfh(READ3args *); 2164 extern void rfs3_read_free(READ3res *); 2165 extern void rfs3_write(WRITE3args *, WRITE3res *, 2166 struct exportinfo *, struct svc_req *, cred_t *); 2167 extern void *rfs3_write_getfh(WRITE3args *); 2168 extern void rfs3_create(CREATE3args *, CREATE3res *, 2169 struct exportinfo *, struct svc_req *, cred_t *); 2170 extern void *rfs3_create_getfh(CREATE3args *); 2171 extern void rfs3_mkdir(MKDIR3args *, MKDIR3res *, 2172 struct exportinfo *, struct svc_req *, cred_t *); 2173 extern void *rfs3_mkdir_getfh(MKDIR3args *); 2174 extern void rfs3_symlink(SYMLINK3args *, SYMLINK3res *, 2175 struct exportinfo *, struct svc_req *, cred_t *); 2176 extern void *rfs3_symlink_getfh(SYMLINK3args *); 2177 extern void rfs3_mknod(MKNOD3args *, MKNOD3res *, 2178 struct exportinfo *, struct svc_req *, cred_t *); 2179 extern void *rfs3_mknod_getfh(MKNOD3args *); 2180 extern void rfs3_remove(REMOVE3args *, REMOVE3res *, 2181 struct exportinfo *, struct svc_req *, cred_t *); 2182 extern void *rfs3_remove_getfh(REMOVE3args *); 2183 extern void rfs3_rmdir(RMDIR3args *, RMDIR3res *, 2184 struct exportinfo *, struct svc_req *, cred_t *); 2185 extern void *rfs3_rmdir_getfh(RMDIR3args *); 2186 extern void rfs3_rename(RENAME3args *, RENAME3res *, 2187 struct exportinfo *, struct svc_req *, cred_t *); 2188 extern void *rfs3_rename_getfh(RENAME3args *); 2189 extern void rfs3_link(LINK3args *, LINK3res *, 2190 struct exportinfo *, struct svc_req *, cred_t *); 2191 extern void *rfs3_link_getfh(LINK3args *); 2192 extern void rfs3_readdir(READDIR3args *, READDIR3res *, 2193 struct exportinfo *, struct svc_req *, cred_t *); 2194 extern void *rfs3_readdir_getfh(READDIR3args *); 2195 extern void rfs3_readdir_free(READDIR3res *); 2196 extern void rfs3_readdirplus(READDIRPLUS3args *, READDIRPLUS3res *, 2197 struct exportinfo *, struct svc_req *, cred_t *); 2198 extern void *rfs3_readdirplus_getfh(READDIRPLUS3args *); 2199 extern void rfs3_readdirplus_free(READDIRPLUS3res *); 2200 extern void rfs3_fsstat(FSSTAT3args *, FSSTAT3res *, 2201 struct exportinfo *, struct svc_req *, cred_t *); 2202 extern void *rfs3_fsstat_getfh(FSSTAT3args *); 2203 extern void rfs3_fsinfo(FSINFO3args *, FSINFO3res *, 2204 struct exportinfo *, struct svc_req *, cred_t *); 2205 extern void *rfs3_fsinfo_getfh(FSINFO3args *); 2206 extern void rfs3_pathconf(PATHCONF3args *, PATHCONF3res *, 2207 struct exportinfo *, struct svc_req *, cred_t *); 2208 extern void *rfs3_pathconf_getfh(PATHCONF3args *); 2209 extern void rfs3_commit(COMMIT3args *, COMMIT3res *, 2210 struct exportinfo *, struct svc_req *, cred_t *); 2211 extern void *rfs3_commit_getfh(COMMIT3args *); 2212 extern void rfs3_srvrinit(void); 2213 extern void rfs3_srvrfini(void); 2214 2215 extern int nfs3_validate_caches(vnode_t *, cred_t *); 2216 extern void nfs3_cache_post_op_attr(vnode_t *, post_op_attr *, hrtime_t, 2217 cred_t *); 2218 extern void nfs3_cache_post_op_vattr(vnode_t *, post_op_vattr *, hrtime_t, 2219 cred_t *); 2220 extern void nfs3_cache_wcc_data(vnode_t *, wcc_data *, hrtime_t, cred_t *); 2221 extern void nfs3_attrcache(vnode_t *, fattr3 *, hrtime_t); 2222 extern int nfs3_cache_fattr3(vnode_t *, fattr3 *, vattr_t *, hrtime_t, 2223 cred_t *); 2224 extern int nfs3_getattr_otw(vnode_t *, struct vattr *, cred_t *); 2225 extern int nfs3getattr(vnode_t *, struct vattr *, cred_t *); 2226 extern int fattr3_to_vattr(vnode_t *, fattr3 *, struct vattr *); 2227 extern int nfs3tsize(void); 2228 extern uint_t nfs3_tsize(struct knetconfig *); 2229 extern uint_t rfs3_tsize(struct svc_req *); 2230 extern int vattr_to_sattr3(struct vattr *, sattr3 *); 2231 extern void setdiropargs3(diropargs3 *, char *, vnode_t *); 2232 extern enum nfsstat3 puterrno3(int); 2233 extern int geterrno3(enum nfsstat3); 2234 extern int nfs3init(int, char *); 2235 extern void nfs3fini(void); 2236 extern int nfs3_vfsinit(void); 2237 extern void nfs3_vfsfini(void); 2238 extern void vattr_to_post_op_attr(struct vattr *, post_op_attr *); 2239 extern void mblk_to_iov(mblk_t *, int, struct iovec *); 2240 extern int rfs_publicfh_mclookup(char *, vnode_t *, cred_t *, 2241 vnode_t **, struct exportinfo **, struct sec_ol *); 2242 extern int rfs_pathname(char *, vnode_t **, vnode_t **, 2243 vnode_t *, cred_t *, int); 2244 extern vtype_t nf3_to_vt[]; 2245 extern kstat_named_t *rfsproccnt_v3_ptr; 2246 extern vfsops_t *nfs3_vfsops; 2247 extern struct vnodeops *nfs3_vnodeops; 2248 extern const struct fs_operation_def nfs3_vnodeops_template[]; 2249 #ifdef DEBUG 2250 extern int rfs3_do_pre_op_attr; 2251 extern int rfs3_do_post_op_attr; 2252 extern int rfs3_do_post_op_fh3; 2253 #endif 2254 /* 2255 * Some servers do not properly update the attributes of the 2256 * directory when changes are made. To allow interoperability 2257 * with these broken servers, the nfs_disable_rddir_cache 2258 * parameter can be used to disable readdir response caching. 2259 */ 2260 extern int nfs_disable_rddir_cache; 2261 2262 /* 2263 * External functions called by the v2/v3 code into the v4 code 2264 */ 2265 extern void nfs4_clnt_init(void); 2266 extern void nfs4_clnt_fini(void); 2267 2268 /* 2269 * Does NFS4 server have a vnode delegated? TRUE if so, FALSE if not. 2270 */ 2271 extern bool_t rfs4_check_delegated(int mode, vnode_t *, bool_t trunc); 2272 /* 2273 * VOP_GETATTR call. If a NFS4 delegation is present on the supplied vnode 2274 * call back to the delegated client to get attributes for AT_MTIME and 2275 * AT_SIZE. Invoke VOP_GETATTR to get all other attributes or all attributes 2276 * if no delegation is present. 2277 */ 2278 extern int rfs4_delegated_getattr(vnode_t *, vattr_t *, int, cred_t *); 2279 extern void rfs4_hold_deleg_policy(void); 2280 extern void rfs4_rele_deleg_policy(void); 2281 2282 extern int do_xattr_exists_check(vnode_t *, ulong_t *, cred_t *); 2283 2284 #endif /* _KERNEL */ 2285 2286 #ifdef __cplusplus 2287 } 2288 #endif 2289 2290 #endif /* _NFS_NFS_H */ 2291