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-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  * 4. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  *      @(#)nfs.h       8.4 (Berkeley) 5/1/95
   33  * $FreeBSD$
   34  */
   35 
   36 #ifndef _NFSSERVER_NFS_H_
   37 #define _NFSSERVER_NFS_H_
   38 
   39 #ifdef _KERNEL
   40 #include "opt_nfs.h"
   41 #endif
   42 
   43 #include <nfs/nfssvc.h>
   44 
   45 /*
   46  * Tunable constants for nfs
   47  */
   48 
   49 #define NFS_TICKINTVL   10              /* Desired time for a tick (msec) */
   50 #define NFS_HZ          (hz / nfs_ticks) /* Ticks/sec */
   51 #define NFS_TIMEO       (1 * NFS_HZ)    /* Default timeout = 1 second */
   52 #define NFS_MINTIMEO    (1 * NFS_HZ)    /* Min timeout to use */
   53 #define NFS_MAXTIMEO    (60 * NFS_HZ)   /* Max timeout to backoff to */
   54 #define NFS_MINIDEMTIMEO (5 * NFS_HZ)   /* Min timeout for non-idempotent ops*/
   55 #define NFS_MAXUIDHASH  64              /* Max. # of hashed uid entries/mp */
   56 #ifndef NFS_GATHERDELAY
   57 #define NFS_GATHERDELAY         10      /* Default write gather delay (msec) */
   58 #endif
   59 #ifdef _KERNEL
   60 #define DIRBLKSIZ       512             /* XXX we used to use ufs's DIRBLKSIZ */
   61 #endif
   62 
   63 /*
   64  * Oddballs
   65  */
   66 #define NFS_SRVMAXDATA(n) \
   67                 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
   68                  NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
   69 
   70 /*
   71  * XXX
   72  * The B_INVAFTERWRITE flag should be set to whatever is required by the
   73  * buffer cache code to say "Invalidate the block after it is written back".
   74  */
   75 #define B_INVAFTERWRITE B_NOCACHE
   76 
   77 /*
   78  * The IO_METASYNC flag should be implemented for local filesystems.
   79  * (Until then, it is nothin at all.)
   80  */
   81 #ifndef IO_METASYNC
   82 #define IO_METASYNC     0
   83 #endif
   84 
   85 /* NFS state flags XXX -Wunused */
   86 #define NFSRV_SNDLOCK           0x01000000  /* Send socket lock */
   87 #define NFSRV_WANTSND           0x02000000  /* Want above */
   88 
   89 /*
   90  * Structures for the nfssvc(2) syscall.  Not that anyone but nfsd and
   91  * mount_nfs should ever try and use it.
   92  */
   93 
   94 /*
   95  * Add a socket to monitor for NFS requests.
   96  */
   97 struct nfsd_addsock_args {
   98         int     sock;           /* Socket to serve */
   99         caddr_t name;           /* Client addr for connection based sockets */
  100         int     namelen;        /* Length of name */
  101 };
  102 
  103 /*
  104  * Start processing requests.
  105  */
  106 struct nfsd_nfsd_args {
  107         const char *principal;  /* GSS-API service principal name */
  108         int     minthreads;     /* minimum service thread count */
  109         int     maxthreads;     /* maximum service thread count */
  110 };
  111 
  112 /*
  113  * XXX to allow amd to include nfs.h without nfsproto.h
  114  */
  115 #ifdef NFS_NPROCS
  116 #include <nfsserver/nfsrvstats.h>
  117 #endif
  118 
  119 /*
  120  * vfs.nfsrv sysctl(3) identifiers
  121  */
  122 #define NFS_NFSRVSTATS  1               /* struct: struct nfsrvstats */
  123 #define NFS_NFSPRIVPORT 2               /* int: prohibit nfs to resvports */
  124 
  125 #ifdef _KERNEL
  126 
  127 extern struct mtx nfsd_mtx;
  128 #define NFSD_LOCK_ASSERT()      mtx_assert(&nfsd_mtx, MA_OWNED)
  129 #define NFSD_UNLOCK_ASSERT()    mtx_assert(&nfsd_mtx, MA_NOTOWNED)
  130 #define NFSD_LOCK_DONTCARE()
  131 #define NFSD_LOCK()     mtx_lock(&nfsd_mtx)
  132 #define NFSD_UNLOCK()   mtx_unlock(&nfsd_mtx)
  133 
  134 #ifdef MALLOC_DECLARE
  135 MALLOC_DECLARE(M_NFSRVDESC);
  136 MALLOC_DECLARE(M_NFSD);
  137 #endif
  138 
  139 /* Forward declarations */
  140 struct nfssvc_sock;
  141 struct nfsrv_descript;
  142 struct uio;
  143 struct vattr;
  144 struct nameidata;
  145 
  146 extern struct callout nfsrv_callout;
  147 extern struct nfsrvstats nfsrvstats;
  148 
  149 extern int      nfsrv_ticks;
  150 extern int      nfsrvw_procrastinate;
  151 extern int      nfsrvw_procrastinate_v3;
  152 extern int      nfsrv_numnfsd;
  153 
  154 /* Various values converted to XDR form. */
  155 extern u_int32_t nfsrv_nfs_false, nfsrv_nfs_true, nfsrv_nfs_xdrneg1,
  156         nfsrv_nfs_prog;
  157 extern u_int32_t nfsrv_rpc_reply, nfsrv_rpc_msgdenied, nfsrv_rpc_mismatch,
  158         nfsrv_rpc_vers;
  159 extern u_int32_t nfsrv_rpc_auth_unix, nfsrv_rpc_msgaccepted, nfsrv_rpc_call,
  160         nfsrv_rpc_autherr;
  161 
  162 /* Procedure table data */
  163 extern const int        nfsrvv2_procid[NFS_NPROCS];
  164 extern const int        nfsrv_nfsv3_procid[NFS_NPROCS];
  165 extern int32_t (*nfsrv3_procs[NFS_NPROCS])(struct nfsrv_descript *nd,
  166                     struct nfssvc_sock *slp, struct mbuf **mreqp);
  167 
  168 /*
  169  * A list of nfssvc_sock structures is maintained with all the sockets
  170  * that require service by the nfsd.
  171  */
  172 #ifndef NFS_WDELAYHASHSIZ
  173 #define NFS_WDELAYHASHSIZ 16    /* and with this */
  174 #endif
  175 #define NWDELAYHASH(sock, f) \
  176         (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
  177 
  178 /*
  179  * This structure is used by the server for describing each request.
  180  */
  181 struct nfsrv_descript {
  182         struct mbuf             *nd_mrep;       /* Request mbuf list */
  183         struct mbuf             *nd_md;         /* Current dissect mbuf */
  184         struct mbuf             *nd_mreq;       /* Reply mbuf list */
  185         struct sockaddr         *nd_nam;        /* and socket addr */
  186         struct sockaddr         *nd_nam2;       /* return socket addr */
  187         caddr_t                 nd_dpos;        /* Current dissect pos */
  188         u_int32_t               nd_procnum;     /* RPC # */
  189         int                     nd_stable;      /* storage type */
  190         int                     nd_flag;        /* nd_flag */
  191         int                     nd_repstat;     /* Reply status */
  192         fhandle_t               nd_fh;          /* File handle */
  193         struct ucred            *nd_cr;         /* Credentials */
  194         int                     nd_credflavor;  /* Security flavor */
  195 };
  196 
  197 /* Bits for "nd_flag" */
  198 #define ND_NFSV3        0x08
  199 
  200 /*
  201  * Defines for WebNFS
  202  */
  203 
  204 #define WEBNFS_ESC_CHAR         '%'
  205 #define WEBNFS_SPECCHAR_START   0x80
  206 
  207 #define WEBNFS_NATIVE_CHAR      0x80
  208 /*
  209  * ..
  210  * Possibly more here in the future.
  211  */
  212 
  213 /*
  214  * Macro for converting escape characters in WebNFS pathnames.
  215  * Should really be in libkern.
  216  */
  217 
  218 #define HEXTOC(c) \
  219         ((c) >= 'a' ? ((c) - ('a' - 10)) : \
  220             ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '')))
  221 #define HEXSTRTOI(p) \
  222         ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
  223 
  224 #ifdef NFS_DEBUG
  225 
  226 extern int nfs_debug;
  227 #define NFS_DEBUG_ASYNCIO       1 /* asynchronous i/o */
  228 #define NFS_DEBUG_WG            2 /* server write gathering */
  229 #define NFS_DEBUG_RC            4 /* server request caching */
  230 
  231 #define NFS_DPF(cat, args)                                      \
  232         do {                                                    \
  233                 if (nfs_debug & NFS_DEBUG_##cat) printf args;   \
  234         } while (0)
  235 
  236 #else
  237 
  238 #define NFS_DPF(cat, args)
  239 
  240 #endif
  241 
  242 /*
  243  * The following flags can be passed to nfsrv_fhtovp() function.
  244  */
  245 /* Leave file system busy on success. */
  246 #define NFSRV_FLAG_BUSY         0x01
  247 
  248 struct mbuf *nfs_rephead(int, struct nfsrv_descript *, int, struct mbuf **,
  249             caddr_t *);
  250 void    nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
  251             struct nfs_fattr *);
  252 void    nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
  253             struct vattr *, struct mbuf **, char **);
  254 void    nfsm_srvpostopattr(struct nfsrv_descript *, int, struct vattr *,
  255             struct mbuf **, char **);
  256 int     nfs_namei(struct nameidata *, struct nfsrv_descript *, fhandle_t *,
  257             int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
  258             caddr_t *, struct vnode **, int, struct vattr *, int *, int);
  259 void    nfsm_adj(struct mbuf *, int, int);
  260 int     nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
  261 void    nfsrv_init(int);
  262 int     nfsrv_errmap(struct nfsrv_descript *, int);
  263 void    nfsrvw_sort(gid_t *, int);
  264 
  265 int     nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  266             struct mbuf **mrq);
  267 int     nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  268             struct mbuf **mrq);
  269 int     nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  270             struct mbuf **mrq);
  271 int     nfsrv_fhtovp(fhandle_t *, int, struct vnode **,
  272             struct nfsrv_descript *, struct nfssvc_sock *, struct sockaddr *,
  273             int *);
  274 int     nfsrv_setpublicfs(struct mount *, struct netexport *,
  275             struct export_args *);
  276 int     nfs_ispublicfh(fhandle_t *);
  277 int     nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  278             struct mbuf **mrq);
  279 int     nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  280             struct mbuf **mrq);
  281 int     nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  282             struct mbuf **mrq);
  283 int     nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  284             struct mbuf **mrq);
  285 int     nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  286             struct mbuf **mrq);
  287 int     nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  288             struct mbuf **mrq);
  289 int     nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  290             struct mbuf **mrq);
  291 int     nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  292             struct mbuf **mrq);
  293 int     nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  294             struct mbuf **mrq);
  295 int     nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  296             struct mbuf **mrq);
  297 int     nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  298             struct mbuf **mrq);
  299 int     nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  300             struct mbuf **mrq);
  301 int     nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  302             struct mbuf **mrq);
  303 int     nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  304             struct mbuf **mrq);
  305 int     nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  306             struct mbuf **mrq);
  307 int     nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  308             struct mbuf **mrq);
  309 int     nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  310             struct mbuf **mrq);
  311 int     nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  312             struct mbuf **mrq);
  313 int     nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  314             struct mbuf **mrq);
  315 int     nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
  316             struct mbuf **mrq);
  317 /*
  318  * #ifdef _SYS_SYSPROTO_H_ so that it is only defined when sysproto.h
  319  * has been included, so that "struct nfssvc_args" is defined.
  320  */
  321 #ifdef _SYS_SYSPROTO_H_
  322 int nfssvc_nfsserver(struct thread *, struct nfssvc_args *);
  323 #endif
  324 #endif  /* _KERNEL */
  325 
  326 #endif

Cache object: e7e01efb59a81f771e5bfde0bc60aca1


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