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