|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ ! 23: /* ! 24: * Copyright (c) 1989, 1993, 1995 ! 25: * The Regents of the University of California. All rights reserved. ! 26: * ! 27: * This code is derived from software contributed to Berkeley by ! 28: * Rick Macklem at The University of Guelph. ! 29: * ! 30: * Redistribution and use in source and binary forms, with or without ! 31: * modification, are permitted provided that the following conditions ! 32: * are met: ! 33: * 1. Redistributions of source code must retain the above copyright ! 34: * notice, this list of conditions and the following disclaimer. ! 35: * 2. Redistributions in binary form must reproduce the above copyright ! 36: * notice, this list of conditions and the following disclaimer in the ! 37: * documentation and/or other materials provided with the distribution. ! 38: * 3. All advertising materials mentioning features or use of this software ! 39: * must display the following acknowledgement: ! 40: * This product includes software developed by the University of ! 41: * California, Berkeley and its contributors. ! 42: * 4. Neither the name of the University nor the names of its contributors ! 43: * may be used to endorse or promote products derived from this software ! 44: * without specific prior written permission. ! 45: * ! 46: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 47: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 48: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 49: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 50: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 51: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 52: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 53: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 54: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 55: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 56: * SUCH DAMAGE. ! 57: * ! 58: * @(#)nfs.h 8.4 (Berkeley) 5/1/95 ! 59: * FreeBSD-Id: nfs.h,v 1.32 1997/10/12 20:25:38 phk Exp $ ! 60: */ ! 61: ! 62: #ifndef _NFS_NFS_H_ ! 63: #define _NFS_NFS_H_ ! 64: ! 65: /* ! 66: * Tunable constants for nfs ! 67: */ ! 68: ! 69: #define NFS_MAXIOVEC 34 ! 70: #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ ! 71: #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ ! 72: #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ ! 73: #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ ! 74: #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ ! 75: #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ ! 76: #define NFS_MAXREXMIT 100 /* Stop counting after this many */ ! 77: #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ ! 78: #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ ! 79: #define NFS_MAXGRPS 16 /* Max. size of groups list */ ! 80: #ifndef NFS_MINATTRTIMO ! 81: #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ ! 82: #endif ! 83: #ifndef NFS_MAXATTRTIMO ! 84: #define NFS_MAXATTRTIMO 60 ! 85: #endif ! 86: #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ ! 87: #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ ! 88: #define NFS_READDIRSIZE 8192 /* Def. readdir size */ ! 89: #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ ! 90: #define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */ ! 91: #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ ! 92: #define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */ ! 93: #define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */ ! 94: #ifndef NFS_GATHERDELAY ! 95: #define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */ ! 96: #endif ! 97: #define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */ ! 98: ! 99: /* ! 100: * Oddballs ! 101: */ ! 102: #define NMOD(a) ((a) % nfs_asyncdaemons) ! 103: #define NFS_CMPFH(n, f, s) \ ! 104: ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) ! 105: #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) ! 106: #define NFS_SRVMAXDATA(n) \ ! 107: (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \ ! 108: NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA) ! 109: ! 110: /* ! 111: * XXX ! 112: * The B_INVAFTERWRITE flag should be set to whatever is required by the ! 113: * buffer cache code to say "Invalidate the block after it is written back". ! 114: */ ! 115: #ifdef __FreeBSD__ ! 116: #define B_INVAFTERWRITE B_NOCACHE ! 117: #else ! 118: #define B_INVAFTERWRITE B_INVAL ! 119: #endif ! 120: ! 121: /* ! 122: * The IO_METASYNC flag should be implemented for local file systems. ! 123: * (Until then, it is nothin at all.) ! 124: */ ! 125: #ifndef IO_METASYNC ! 126: #define IO_METASYNC 0 ! 127: #endif ! 128: ! 129: /* ! 130: * Set the attribute timeout based on how recently the file has been modified. ! 131: */ ! 132: #define NFS_ATTRTIMEO(np) \ ! 133: ((((np)->n_flag & NMODIFIED) || \ ! 134: (time.tv_sec - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \ ! 135: ((time.tv_sec - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \ ! 136: (time.tv_sec - (np)->n_mtime) / 10)) ! 137: ! 138: /* ! 139: * Expected allocation sizes for major data structures. If the actual size ! 140: * of the structure exceeds these sizes, then malloc() will be allocating ! 141: * almost twice the memory required. This is used in nfs_init() to warn ! 142: * the sysadmin that the size of a structure should be reduced. ! 143: * (These sizes are always a power of 2. If the kernel malloc() changes ! 144: * to one that does not allocate space in powers of 2 size, then this all ! 145: * becomes bunk!) ! 146: */ ! 147: #define NFS_NODEALLOC 256 ! 148: #define NFS_MNTALLOC 512 ! 149: #define NFS_SVCALLOC 256 ! 150: #define NFS_UIDALLOC 128 ! 151: ! 152: /* ! 153: * Arguments to mount NFS ! 154: */ ! 155: #define NFS_ARGSVERSION 3 /* change when nfs_args changes */ ! 156: struct nfs_args { ! 157: int version; /* args structure version number */ ! 158: struct sockaddr *addr; /* file server address */ ! 159: int addrlen; /* length of address */ ! 160: int sotype; /* Socket type */ ! 161: int proto; /* and Protocol */ ! 162: u_char *fh; /* File handle to be mounted */ ! 163: int fhsize; /* Size, in bytes, of fh */ ! 164: int flags; /* flags */ ! 165: int wsize; /* write size in bytes */ ! 166: int rsize; /* read size in bytes */ ! 167: int readdirsize; /* readdir size in bytes */ ! 168: int timeo; /* initial timeout in .1 secs */ ! 169: int retrans; /* times to retry send */ ! 170: int maxgrouplist; /* Max. size of group list */ ! 171: int readahead; /* # of blocks to readahead */ ! 172: int leaseterm; /* Term (sec) of lease */ ! 173: int deadthresh; /* Retrans threshold */ ! 174: char *hostname; /* server's name */ ! 175: }; ! 176: ! 177: /* ! 178: * NFS mount option flags ! 179: */ ! 180: #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ ! 181: #define NFSMNT_WSIZE 0x00000002 /* set write size */ ! 182: #define NFSMNT_RSIZE 0x00000004 /* set read size */ ! 183: #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ ! 184: #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ ! 185: #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ ! 186: #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ ! 187: #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ ! 188: #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ ! 189: #define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ ! 190: #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ ! 191: #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ ! 192: #define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ ! 193: #define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ ! 194: #define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ ! 195: #define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ ! 196: #define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ ! 197: #define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ ! 198: #define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ ! 199: #define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ ! 200: #define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ ! 201: #define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ ! 202: #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ ! 203: #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ ! 204: #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ ! 205: #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ ! 206: #define NFSMNT_WANTSND 0x02000000 /* Want above */ ! 207: #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ ! 208: #define NFSMNT_WANTRCV 0x08000000 /* Want above */ ! 209: #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ ! 210: #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ ! 211: #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ ! 212: #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ ! 213: ! 214: /* ! 215: * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs ! 216: * should ever try and use it. ! 217: */ ! 218: struct nfsd_args { ! 219: int sock; /* Socket to serve */ ! 220: caddr_t name; /* Client addr for connection based sockets */ ! 221: int namelen; /* Length of name */ ! 222: }; ! 223: ! 224: struct nfsd_srvargs { ! 225: struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */ ! 226: uid_t nsd_uid; /* Effective uid mapped to cred */ ! 227: u_long nsd_haddr; /* Ip address of client */ ! 228: struct ucred nsd_cr; /* Cred. uid maps to */ ! 229: int nsd_authlen; /* Length of auth string (ret) */ ! 230: u_char *nsd_authstr; /* Auth string (ret) */ ! 231: int nsd_verflen; /* and the verfier */ ! 232: u_char *nsd_verfstr; ! 233: struct timeval nsd_timestamp; /* timestamp from verifier */ ! 234: u_long nsd_ttl; /* credential ttl (sec) */ ! 235: NFSKERBKEY_T nsd_key; /* Session key */ ! 236: }; ! 237: ! 238: struct nfsd_cargs { ! 239: char *ncd_dirp; /* Mount dir path */ ! 240: uid_t ncd_authuid; /* Effective uid */ ! 241: int ncd_authtype; /* Type of authenticator */ ! 242: int ncd_authlen; /* Length of authenticator string */ ! 243: u_char *ncd_authstr; /* Authenticator string */ ! 244: int ncd_verflen; /* and the verifier */ ! 245: u_char *ncd_verfstr; ! 246: NFSKERBKEY_T ncd_key; /* Session key */ ! 247: }; ! 248: ! 249: /* ! 250: * XXX to allow amd to include nfs.h without nfsproto.h ! 251: */ ! 252: #ifdef NFS_NPROCS ! 253: /* ! 254: * Stats structure ! 255: */ ! 256: struct nfsstats { ! 257: int attrcache_hits; ! 258: int attrcache_misses; ! 259: int lookupcache_hits; ! 260: int lookupcache_misses; ! 261: int direofcache_hits; ! 262: int direofcache_misses; ! 263: int biocache_reads; ! 264: int read_bios; ! 265: int read_physios; ! 266: int biocache_writes; ! 267: int write_bios; ! 268: int write_physios; ! 269: int biocache_readlinks; ! 270: int readlink_bios; ! 271: int biocache_readdirs; ! 272: int readdir_bios; ! 273: int rpccnt[NFS_NPROCS]; ! 274: int rpcretries; ! 275: int srvrpccnt[NFS_NPROCS]; ! 276: int srvrpc_errs; ! 277: int srv_errs; ! 278: int rpcrequests; ! 279: int rpctimeouts; ! 280: int rpcunexpected; ! 281: int rpcinvalid; ! 282: int srvcache_inproghits; ! 283: int srvcache_idemdonehits; ! 284: int srvcache_nonidemdonehits; ! 285: int srvcache_misses; ! 286: int srvnqnfs_leases; ! 287: int srvnqnfs_maxleases; ! 288: int srvnqnfs_getleases; ! 289: int srvvop_writes; ! 290: }; ! 291: #endif ! 292: ! 293: /* ! 294: * Flags for nfssvc() system call. ! 295: */ ! 296: #define NFSSVC_BIOD 0x002 ! 297: #define NFSSVC_NFSD 0x004 ! 298: #define NFSSVC_ADDSOCK 0x008 ! 299: #define NFSSVC_AUTHIN 0x010 ! 300: #define NFSSVC_GOTAUTH 0x040 ! 301: #define NFSSVC_AUTHINFAIL 0x080 ! 302: #define NFSSVC_MNTD 0x100 ! 303: ! 304: /* ! 305: * fs.nfs sysctl(3) identifiers ! 306: */ ! 307: #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ ! 308: #define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */ ! 309: ! 310: #define FS_NFS_NAMES { \ ! 311: { 0, 0 }, \ ! 312: { "nfsstats", CTLTYPE_STRUCT }, \ ! 313: { "nfsprivport", CTLTYPE_INT }, \ ! 314: } ! 315: ! 316: #ifndef NFS_MUIDHASHSIZ ! 317: #define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ ! 318: #endif ! 319: #ifndef NFS_WDELAYHASHSIZ ! 320: #define NFS_WDELAYHASHSIZ 16 /* and with this */ ! 321: #endif ! 322: ! 323: /* ! 324: * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. ! 325: * What should be in this set is open to debate, but I believe that since ! 326: * I/O system calls on ufs are never interrupted by signals the set should ! 327: * be minimal. My reasoning is that many current programs that use signals ! 328: * such as SIGALRM will not expect file I/O system calls to be interrupted ! 329: * by them and break. ! 330: */ ! 331: #ifdef KERNEL ! 332: ! 333: #ifdef MALLOC_DECLARE ! 334: MALLOC_DECLARE(M_NFSREQ); ! 335: MALLOC_DECLARE(M_NFSMNT); ! 336: MALLOC_DECLARE(M_NFSDIROFF); ! 337: MALLOC_DECLARE(M_NFSRVDESC); ! 338: MALLOC_DECLARE(M_NFSUID); ! 339: MALLOC_DECLARE(M_NQLEASE); ! 340: MALLOC_DECLARE(M_NFSD); ! 341: MALLOC_DECLARE(M_NFSBIGFH); ! 342: #endif ! 343: ! 344: struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ ! 345: ! 346: #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ ! 347: sigmask(SIGHUP)|sigmask(SIGQUIT)) ! 348: ! 349: /* ! 350: * Socket errors ignored for connectionless sockets?? ! 351: * For now, ignore them all ! 352: */ ! 353: #define NFSIGNORE_SOERROR(s, e) \ ! 354: ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ ! 355: ((s) & PR_CONNREQUIRED) == 0) ! 356: ! 357: /* ! 358: * Nfs outstanding request list element ! 359: */ ! 360: struct nfsreq { ! 361: TAILQ_ENTRY(nfsreq) r_chain; ! 362: struct mbuf *r_mreq; ! 363: struct mbuf *r_mrep; ! 364: struct mbuf *r_md; ! 365: caddr_t r_dpos; ! 366: struct nfsmount *r_nmp; ! 367: struct vnode *r_vp; ! 368: u_long r_xid; ! 369: int r_flags; /* flags on request, see below */ ! 370: int r_retry; /* max retransmission count */ ! 371: int r_rexmit; /* current retrans count */ ! 372: int r_timer; /* tick counter on reply */ ! 373: u_int32_t r_procnum; /* NFS procedure number */ ! 374: int r_rtt; /* RTT for rpc */ ! 375: struct proc *r_procp; /* Proc that did I/O system call */ ! 376: }; ! 377: ! 378: /* ! 379: * Queue head for nfsreq's ! 380: */ ! 381: extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; ! 382: ! 383: /* Flag values for r_flags */ ! 384: #define R_TIMING 0x01 /* timing request (in mntp) */ ! 385: #define R_SENT 0x02 /* request has been sent */ ! 386: #define R_SOFTTERM 0x04 /* soft mnt, too many retries */ ! 387: #define R_INTR 0x08 /* intr mnt, signal pending */ ! 388: #define R_SOCKERR 0x10 /* Fatal error on socket */ ! 389: #define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ ! 390: #define R_MUSTRESEND 0x40 /* Must resend request */ ! 391: #define R_GETONEREP 0x80 /* Probe for one reply only */ ! 392: ! 393: /* ! 394: * A list of nfssvc_sock structures is maintained with all the sockets ! 395: * that require service by the nfsd. ! 396: * The nfsuid structs hang off of the nfssvc_sock structs in both lru ! 397: * and uid hash lists. ! 398: */ ! 399: #ifndef NFS_UIDHASHSIZ ! 400: #define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ ! 401: #endif ! 402: #define NUIDHASH(sock, uid) \ ! 403: (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) ! 404: #define NWDELAYHASH(sock, f) \ ! 405: (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) ! 406: #define NMUIDHASH(nmp, uid) \ ! 407: (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) ! 408: #define NFSNOHASH(fhsum) \ ! 409: (&nfsnodehashtbl[(fhsum) & nfsnodehash]) ! 410: ! 411: /* ! 412: * Network address hash list element ! 413: */ ! 414: union nethostaddr { ! 415: u_long had_inetaddr; ! 416: struct mbuf *had_nam; ! 417: }; ! 418: ! 419: struct nfsuid { ! 420: TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ ! 421: LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ ! 422: int nu_flag; /* Flags */ ! 423: union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ ! 424: struct ucred nu_cr; /* Cred uid mapped to */ ! 425: int nu_expire; /* Expiry time (sec) */ ! 426: struct timeval nu_timestamp; /* Kerb. timestamp */ ! 427: u_long nu_nickname; /* Nickname on server */ ! 428: NFSKERBKEY_T nu_key; /* and session key */ ! 429: }; ! 430: ! 431: #define nu_inetaddr nu_haddr.had_inetaddr ! 432: #define nu_nam nu_haddr.had_nam ! 433: /* Bits for nu_flag */ ! 434: #define NU_INETADDR 0x1 ! 435: #define NU_NAM 0x2 ! 436: #define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) ! 437: ! 438: #ifdef notyet ! 439: /* XXX CSM 12/2/97 When/if we merge queue.h */ ! 440: struct nfsrv_rec { ! 441: STAILQ_ENTRY(nfsrv_rec) nr_link; ! 442: struct sockaddr *nr_address; ! 443: struct mbuf *nr_packet; ! 444: }; ! 445: #endif ! 446: ! 447: struct nfssvc_sock { ! 448: TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ ! 449: TAILQ_HEAD(, nfsuid) ns_uidlruhead; ! 450: struct file *ns_fp; ! 451: struct socket *ns_so; ! 452: struct mbuf *ns_nam; ! 453: struct mbuf *ns_raw; ! 454: struct mbuf *ns_rawend; ! 455: struct mbuf *ns_rec; ! 456: struct mbuf *ns_recend; ! 457: struct mbuf *ns_frag; ! 458: int ns_flag; ! 459: int ns_solock; ! 460: int ns_cc; ! 461: int ns_reclen; ! 462: int ns_numuids; ! 463: u_long ns_sref; ! 464: LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ ! 465: LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; ! 466: LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; ! 467: }; ! 468: ! 469: /* Bits for "ns_flag" */ ! 470: #define SLP_VALID 0x01 ! 471: #define SLP_DOREC 0x02 ! 472: #define SLP_NEEDQ 0x04 ! 473: #define SLP_DISCONN 0x08 ! 474: #define SLP_GETSTREAM 0x10 ! 475: #define SLP_LASTFRAG 0x20 ! 476: #define SLP_ALLFLAGS 0xff ! 477: ! 478: extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; ! 479: extern int nfssvc_sockhead_flag; ! 480: #define SLP_INIT 0x01 ! 481: #define SLP_WANTINIT 0x02 ! 482: ! 483: /* ! 484: * One of these structures is allocated for each nfsd. ! 485: */ ! 486: struct nfsd { ! 487: TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ ! 488: int nfsd_flag; /* NFSD_ flags */ ! 489: struct nfssvc_sock *nfsd_slp; /* Current socket */ ! 490: int nfsd_authlen; /* Authenticator len */ ! 491: u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ ! 492: int nfsd_verflen; /* and the Verifier */ ! 493: u_char nfsd_verfstr[RPCVERF_MAXSIZ]; ! 494: struct proc *nfsd_procp; /* Proc ptr */ ! 495: struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ ! 496: }; ! 497: ! 498: /* Bits for "nfsd_flag" */ ! 499: #define NFSD_WAITING 0x01 ! 500: #define NFSD_REQINPROG 0x02 ! 501: #define NFSD_NEEDAUTH 0x04 ! 502: #define NFSD_AUTHFAIL 0x08 ! 503: ! 504: /* ! 505: * This structure is used by the server for describing each request. ! 506: * Some fields are used only when write request gathering is performed. ! 507: */ ! 508: struct nfsrv_descript { ! 509: u_quad_t nd_time; /* Write deadline (usec) */ ! 510: off_t nd_off; /* Start byte offset */ ! 511: off_t nd_eoff; /* and end byte offset */ ! 512: LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ ! 513: LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ ! 514: LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ ! 515: struct mbuf *nd_mrep; /* Request mbuf list */ ! 516: struct mbuf *nd_md; /* Current dissect mbuf */ ! 517: struct mbuf *nd_mreq; /* Reply mbuf list */ ! 518: struct mbuf *nd_nam; /* and socket addr */ ! 519: struct mbuf *nd_nam2; /* return socket addr */ ! 520: caddr_t nd_dpos; /* Current dissect pos */ ! 521: u_int32_t nd_procnum; /* RPC # */ ! 522: int nd_stable; /* storage type */ ! 523: int nd_flag; /* nd_flag */ ! 524: int nd_len; /* Length of this write */ ! 525: int nd_repstat; /* Reply status */ ! 526: u_long nd_retxid; /* Reply xid */ ! 527: u_long nd_duration; /* Lease duration */ ! 528: struct timeval nd_starttime; /* Time RPC initiated */ ! 529: fhandle_t nd_fh; /* File handle */ ! 530: struct ucred nd_cr; /* Credentials */ ! 531: }; ! 532: ! 533: /* Bits for "nd_flag" */ ! 534: #define ND_READ LEASE_READ ! 535: #define ND_WRITE LEASE_WRITE ! 536: #define ND_CHECK 0x04 ! 537: #define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) ! 538: #define ND_NFSV3 0x08 ! 539: #define ND_NQNFS 0x10 ! 540: #define ND_KERBNICK 0x20 ! 541: #define ND_KERBFULL 0x40 ! 542: #define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) ! 543: ! 544: extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; ! 545: extern int nfsd_head_flag; ! 546: #define NFSD_CHECKSLP 0x01 ! 547: ! 548: /* ! 549: * These macros compare nfsrv_descript structures. ! 550: */ ! 551: #define NFSW_CONTIG(o, n) \ ! 552: ((o)->nd_eoff >= (n)->nd_off && \ ! 553: !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) ! 554: ! 555: #define NFSW_SAMECRED(o, n) \ ! 556: (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ ! 557: !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ ! 558: sizeof (struct ucred))) ! 559: ! 560: /* ! 561: * Defines for WebNFS ! 562: */ ! 563: ! 564: #define WEBNFS_ESC_CHAR '%' ! 565: #define WEBNFS_SPECCHAR_START 0x80 ! 566: ! 567: #define WEBNFS_NATIVE_CHAR 0x80 ! 568: /* ! 569: * .. ! 570: * Possibly more here in the future. ! 571: */ ! 572: ! 573: /* ! 574: * Macro for converting escape characters in WebNFS pathnames. ! 575: * Should really be in libkern. ! 576: */ ! 577: ! 578: #define HEXTOC(c) \ ! 579: ((c) >= 'a' ? ((c) - ('a' - 10)) : \ ! 580: ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0'))) ! 581: #define HEXSTRTOI(p) \ ! 582: ((HEXTOC(p[0]) << 4) + HEXTOC(p[1])) ! 583: ! 584: #if DIAGNOSTIC ! 585: ! 586: extern int nfs_debug; ! 587: #define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */ ! 588: #define NFS_DEBUG_WG 2 /* server write gathering */ ! 589: #define NFS_DEBUG_RC 4 /* server request caching */ ! 590: #define NFS_DEBUG_SILLY 8 /* nfs_sillyrename (.nfsXXX aka turd files) */ ! 591: #define NFS_DEBUG_DUP 16 /* debug duplicate requests */ ! 592: #define NFS_DEBUG_ATTR 32 ! 593: ! 594: #define NFS_DPF(cat, args) \ ! 595: do { \ ! 596: if (nfs_debug & NFS_DEBUG_##cat) kprintf args; \ ! 597: } while (0) ! 598: ! 599: #else ! 600: ! 601: #define NFS_DPF(cat, args) ! 602: ! 603: #endif ! 604: ! 605: int nfs_init __P((struct vfsconf *vfsp)); ! 606: int nfs_reply __P((struct nfsreq *)); ! 607: int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); ! 608: int nfs_send __P((struct socket *, struct mbuf *, struct mbuf *, ! 609: struct nfsreq *)); ! 610: int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *, ! 611: int, int, u_quad_t *, struct mbuf **, struct mbuf **, ! 612: caddr_t *)); ! 613: int nfs_sndlock __P((int *, struct nfsreq *)); ! 614: void nfs_sndunlock __P((int *flagp)); ! 615: int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); ! 616: int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, ! 617: int)); ! 618: int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *)); ! 619: int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *, ! 620: int *)); ! 621: int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *)); ! 622: int nfs_asyncio __P((struct buf *, struct ucred *)); ! 623: int nfs_doio __P((struct buf *, struct ucred *, struct proc *)); ! 624: int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *)); ! 625: int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *)); ! 626: int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *)); ! 627: int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *)); ! 628: void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *, ! 629: struct nfs_fattr *)); ! 630: void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int, ! 631: struct vattr *, struct mbuf **, char **)); ! 632: void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *, ! 633: struct mbuf **, char **)); ! 634: int netaddr_match __P((int, union nethostaddr *, struct mbuf *)); ! 635: int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *, ! 636: struct ucred *, struct mbuf **, struct mbuf **, ! 637: caddr_t *)); ! 638: int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *, ! 639: struct vattr *)); ! 640: int nfs_namei __P((struct nameidata *, fhandle_t *, int, ! 641: struct nfssvc_sock *, struct mbuf *, struct mbuf **, ! 642: caddr_t *, struct vnode **, struct proc *, int, int)); ! 643: void nfsm_adj __P((struct mbuf *, int, int)); ! 644: int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *)); ! 645: void nfsrv_initcache __P((void)); ! 646: int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *, ! 647: char **, int *, char *, int *, NFSKERBKEY_T)); ! 648: int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **, ! 649: int *, char *, int)); ! 650: int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int, ! 651: NFSKERBKEY_T, struct mbuf **, char **, ! 652: struct mbuf *)); ! 653: int nfs_adv __P((struct mbuf **, caddr_t *, int, int)); ! 654: void nfs_nhinit __P((void)); ! 655: void nfs_timer __P((void*)); ! 656: u_long nfs_hash __P((nfsfh_t *, int)); ! 657: int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *, ! 658: struct nfsrv_descript **)); ! 659: int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *, ! 660: struct mbuf **)); ! 661: void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *)); ! 662: void nfsrv_cleancache __P((void)); ! 663: int nfs_connect __P((struct nfsmount *, struct nfsreq *)); ! 664: void nfs_disconnect __P((struct nfsmount *)); ! 665: int nfs_getattrcache __P((struct vnode *, struct vattr *)); ! 666: int nfsm_strtmbuf __P((struct mbuf **, char **, char *, long)); ! 667: int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *, ! 668: int)); ! 669: int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *)); ! 670: void nfsrv_init __P((int)); ! 671: void nfs_clearcommit __P((struct mount *)); ! 672: int nfsrv_errmap __P((struct nfsrv_descript *, int)); ! 673: void nfsrvw_sort __P((gid_t *, int)); ! 674: void nfsrv_setcred __P((struct ucred *, struct ucred *)); ! 675: int nfs_writebp __P((struct buf *, int)); ! 676: int nfsrv_object_create __P((struct vnode *)); ! 677: void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); ! 678: int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, ! 679: struct proc *, struct mbuf **)); ! 680: int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, ! 681: struct proc *p)); ! 682: ! 683: int nfsrv3_access __P((struct nfsrv_descript *nfsd, ! 684: struct nfssvc_sock *slp, ! 685: struct proc *procp, struct mbuf **mrq)); ! 686: int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 687: struct proc *procp, struct mbuf **mrq)); ! 688: int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 689: struct proc *procp, struct mbuf **mrq)); ! 690: int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, ! 691: struct nfssvc_sock *, struct mbuf *, int *, ! 692: int, int)); ! 693: int nfsrv_setpublicfs __P((struct mount *, struct netexport *, ! 694: struct export_args *)); ! 695: int nfs_ispublicfh __P((fhandle_t *)); ! 696: int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 697: struct proc *procp, struct mbuf **mrq)); ! 698: int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 699: struct proc *procp, struct mbuf **mrq)); ! 700: int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 701: struct proc *procp, struct mbuf **mrq)); ! 702: int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 703: struct proc *procp, struct mbuf **mrq)); ! 704: int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 705: struct proc *procp, struct mbuf **mrq)); ! 706: int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 707: struct proc *procp, struct mbuf **mrq)); ! 708: int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 709: struct proc *procp, struct mbuf **mrq)); ! 710: int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 711: struct proc *procp, struct mbuf **mrq)); ! 712: int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, ! 713: struct nfssvc_sock *slp, struct proc *procp, ! 714: struct mbuf **mrq)); ! 715: int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 716: struct proc *procp, struct mbuf **mrq)); ! 717: int nfsrv_readdir __P((struct nfsrv_descript *nfsd, ! 718: struct nfssvc_sock *slp, ! 719: struct proc *procp, struct mbuf **mrq)); ! 720: int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, ! 721: struct nfssvc_sock *slp, struct proc *procp, ! 722: struct mbuf **mrq)); ! 723: int nfsrv_readlink __P((struct nfsrv_descript *nfsd, ! 724: struct nfssvc_sock *slp, struct proc *procp, ! 725: struct mbuf **mrq)); ! 726: int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 727: struct proc *procp, struct mbuf **mrq)); ! 728: int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 729: struct proc *procp, struct mbuf **mrq)); ! 730: int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 731: struct proc *procp, struct mbuf **mrq)); ! 732: int nfsrv_setattr __P((struct nfsrv_descript *nfsd, ! 733: struct nfssvc_sock *slp, ! 734: struct proc *procp, struct mbuf **mrq)); ! 735: int nfsrv_statfs __P((struct nfsrv_descript *nfsd, ! 736: struct nfssvc_sock *slp, ! 737: struct proc *procp, struct mbuf **mrq)); ! 738: int nfsrv_symlink __P((struct nfsrv_descript *nfsd, ! 739: struct nfssvc_sock *slp, ! 740: struct proc *procp, struct mbuf **mrq)); ! 741: int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, ! 742: struct proc *procp, struct mbuf **mrq)); ! 743: void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); ! 744: void nfsrv_slpderef __P((struct nfssvc_sock *slp)); ! 745: ! 746: #if DIAGNOSTIC ! 747: ! 748: #include <sys/time.h> ! 749: #include <kern/clock.h> ! 750: ! 751: extern uint nfstraceindx; ! 752: #define NFSTBUFSIZ 4096 ! 753: struct nfstracerec { uint i1, i2, i3, i4; }; ! 754: extern struct nfstracerec nfstracebuf[NFSTBUFSIZ]; ! 755: extern uint nfstracemask; /* 32 bits - trace points over 31 are unconditional */ ! 756: ! 757: /* 0x0000000f nfs_getattrcache trace points */ ! 758: #define NFSTRC_GAC_MISS 0x00 /* 0x00000001 cache miss */ ! 759: #define NFSTRC_GAC_HIT 0x01 /* 0x00000002 cache hit */ ! 760: #define NFSTRC_GAC_NP 0x02 /* 0x00000004 np size mismatch - vp... */ ! 761: #define NFSTRC_GAC_MAP 0x03 /* 0x00000008 Mapped size mismatch - vp... */ ! 762: /* 0x000000f0 nfs_loadattrcache trace points */ ! 763: #define NFSTRC_LAC 0x04 /* 0x00000010 function entry point - vp */ ! 764: #define NFSTRC_LAC_INIT 0x05 /* 0x00000020 new vp & init n_mtime - vp */ ! 765: #define NFSTRC_LAC_NP 0x06 /* 0x00000040 np size mismatch - vp... */ ! 766: #define NFSTRC_LAC_MAP 0x07 /* 0x00000080 Mapped size mismatch - vp... */ ! 767: /* 0x00000300 nfs_getattr trace points */ ! 768: #define NFSTRC_GA_INV 0x08 /* 0x00000100 times mismatch - vp */ ! 769: #define NFSTRC_GA_INV1 0x09 /* 0x00000200 invalidate ok - vp */ ! 770: /* 0x00004000 vmp_invalidate trace points */ ! 771: #define NFSTRC_VMP_INV 0x0e /* 0x00004000 function entry point - vmp */ ! 772: /* 0x00008000 nfs_request trace points */ ! 773: #define NFSTRC_REQ 0x0f /* 0x00008000 - alternates vp and procnum */ ! 774: /* 0x00030000 vmp_push_range trace points */ ! 775: #define NFSTRC_VPR 0x10 /* 0x00010000 entry point - vp... */ ! 776: #define NFSTRC_VPR_DONE 0x11 /* 0x00020000 tail exit - error # */ ! 777: /* 0x000c0000 nfs_doio trace points */ ! 778: #define NFSTRC_DIO 0x12 /* 0x00040000 entry point - vp */ ! 779: #define NFSTRC_DIO_DONE 0x13 /* 0x00080000 exit points - vp */ ! 780: /* 0x00300000 mapfs_io trace points */ ! 781: #define NFSTRC_MIO_WRT 0x14 /* 0x00100000 Write - vp... */ ! 782: #define NFSTRC_MIO_READ 0x15 /* 0x00200000 Read - vp... */ ! 783: /* 0x0f000000 mapfs_trunc trace points */ ! 784: #define NFSTRC_MTR 0x18 /* 0x01000000 mapfs_trunc - vp... */ ! 785: #define NFSTRC_MTR_MREM 0x19 /* 0x02000000 ditto, map_remove - vp... */ ! 786: #define NFSTRC_MTR_RMAP 0x1a /* 0x04000000 ditto, remap_vnode - vp... */ ! 787: #define NFSTRC_MTR_DIRT 0x1b /* 0x08000000 ditto, nfsdirty - vmp->va */ ! 788: /* 0xf0000000 nfs_rcvlock & nfs_rcvunlock trace points */ ! 789: #define NFSTRC_RCVLCKW 0x1c /* 0x10000000 seeking recieve lock (waiting) */ ! 790: #define NFSTRC_RCVLCK 0x1d /* 0x20000000 getting recieve lock */ ! 791: #define NFSTRC_RCVUNLW 0x1e /* 0x40000000 releasing rcv lock w/ wakeup */ ! 792: #define NFSTRC_RCVUNL 0x1f /* 0x80000000 releasing rcv lock w/o wakeup */ ! 793: /* trace points beyond 31 are unconditional */ ! 794: #define NFSTRC_GA_INV2 0x20 /* nfs_getattr invalidate - error# */ ! 795: #define NFSTRC_MTR_BZER 0x30 /* mapfs_trunc safe_bzero error - vp... */ ! 796: #define NFSTRC_MIO_RINV 0x40 /* mapfs_io Read INValidating */ ! 797: #define NFSTRC_CONTINUE 0xff /* continuation record for previous entry */ ! 798: ! 799: #define NFSTRACEX(a1, a2, a3, a4) \ ! 800: ( \ ! 801: nfstracebuf[nfstraceindx].i1 = (uint)(a1), \ ! 802: nfstracebuf[nfstraceindx].i2 = (uint)(a2), \ ! 803: nfstracebuf[nfstraceindx].i3 = (uint)(a3), \ ! 804: nfstracebuf[nfstraceindx].i4 = (uint)(a4), \ ! 805: nfstraceindx = (nfstraceindx + 1) % NFSTBUFSIZ, \ ! 806: 1 \ ! 807: ) ! 808: ! 809: #define NFSTRACE(cnst, fptr) \ ! 810: ( \ ! 811: ((cnst) > 31 || nfstracemask & 1<<(cnst)) ? \ ! 812: NFSTRACEX((cnst), (fptr), current_thread(), \ ! 813: clock_get_system_value().tv_nsec) : \ ! 814: 0 \ ! 815: ) ! 816: ! 817: #define NFSTRACE4(cnst, fptr, a2, a3, a4) \ ! 818: ( \ ! 819: NFSTRACE(cnst,fptr) ? \ ! 820: NFSTRACEX(NFSTRC_CONTINUE, a2, a3, a4) : \ ! 821: 0 \ ! 822: ) ! 823: ! 824: #else /* DIAGNOSTIC */ ! 825: ! 826: #define NFSTRACE(cnst, fptr) ! 827: #define NFSTRACE4(cnst, fptr, a2, a3, a4) ! 828: ! 829: #endif /* DIAGNOSTIC */ ! 830: ! 831: #endif /* KERNEL */ ! 832: ! 833: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.