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