The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/nfs/nfs.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: b09fa22a0252aa60c83d6924b901d214


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.