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/nfsserver/nfs.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
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: releng/5.2/sys/nfsserver/nfs.h 115301 2003-05-25 06:17:33Z truckman $
   38  */
   39 
   40 #ifndef _NFSSERVER_NFS_H_
   41 #define _NFSSERVER_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_TICKINTVL   5               /* Desired time for a tick (msec) */
   52 #define NFS_HZ          (hz / nfs_ticks) /* Ticks/sec */
   53 #define NFS_TIMEO       (1 * NFS_HZ)    /* Default timeout = 1 second */
   54 #define NFS_MINTIMEO    (1 * NFS_HZ)    /* Min timeout to use */
   55 #define NFS_MAXTIMEO    (60 * NFS_HZ)   /* Max timeout to backoff to */
   56 #define NFS_MINIDEMTIMEO (5 * NFS_HZ)   /* Min timeout for non-idempotent ops*/
   57 #define NFS_MAXUIDHASH  64              /* Max. # of hashed uid entries/mp */
   58 #ifndef NFS_GATHERDELAY
   59 #define NFS_GATHERDELAY         10      /* Default write gather delay (msec) */
   60 #endif
   61 #ifdef _KERNEL
   62 #define DIRBLKSIZ       512             /* XXX we used to use ufs's DIRBLKSIZ */
   63 #endif
   64 
   65 /*
   66  * Oddballs
   67  */
   68 #define NFS_SRVMAXDATA(n) \
   69                 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
   70                  NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
   71 
   72 /*
   73  * XXX
   74  * The B_INVAFTERWRITE flag should be set to whatever is required by the
   75  * buffer cache code to say "Invalidate the block after it is written back".
   76  */
   77 #define B_INVAFTERWRITE B_NOCACHE
   78 
   79 /*
   80  * The IO_METASYNC flag should be implemented for local filesystems.
   81  * (Until then, it is nothin at all.)
   82  */
   83 #ifndef IO_METASYNC
   84 #define IO_METASYNC     0
   85 #endif
   86 
   87 
   88 /* NFS state flags XXX -Wunused */
   89 #define NFSRV_SNDLOCK           0x01000000  /* Send socket lock */
   90 #define NFSRV_WANTSND           0x02000000  /* Want above */
   91 
   92 /*
   93  * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
   94  * should ever try and use it.
   95  */
   96 struct nfsd_args {
   97         int     sock;           /* Socket to serve */
   98         caddr_t name;           /* Client addr for connection based sockets */
   99         int     namelen;        /* Length of name */
  100 };
  101 
  102 /*
  103  * XXX to allow amd to include nfs.h without nfsproto.h
  104  */
  105 #ifdef NFS_NPROCS
  106 #include <nfsserver/nfsrvstats.h>
  107 #endif
  108 
  109 /*
  110  * Flags for nfssvc() system call.
  111  */
  112 #define NFSSVC_NFSD     0x004
  113 #define NFSSVC_ADDSOCK  0x008
  114 
  115 /*
  116  * vfs.nfsrv sysctl(3) identifiers
  117  */
  118 #define NFS_NFSRVSTATS  1               /* struct: struct nfsrvstats */
  119 #define NFS_NFSPRIVPORT 2               /* int: prohibit nfs to resvports */
  120 
  121 #ifdef _KERNEL
  122 
  123 #ifdef MALLOC_DECLARE
  124 MALLOC_DECLARE(M_NFSRVDESC);
  125 MALLOC_DECLARE(M_NFSD);
  126 #endif
  127 
  128 /* Forward declarations */
  129 struct nfssvc_sock;
  130 struct nfsrv_descript;
  131 struct uio;
  132 struct vattr;
  133 struct nameidata;
  134 
  135 extern struct callout_handle nfsrv_timer_handle;
  136 extern struct nfsrvstats nfsrvstats;
  137 
  138 extern int      nfsrv_ticks;
  139 extern int      nfsrvw_procrastinate;
  140 extern int      nfsrvw_procrastinate_v3;
  141 
  142 /* Various values converted to XDR form. */
  143 extern u_int32_t nfsrv_nfs_false, nfsrv_nfs_true, nfsrv_nfs_xdrneg1,
  144         nfsrv_nfs_prog;
  145 extern u_int32_t nfsrv_rpc_reply, nfsrv_rpc_msgdenied, nfsrv_rpc_mismatch,
  146         nfsrv_rpc_vers;
  147 extern u_int32_t nfsrv_rpc_auth_unix, nfsrv_rpc_msgaccepted, nfsrv_rpc_call,
  148         nfsrv_rpc_autherr;
  149 
  150 /* Procedure table data */
  151 extern int      nfsrvv2_procid[NFS_NPROCS];
  152 extern int      nfsrv_nfsv3_procid[NFS_NPROCS];
  153 extern int32_t (*nfsrv3_procs[NFS_NPROCS])(struct nfsrv_descript *nd,
  154                     struct nfssvc_sock *slp, struct thread *td,
  155                     struct mbuf **mreqp);
  156 
  157 /*
  158  * A list of nfssvc_sock structures is maintained with all the sockets
  159  * that require service by the nfsd.
  160  */
  161 #ifndef NFS_WDELAYHASHSIZ
  162 #define NFS_WDELAYHASHSIZ 16    /* and with this */
  163 #endif
  164 #define NWDELAYHASH(sock, f) \
  165         (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
  166 
  167 /*
  168  * Network address hash list element
  169  */
  170 union nethostaddr {
  171         u_int32_t had_inetaddr;
  172         struct sockaddr *had_nam;
  173 };
  174 
  175 struct nfsrv_rec {
  176         STAILQ_ENTRY(nfsrv_rec) nr_link;
  177         struct sockaddr *nr_address;
  178         struct mbuf     *nr_packet;
  179 };
  180 
  181 struct nfssvc_sock {
  182         TAILQ_ENTRY(nfssvc_sock) ns_chain;      /* List of all nfssvc_sock's */
  183         struct file     *ns_fp;
  184         struct socket   *ns_so;
  185         struct sockaddr *ns_nam;
  186         struct mbuf     *ns_raw;
  187         struct mbuf     *ns_rawend;
  188         STAILQ_HEAD(, nfsrv_rec) ns_rec;
  189         struct mbuf     *ns_frag;
  190         int             ns_flag;
  191         int             ns_solock;
  192         int             ns_cc;
  193         int             ns_reclen;
  194         u_int32_t       ns_sref;
  195         LIST_HEAD(, nfsrv_descript) ns_tq;      /* Write gather lists */
  196         LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
  197 };
  198 
  199 /* Bits for "ns_flag" */
  200 #define SLP_VALID       0x01
  201 #define SLP_DOREC       0x02
  202 #define SLP_NEEDQ       0x04
  203 #define SLP_DISCONN     0x08
  204 #define SLP_GETSTREAM   0x10
  205 #define SLP_LASTFRAG    0x20
  206 #define SLP_ALLFLAGS    0xff
  207 
  208 extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
  209 extern int nfssvc_sockhead_flag;
  210 #define SLP_INIT        0x01
  211 #define SLP_WANTINIT    0x02
  212 
  213 /*
  214  * One of these structures is allocated for each nfsd.
  215  */
  216 struct nfsd {
  217         TAILQ_ENTRY(nfsd) nfsd_chain;   /* List of all nfsd's */
  218         int             nfsd_flag;      /* NFSD_ flags */
  219         struct nfssvc_sock *nfsd_slp;   /* Current socket */
  220         int             nfsd_authlen;   /* Authenticator len */
  221         u_char          nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
  222         int             nfsd_verflen;   /* and the Verifier */
  223         u_char          nfsd_verfstr[RPCVERF_MAXSIZ];
  224         struct thread   *nfsd_td;       /* daemon thread ptr */
  225         struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
  226 };
  227 
  228 /* Bits for "nfsd_flag" */
  229 #define NFSD_WAITING    0x01
  230 #define NFSD_REQINPROG  0x02
  231 
  232 /*
  233  * This structure is used by the server for describing each request.
  234  * Some fields are used only when write request gathering is performed.
  235  */
  236 struct nfsrv_descript {
  237         u_quad_t                nd_time;        /* Write deadline (usec) */
  238         off_t                   nd_off;         /* Start byte offset */
  239         off_t                   nd_eoff;        /* and end byte offset */
  240         LIST_ENTRY(nfsrv_descript) nd_hash;     /* Hash list */
  241         LIST_ENTRY(nfsrv_descript) nd_tq;       /* and timer list */
  242         LIST_HEAD(, nfsrv_descript) nd_coalesce;/* coalesced writes */
  243         struct mbuf             *nd_mrep;       /* Request mbuf list */
  244         struct mbuf             *nd_md;         /* Current dissect mbuf */
  245         struct mbuf             *nd_mreq;       /* Reply mbuf list */
  246         struct sockaddr         *nd_nam;        /* and socket addr */
  247         struct sockaddr         *nd_nam2;       /* return socket addr */
  248         caddr_t                 nd_dpos;        /* Current dissect pos */
  249         u_int32_t               nd_procnum;     /* RPC # */
  250         int                     nd_stable;      /* storage type */
  251         int                     nd_flag;        /* nd_flag */
  252         int                     nd_len;         /* Length of this write */
  253         int                     nd_repstat;     /* Reply status */
  254         u_int32_t               nd_retxid;      /* Reply xid */
  255         struct timeval          nd_starttime;   /* Time RPC initiated */
  256         fhandle_t               nd_fh;          /* File handle */
  257         struct ucred            nd_cr;          /* Credentials */
  258 };
  259 
  260 /* Bits for "nd_flag" */
  261 #define ND_NFSV3        0x08
  262 
  263 extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
  264 extern int nfsd_head_flag;
  265 #define NFSD_CHECKSLP   0x01
  266 
  267 /*
  268  * These macros compare nfsrv_descript structures.
  269  */
  270 #define NFSW_CONTIG(o, n) \
  271                 ((o)->nd_eoff >= (n)->nd_off && \
  272                  !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
  273 
  274 #define NFSW_SAMECRED(o, n) \
  275         (!bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
  276                 sizeof (struct ucred)))
  277 
  278 /*
  279  * Defines for WebNFS
  280  */
  281 
  282 #define WEBNFS_ESC_CHAR         '%'
  283 #define WEBNFS_SPECCHAR_START   0x80
  284 
  285 #define WEBNFS_NATIVE_CHAR      0x80
  286 /*
  287  * ..
  288  * Possibly more here in the future.
  289  */
  290 
  291 /*
  292  * Macro for converting escape characters in WebNFS pathnames.
  293  * Should really be in libkern.
  294  */
  295 
  296 #define HEXTOC(c) \
  297         ((c) >= 'a' ? ((c) - ('a' - 10)) : \
  298             ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '')))
  299 #define HEXSTRTOI(p) \
  300         ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
  301 
  302 #ifdef NFS_DEBUG
  303 
  304 extern int nfs_debug;
  305 #define NFS_DEBUG_ASYNCIO       1 /* asynchronous i/o */
  306 #define NFS_DEBUG_WG            2 /* server write gathering */
  307 #define NFS_DEBUG_RC            4 /* server request caching */
  308 
  309 #define NFS_DPF(cat, args)                                      \
  310         do {                                                    \
  311                 if (nfs_debug & NFS_DEBUG_##cat) printf args;   \
  312         } while (0)
  313 
  314 #else
  315 
  316 #define NFS_DPF(cat, args)
  317 
  318 #endif
  319 
  320 int     nfs_getreq(struct nfsrv_descript *, struct nfsd *, int);
  321 int     nfsrv_send(struct socket *, struct sockaddr *, struct mbuf *);
  322 struct mbuf *nfs_rephead(int, struct nfsrv_descript *, int, struct mbuf **,
  323             caddr_t *);
  324 int     nfs_slplock(struct nfssvc_sock *, int);
  325 void    nfs_slpunlock(struct nfssvc_sock *);
  326 void    nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
  327             struct nfs_fattr *);
  328 void    nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
  329             struct vattr *, struct mbuf **, char **);
  330 void    nfsm_srvpostopattr(struct nfsrv_descript *, int, struct vattr *,
  331             struct mbuf **, char **);
  332 int     netaddr_match(int, union nethostaddr *, struct sockaddr *);
  333 int     nfs_namei(struct nameidata *, fhandle_t *, int,
  334             struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
  335             caddr_t *, struct vnode **, int, struct vattr *, int *,
  336             struct thread *, int);
  337 void    nfsm_adj(struct mbuf *, int, int);
  338 int     nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
  339 void    nfsrv_initcache(void);
  340 void    nfsrv_timer(void *);
  341 int     nfsrv_dorec(struct nfssvc_sock *, struct nfsd *,
  342             struct nfsrv_descript **);
  343 int     nfsrv_getcache(struct nfsrv_descript *, struct mbuf **);
  344 void    nfsrv_updatecache(struct nfsrv_descript *, int, struct mbuf *);
  345 void    nfsrv_cleancache(void);
  346 void    nfsrv_init(int);
  347 int     nfsrv_errmap(struct nfsrv_descript *, int);
  348 void    nfsrvw_sort(gid_t *, int);
  349 void    nfsrv_setcred(struct ucred *, struct ucred *);
  350 int     nfsrv_object_create(struct vnode *);
  351 void    nfsrv_wakenfsd(struct nfssvc_sock *slp);
  352 int     nfsrv_writegather(struct nfsrv_descript **, struct nfssvc_sock *,
  353             struct thread *, struct mbuf **);
  354 
  355 int     nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  356             struct thread *td, struct mbuf **mrq);
  357 int     nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  358             struct thread *td, struct mbuf **mrq);
  359 int     nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  360             struct thread *td, struct mbuf **mrq);
  361 int     nfsrv_fhtovp(fhandle_t *, int, struct vnode **, struct ucred *,
  362             struct nfssvc_sock *, struct sockaddr *, int *, int);
  363 int     nfsrv_setpublicfs(struct mount *, struct netexport *,
  364             struct export_args *);
  365 int     nfs_ispublicfh(fhandle_t *);
  366 int     nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  367             struct thread *td, struct mbuf **mrq);
  368 int     nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  369             struct thread *td, struct mbuf **mrq);
  370 int     nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  371             struct thread *td, struct mbuf **mrq);
  372 int     nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  373             struct thread *td, struct mbuf **mrq);
  374 int     nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  375             struct thread *td, struct mbuf **mrq);
  376 int     nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  377             struct thread *td, struct mbuf **mrq);
  378 int     nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  379             struct thread *td, struct mbuf **mrq);
  380 int     nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  381             struct thread *td, struct mbuf **mrq);
  382 int     nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  383             struct thread *td, struct mbuf **mrq);
  384 int     nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  385             struct thread *td, struct mbuf **mrq);
  386 int     nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  387             struct thread *td, struct mbuf **mrq);
  388 int     nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  389             struct thread *td, struct mbuf **mrq);
  390 int     nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  391             struct thread *td, struct mbuf **mrq);
  392 int     nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  393             struct thread *td, struct mbuf **mrq);
  394 int     nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  395             struct thread *td, struct mbuf **mrq);
  396 int     nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  397             struct thread *td, struct mbuf **mrq);
  398 int     nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  399             struct thread *td, struct mbuf **mrq);
  400 int     nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  401             struct thread *td, struct mbuf **mrq);
  402 int     nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  403             struct thread *td, struct mbuf **mrq);
  404 int     nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  405             struct thread *td, struct mbuf **mrq);
  406 void    nfsrv_rcv(struct socket *so, void *arg, int waitflag);
  407 void    nfsrv_slpderef(struct nfssvc_sock *slp);
  408 #endif  /* _KERNEL */
  409 
  410 #endif

Cache object: dfb0eb3e89dc8ef30f5a60ac7d627277


[ 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.