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/fs/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
    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  * $FreeBSD$
   33  */
   34 
   35 #ifndef _NFS_NFS_H_
   36 #define _NFS_NFS_H_
   37 /*
   38  * Tunable constants for nfs
   39  */
   40 
   41 #define NFS_MAXIOVEC    34
   42 #define NFS_TICKINTVL   500             /* Desired time for a tick (msec) */
   43 #define NFS_HZ          (hz / nfscl_ticks) /* Ticks/sec */
   44 #define NFS_TIMEO       (1 * NFS_HZ)    /* Default timeout = 1 second */
   45 #define NFS_MINTIMEO    (1 * NFS_HZ)    /* Min timeout to use */
   46 #define NFS_MAXTIMEO    (60 * NFS_HZ)   /* Max timeout to backoff to */
   47 #define NFS_TCPTIMEO    300             /* TCP timeout */
   48 #define NFS_MAXRCVTIMEO 60              /* 1 minute in seconds */
   49 #define NFS_MINIDEMTIMEO (5 * NFS_HZ)   /* Min timeout for non-idempotent ops*/
   50 #define NFS_MAXREXMIT   100             /* Stop counting after this many */
   51 #define NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */
   52 #define NFSV4_CALLBACKRETRY 5           /* Number of retries before failure */
   53 #define NFSV4_SLOTS     64              /* Number of slots, fore channel */
   54 #define NFSV4_CBSLOTS   8               /* Number of slots, back channel */
   55 #define NFSV4_CBRETRYCNT 4              /* # of CBRecall retries upon err */
   56 #define NFSV4_UPCALLTIMEO (15 * NFS_HZ) /* Timeout in ticks for upcalls */
   57                                         /* to gssd or nfsuserd */
   58 #define NFSV4_UPCALLRETRY 4             /* Number of retries before failure */
   59 #define NFS_MAXWINDOW   1024            /* Max number of outstanding requests */
   60 #define NFS_RETRANS     10              /* Num of retrans for soft mounts */
   61 #define NFS_RETRANS_TCP 2               /* Num of retrans for TCP soft mounts */
   62 #define NFS_MAXGRPS     16              /* Max. size of groups list */
   63 #define NFS_TRYLATERDEL 15              /* Maximum delay timeout (sec) */
   64 #ifndef NFS_REMOVETIMEO
   65 #define NFS_REMOVETIMEO 15  /* # sec to wait for delegret in local syscall */
   66 #endif
   67 #ifndef NFS_MINATTRTIMO
   68 #define NFS_MINATTRTIMO 5               /* Attribute cache timeout in sec */
   69 #endif
   70 #ifndef NFS_MAXATTRTIMO
   71 #define NFS_MAXATTRTIMO 60
   72 #endif
   73 #define NFS_WSIZE       8192            /* Def. write data size <= 8192 */
   74 #define NFS_RSIZE       8192            /* Def. read data size <= 8192 */
   75 #define NFS_READDIRSIZE 8192            /* Def. readdir size */
   76 #define NFS_DEFRAHEAD   1               /* Def. read ahead # blocks */
   77 #define NFS_MAXRAHEAD   16              /* Max. read ahead # blocks */
   78 #define NFS_MAXASYNCDAEMON      64      /* Max. number async_daemons runnable */
   79 #define NFS_MAXUIDHASH  64              /* Max. # of hashed uid entries/mp */
   80 #ifndef NFSRV_LEASE
   81 #define NFSRV_LEASE             120     /* Lease time in seconds for V4 */
   82 #endif                                  /* assigned to nfsrv_lease */
   83 #ifndef NFSRV_STALELEASE
   84 #define NFSRV_STALELEASE        (5 * nfsrv_lease)
   85 #endif
   86 #ifndef NFSRV_MOULDYLEASE
   87 #define NFSRV_MOULDYLEASE       604800  /* One week (in sec) */
   88 #endif
   89 #ifndef NFSCLIENTHASHSIZE
   90 #define NFSCLIENTHASHSIZE       20      /* Size of server client hash table */
   91 #endif
   92 #ifndef NFSLOCKHASHSIZE
   93 #define NFSLOCKHASHSIZE         20      /* Size of server nfslock hash table */
   94 #endif
   95 #ifndef NFSSESSIONHASHSIZE
   96 #define NFSSESSIONHASHSIZE      20      /* Size of server session hash table */
   97 #endif
   98 #define NFSSTATEHASHSIZE        10      /* Size of server stateid hash table */
   99 #ifndef NFSCLDELEGHIGHWATER
  100 #define NFSCLDELEGHIGHWATER     10000   /* limit for client delegations */
  101 #endif
  102 #ifndef NFSCLLAYOUTHIGHWATER
  103 #define NFSCLLAYOUTHIGHWATER    10000   /* limit for client pNFS layouts */
  104 #endif
  105 #ifndef NFSNOOPEN                       /* Inactive open owner (sec) */
  106 #define NFSNOOPEN               120
  107 #endif
  108 #define NFSRV_LEASEDELTA        15      /* # of seconds to delay beyond lease */
  109 #define NFS_IDMAXSIZE           4       /* max sizeof (in_addr_t) */
  110 #ifndef NFSRVCACHE_UDPTIMEOUT
  111 #define NFSRVCACHE_UDPTIMEOUT   30      /* # of sec to hold cached rpcs(udp) */
  112 #endif
  113 #ifndef NFSRVCACHE_UDPHIGHWATER
  114 #define NFSRVCACHE_UDPHIGHWATER 500     /* Max # of udp cache entries */
  115 #endif
  116 #ifndef NFSRVCACHE_TCPTIMEOUT
  117 #define NFSRVCACHE_TCPTIMEOUT   (3600*12) /*#of sec to hold cached rpcs(tcp) */
  118 #endif
  119 #ifndef NFSRVCACHE_FLOODLEVEL
  120 #define NFSRVCACHE_FLOODLEVEL   16384   /* Very high water mark for cache */
  121 #endif
  122 #ifndef NFSRV_CLIENTHIGHWATER
  123 #define NFSRV_CLIENTHIGHWATER   1000
  124 #endif
  125 #ifndef NFSRV_MAXDUMPLIST
  126 #define NFSRV_MAXDUMPLIST       10000
  127 #endif
  128 #ifndef NFS_ACCESSCACHESIZE
  129 #define NFS_ACCESSCACHESIZE     8
  130 #endif
  131 #define NFSV4_CBPORT    7745            /* Callback port for testing */
  132 
  133 /*
  134  * This macro defines the high water mark for issuing V4 delegations.
  135  * (It is currently set at a conservative 20% of nfsrv_v4statelimit. This
  136  *  may want to increase when clients can make more effective use of
  137  *  delegations.)
  138  */
  139 #define NFSRV_V4DELEGLIMIT(c) (((c) * 5) > nfsrv_v4statelimit)
  140 
  141 #define NFS_READDIRBLKSIZ       DIRBLKSIZ       /* Minimal nm_readdirsize */
  142 
  143 /*
  144  * Oddballs
  145  */
  146 #define NFS_CMPFH(n, f, s)                                              \
  147     ((n)->n_fhp->nfh_len == (s) && !NFSBCMP((n)->n_fhp->nfh_fh, (caddr_t)(f), (s)))
  148 #define NFSRV_CMPFH(nf, ns, f, s)                                       \
  149         ((ns) == (s) && !NFSBCMP((caddr_t)(nf), (caddr_t)(f), (s)))
  150 #define NFS_CMPTIME(t1, t2)                                             \
  151         ((t1).tv_sec == (t2).tv_sec && (t1).tv_nsec == (t2).tv_nsec)
  152 #define NFS_SETTIME(t) do {                                             \
  153         (t).tv_sec = time.tv_sec; (t).tv_nsec = 1000 * time.tv_usec; } while (0)
  154 #define NFS_SRVMAXDATA(n)                                               \
  155                 (((n)->nd_flag & (ND_NFSV3 | ND_NFSV4)) ?               \
  156                  NFS_SRVMAXIO : NFS_V2MAXDATA)
  157 #define NFS64BITSSET    0xffffffffffffffffull
  158 #define NFS64BITSMINUS1 0xfffffffffffffffeull
  159 
  160 /*
  161  * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs
  162  * and nfsloaduser should ever try and use it.
  163  */
  164 struct nfsd_addsock_args {
  165         int     sock;           /* Socket to serve */
  166         caddr_t name;           /* Client addr for connection based sockets */
  167         int     namelen;        /* Length of name */
  168 };
  169 
  170 /*
  171  * nfsd argument for new krpc.
  172  */
  173 struct nfsd_nfsd_args {
  174         const char *principal;  /* GSS-API service principal name */
  175         int     minthreads;     /* minimum service thread count */
  176         int     maxthreads;     /* maximum service thread count */
  177 };
  178 
  179 /*
  180  * Arguments for use by the callback daemon.
  181  */
  182 struct nfsd_nfscbd_args {
  183         const char *principal;  /* GSS-API service principal name */
  184 };
  185 
  186 struct nfscbd_args {
  187         int     sock;           /* Socket to serve */
  188         caddr_t name;           /* Client addr for connection based sockets */
  189         int     namelen;        /* Length of name */
  190         u_short port;           /* Port# for callbacks */
  191 };
  192 
  193 struct nfsd_idargs {
  194         int             nid_flag;       /* Flags (see below) */
  195         uid_t           nid_uid;        /* user/group id */
  196         gid_t           nid_gid;
  197         int             nid_usermax;    /* Upper bound on user name cache */
  198         int             nid_usertimeout;/* User name timeout (minutes) */
  199         u_char          *nid_name;      /* Name */
  200         int             nid_namelen;    /* and its length */
  201         gid_t           *nid_grps;      /* and the list */
  202         int             nid_ngroup;     /* Size of groups list */
  203 };
  204 
  205 struct nfsd_oidargs {
  206         int             nid_flag;       /* Flags (see below) */
  207         uid_t           nid_uid;        /* user/group id */
  208         gid_t           nid_gid;
  209         int             nid_usermax;    /* Upper bound on user name cache */
  210         int             nid_usertimeout;/* User name timeout (minutes) */
  211         u_char          *nid_name;      /* Name */
  212         int             nid_namelen;    /* and its length */
  213 };
  214 
  215 struct nfsuserd_args {
  216         sa_family_t     nuserd_family;  /* Address family to use */
  217         u_short         nuserd_port;    /* Port# */
  218 };
  219 
  220 struct nfsd_clid {
  221         int             nclid_idlen;    /* Length of client id */
  222         u_char          nclid_id[NFSV4_OPAQUELIMIT]; /* and name */
  223 };
  224 
  225 struct nfsd_dumplist {
  226         int             ndl_size;       /* Number of elements */
  227         void            *ndl_list;      /* and the list of elements */
  228 };
  229 
  230 struct nfsd_dumpclients {
  231         u_int32_t       ndcl_flags;             /* LCL_xxx flags */
  232         u_int32_t       ndcl_nopenowners;       /* Number of openowners */
  233         u_int32_t       ndcl_nopens;            /* and opens */
  234         u_int32_t       ndcl_nlockowners;       /* and of lockowners */
  235         u_int32_t       ndcl_nlocks;            /* and of locks */
  236         u_int32_t       ndcl_ndelegs;           /* and of delegations */
  237         u_int32_t       ndcl_nolddelegs;        /* and old delegations */
  238         sa_family_t     ndcl_addrfam;           /* Callback address */
  239         union {
  240                 struct in_addr sin_addr;
  241                 struct in6_addr sin6_addr;
  242         } ndcl_cbaddr;
  243         struct nfsd_clid ndcl_clid;     /* and client id */
  244 };
  245 
  246 struct nfsd_dumplocklist {
  247         char            *ndllck_fname;  /* File Name */
  248         int             ndllck_size;    /* Number of elements */
  249         void            *ndllck_list;   /* and the list of elements */
  250 };
  251 
  252 struct nfsd_dumplocks {
  253         u_int32_t       ndlck_flags;            /* state flags NFSLCK_xxx */
  254         nfsv4stateid_t  ndlck_stateid;          /* stateid */
  255         u_int64_t       ndlck_first;            /* lock byte range */
  256         u_int64_t       ndlck_end;
  257         struct nfsd_clid ndlck_owner;           /* Owner of open/lock */
  258         sa_family_t     ndlck_addrfam;          /* Callback address */
  259         union {
  260                 struct in_addr sin_addr;
  261                 struct in6_addr sin6_addr;
  262         } ndlck_cbaddr;
  263         struct nfsd_clid ndlck_clid;    /* and client id */
  264 };
  265 
  266 /*
  267  * Structure for referral information.
  268  */
  269 struct nfsreferral {
  270         u_char          *nfr_srvlist;   /* List of servers */
  271         int             nfr_srvcnt;     /* number of servers */
  272         vnode_t         nfr_vp; /* vnode for referral */
  273         u_int32_t       nfr_dfileno;    /* assigned dir inode# */
  274 };
  275 
  276 /*
  277  * Flags for lc_flags and opsflags for nfsrv_getclient().
  278  */
  279 #define LCL_NEEDSCONFIRM        0x00000001
  280 #define LCL_DONTCLEAN           0x00000002
  281 #define LCL_WAKEUPWANTED        0x00000004
  282 #define LCL_TCPCALLBACK         0x00000008
  283 #define LCL_CALLBACKSON         0x00000010
  284 #define LCL_INDEXNOTOK          0x00000020
  285 #define LCL_STAMPEDSTABLE       0x00000040
  286 #define LCL_EXPIREIT            0x00000080
  287 #define LCL_CBDOWN              0x00000100
  288 #define LCL_KERBV               0x00000400
  289 #define LCL_NAME                0x00000800
  290 #define LCL_NEEDSCBNULL         0x00001000
  291 #define LCL_GSSINTEGRITY        0x00002000
  292 #define LCL_GSSPRIVACY          0x00004000
  293 #define LCL_ADMINREVOKED        0x00008000
  294 #define LCL_RECLAIMCOMPLETE     0x00010000
  295 #define LCL_NFSV41              0x00020000
  296 #define LCL_DONEBINDCONN        0x00040000
  297 #define LCL_RECLAIMONEFS        0x00080000
  298 
  299 #define LCL_GSS         LCL_KERBV       /* Or of all mechs */
  300 
  301 /*
  302  * Bits for flags in nfslock and nfsstate.
  303  * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as
  304  * below, in the correct order, so the shifts work for tests.
  305  */
  306 #define NFSLCK_READACCESS       0x00000001
  307 #define NFSLCK_WRITEACCESS      0x00000002
  308 #define NFSLCK_ACCESSBITS       (NFSLCK_READACCESS | NFSLCK_WRITEACCESS)
  309 #define NFSLCK_SHIFT            2
  310 #define NFSLCK_READDENY         0x00000004
  311 #define NFSLCK_WRITEDENY        0x00000008
  312 #define NFSLCK_DENYBITS         (NFSLCK_READDENY | NFSLCK_WRITEDENY)
  313 #define NFSLCK_SHAREBITS                                                \
  314     (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY)
  315 #define NFSLCK_LOCKSHIFT        4
  316 #define NFSLCK_READ             0x00000010
  317 #define NFSLCK_WRITE            0x00000020
  318 #define NFSLCK_BLOCKING         0x00000040
  319 #define NFSLCK_RECLAIM          0x00000080
  320 #define NFSLCK_OPENTOLOCK       0x00000100
  321 #define NFSLCK_TEST             0x00000200
  322 #define NFSLCK_LOCK             0x00000400
  323 #define NFSLCK_UNLOCK           0x00000800
  324 #define NFSLCK_OPEN             0x00001000
  325 #define NFSLCK_CLOSE            0x00002000
  326 #define NFSLCK_CHECK            0x00004000
  327 #define NFSLCK_RELEASE          0x00008000
  328 #define NFSLCK_NEEDSCONFIRM     0x00010000
  329 #define NFSLCK_CONFIRM          0x00020000
  330 #define NFSLCK_DOWNGRADE        0x00040000
  331 #define NFSLCK_DELEGREAD        0x00080000
  332 #define NFSLCK_DELEGWRITE       0x00100000
  333 #define NFSLCK_DELEGCUR         0x00200000
  334 #define NFSLCK_DELEGPREV        0x00400000
  335 #define NFSLCK_OLDDELEG         0x00800000
  336 #define NFSLCK_DELEGRECALL      0x01000000
  337 #define NFSLCK_SETATTR          0x02000000
  338 #define NFSLCK_DELEGPURGE       0x04000000
  339 #define NFSLCK_DELEGRETURN      0x08000000
  340 #define NFSLCK_WANTWDELEG       0x10000000
  341 #define NFSLCK_WANTRDELEG       0x20000000
  342 #define NFSLCK_WANTNODELEG      0x40000000
  343 #define NFSLCK_WANTBITS                                                 \
  344     (NFSLCK_WANTWDELEG | NFSLCK_WANTRDELEG | NFSLCK_WANTNODELEG)
  345 
  346 /* And bits for nid_flag */
  347 #define NFSID_INITIALIZE        0x0001
  348 #define NFSID_ADDUID            0x0002
  349 #define NFSID_DELUID            0x0004
  350 #define NFSID_ADDUSERNAME       0x0008
  351 #define NFSID_DELUSERNAME       0x0010
  352 #define NFSID_ADDGID            0x0020
  353 #define NFSID_DELGID            0x0040
  354 #define NFSID_ADDGROUPNAME      0x0080
  355 #define NFSID_DELGROUPNAME      0x0100
  356 
  357 /*
  358  * fs.nfs sysctl(3) identifiers
  359  */
  360 #define NFS_NFSSTATS    1               /* struct: struct nfsstats */
  361 
  362 /*
  363  * Here is the definition of the attribute bits array and macros that
  364  * manipulate it.
  365  * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!!
  366  * It is (NFSATTRBIT_MAX + 31) / 32.
  367  */
  368 #define NFSATTRBIT_MAXWORDS     3
  369 
  370 typedef struct {
  371         u_int32_t bits[NFSATTRBIT_MAXWORDS];
  372 } nfsattrbit_t;
  373 
  374 #define NFSZERO_ATTRBIT(b) do {                                         \
  375         (b)->bits[0] = 0;                                               \
  376         (b)->bits[1] = 0;                                               \
  377         (b)->bits[2] = 0;                                               \
  378 } while (0)
  379 
  380 #define NFSSET_ATTRBIT(t, f) do {                                       \
  381         (t)->bits[0] = (f)->bits[0];                                    \
  382         (t)->bits[1] = (f)->bits[1];                                    \
  383         (t)->bits[2] = (f)->bits[2];                                    \
  384 } while (0)
  385 
  386 #define NFSSETSUPP_ATTRBIT(b, n) do {                                   \
  387         (b)->bits[0] = NFSATTRBIT_SUPP0;                                \
  388         (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY1);    \
  389         (b)->bits[2] = (NFSATTRBIT_SUPP2 | NFSATTRBIT_SUPPSETONLY2);    \
  390         if (((n)->nd_flag & ND_NFSV41) == 0) {                          \
  391                 (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1;                   \
  392                 (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;                   \
  393         }                                                               \
  394 } while (0)
  395 
  396 #define NFSISSET_ATTRBIT(b, p)  ((b)->bits[(p) / 32] & (1 << ((p) % 32)))
  397 #define NFSSETBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] |= (1 << ((p) % 32)))
  398 #define NFSCLRBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] &= ~(1 << ((p) % 32)))
  399 
  400 #define NFSCLRALL_ATTRBIT(b, a) do {                                    \
  401         (b)->bits[0] &= ~((a)->bits[0]);                                \
  402         (b)->bits[1] &= ~((a)->bits[1]);                                \
  403         (b)->bits[2] &= ~((a)->bits[2]);                                \
  404 } while (0)
  405 
  406 #define NFSCLRNOT_ATTRBIT(b, a) do {                                    \
  407         (b)->bits[0] &= ((a)->bits[0]);                                 \
  408         (b)->bits[1] &= ((a)->bits[1]);                                 \
  409         (b)->bits[2] &= ((a)->bits[2]);                                 \
  410 } while (0)
  411 
  412 #define NFSCLRNOTFILLABLE_ATTRBIT(b, n) do {                            \
  413         (b)->bits[0] &= NFSATTRBIT_SUPP0;                               \
  414         (b)->bits[1] &= NFSATTRBIT_SUPP1;                               \
  415         (b)->bits[2] &= NFSATTRBIT_SUPP2;                               \
  416         if (((n)->nd_flag & ND_NFSV41) == 0) {                          \
  417                 (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1;                   \
  418                 (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;                   \
  419         }                                                               \
  420 } while (0)
  421 
  422 #define NFSCLRNOTSETABLE_ATTRBIT(b, n) do {                             \
  423         (b)->bits[0] &= NFSATTRBIT_SETABLE0;                            \
  424         (b)->bits[1] &= NFSATTRBIT_SETABLE1;                            \
  425         (b)->bits[2] &= NFSATTRBIT_SETABLE2;                            \
  426         if (((n)->nd_flag & ND_NFSV41) == 0)                            \
  427                 (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;                   \
  428 } while (0)
  429 
  430 #define NFSNONZERO_ATTRBIT(b)   ((b)->bits[0] || (b)->bits[1] || (b)->bits[2])
  431 #define NFSEQUAL_ATTRBIT(b, p)  ((b)->bits[0] == (p)->bits[0] &&        \
  432         (b)->bits[1] == (p)->bits[1] && (b)->bits[2] == (p)->bits[2])
  433 
  434 #define NFSGETATTR_ATTRBIT(b) do {                                      \
  435         (b)->bits[0] = NFSATTRBIT_GETATTR0;                             \
  436         (b)->bits[1] = NFSATTRBIT_GETATTR1;                             \
  437         (b)->bits[2] = NFSATTRBIT_GETATTR2;                             \
  438 } while (0)
  439 
  440 #define NFSWCCATTR_ATTRBIT(b) do {                                      \
  441         (b)->bits[0] = NFSATTRBIT_WCCATTR0;                             \
  442         (b)->bits[1] = NFSATTRBIT_WCCATTR1;                             \
  443         (b)->bits[2] = NFSATTRBIT_WCCATTR2;                             \
  444 } while (0)
  445 
  446 #define NFSWRITEGETATTR_ATTRBIT(b) do {                                 \
  447         (b)->bits[0] = NFSATTRBIT_WRITEGETATTR0;                        \
  448         (b)->bits[1] = NFSATTRBIT_WRITEGETATTR1;                        \
  449         (b)->bits[2] = NFSATTRBIT_WRITEGETATTR2;                        \
  450 } while (0)
  451 
  452 #define NFSCBGETATTR_ATTRBIT(b, c) do {                                 \
  453         (c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0);          \
  454         (c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1);          \
  455         (c)->bits[2] = ((b)->bits[2] & NFSATTRBIT_CBGETATTR2);          \
  456 } while (0)
  457 
  458 #define NFSPATHCONF_GETATTRBIT(b) do {                                  \
  459         (b)->bits[0] = NFSGETATTRBIT_PATHCONF0;                         \
  460         (b)->bits[1] = NFSGETATTRBIT_PATHCONF1;                         \
  461         (b)->bits[2] = NFSGETATTRBIT_PATHCONF2;                         \
  462 } while (0)
  463 
  464 #define NFSSTATFS_GETATTRBIT(b) do {                                    \
  465         (b)->bits[0] = NFSGETATTRBIT_STATFS0;                           \
  466         (b)->bits[1] = NFSGETATTRBIT_STATFS1;                           \
  467         (b)->bits[2] = NFSGETATTRBIT_STATFS2;                           \
  468 } while (0)
  469 
  470 #define NFSISSETSTATFS_ATTRBIT(b)                                       \
  471                 (((b)->bits[0] & NFSATTRBIT_STATFS0) ||                 \
  472                  ((b)->bits[1] & NFSATTRBIT_STATFS1) ||                 \
  473                  ((b)->bits[2] & NFSATTRBIT_STATFS2))
  474 
  475 #define NFSCLRSTATFS_ATTRBIT(b) do {                                    \
  476         (b)->bits[0] &= ~NFSATTRBIT_STATFS0;                            \
  477         (b)->bits[1] &= ~NFSATTRBIT_STATFS1;                            \
  478         (b)->bits[2] &= ~NFSATTRBIT_STATFS2;                            \
  479 } while (0)
  480 
  481 #define NFSREADDIRPLUS_ATTRBIT(b) do {                                  \
  482         (b)->bits[0] = NFSATTRBIT_READDIRPLUS0;                         \
  483         (b)->bits[1] = NFSATTRBIT_READDIRPLUS1;                         \
  484         (b)->bits[2] = NFSATTRBIT_READDIRPLUS2;                         \
  485 } while (0)
  486 
  487 #define NFSREFERRAL_ATTRBIT(b) do {                                     \
  488         (b)->bits[0] = NFSATTRBIT_REFERRAL0;                            \
  489         (b)->bits[1] = NFSATTRBIT_REFERRAL1;                            \
  490         (b)->bits[2] = NFSATTRBIT_REFERRAL2;                            \
  491 } while (0)
  492 
  493 /*
  494  * Store uid, gid creds that were used when the stateid was acquired.
  495  * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire,
  496  * so that's how many gets stored here.
  497  */
  498 struct nfscred {
  499         uid_t           nfsc_uid;
  500         gid_t           nfsc_groups[NFS_MAXGRPS + 1];
  501         int             nfsc_ngroups;
  502 };
  503 
  504 /*
  505  * Constants that define the file handle for the V4 root directory.
  506  * (The FSID must never be used by other file systems that are exported.)
  507  */
  508 #define NFSV4ROOT_FSID0         ((int32_t) -1)
  509 #define NFSV4ROOT_FSID1         ((int32_t) -1)
  510 #define NFSV4ROOT_REFERRAL      ((int32_t) -2)
  511 #define NFSV4ROOT_INO           2       /* It's traditional */
  512 #define NFSV4ROOT_GEN           1
  513 
  514 /*
  515  * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
  516  * What should be in this set is open to debate, but I believe that since
  517  * I/O system calls on ufs are never interrupted by signals the set should
  518  * be minimal. My reasoning is that many current programs that use signals
  519  * such as SIGALRM will not expect file I/O system calls to be interrupted
  520  * by them and break.
  521  */
  522 #if defined(_KERNEL) || defined(KERNEL)
  523 
  524 struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
  525 
  526 /*
  527  * Socket errors ignored for connectionless sockets?
  528  * For now, ignore them all
  529  */
  530 #define NFSIGNORE_SOERROR(s, e)                                         \
  531                 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
  532                 ((s) & PR_CONNREQUIRED) == 0)
  533 
  534 
  535 /*
  536  * This structure holds socket information for a connection. Used by the
  537  * client and the server for callbacks.
  538  */
  539 struct nfssockreq {
  540         NFSSOCKADDR_T   nr_nam;
  541         int             nr_sotype;
  542         int             nr_soproto;
  543         int             nr_soflags;
  544         struct ucred    *nr_cred;
  545         int             nr_lock;
  546         NFSMUTEX_T      nr_mtx;
  547         u_int32_t       nr_prog;
  548         u_int32_t       nr_vers;
  549         struct __rpc_client *nr_client;
  550         AUTH            *nr_auth;
  551 };
  552 
  553 /*
  554  * And associated nr_lock bits.
  555  */
  556 #define NFSR_SNDLOCK            0x01
  557 #define NFSR_WANTSND            0x02
  558 #define NFSR_RCVLOCK            0x04
  559 #define NFSR_WANTRCV            0x08
  560 #define NFSR_RESERVEDPORT       0x10
  561 #define NFSR_LOCALHOST          0x20
  562 
  563 /*
  564  * Queue head for nfsreq's
  565  */
  566 TAILQ_HEAD(nfsreqhead, nfsreq);
  567 
  568 /* This is the only nfsreq R_xxx flag still used. */
  569 #define R_DONTRECOVER   0x00000100      /* don't initiate recovery when this
  570                                            rpc gets a stale state reply */
  571 
  572 /*
  573  * Network address hash list element
  574  */
  575 union nethostaddr {
  576         struct in_addr  had_inet;
  577         struct in6_addr had_inet6;
  578 };
  579 
  580 /*
  581  * Structure of list of mechanisms.
  582  */
  583 struct nfsgss_mechlist {
  584         int     len;
  585         const u_char    *str;
  586         int     totlen;
  587 };
  588 #define KERBV_MECH      0       /* position in list */
  589 
  590 /*
  591  * This structure is used by the server for describing each request.
  592  */
  593 struct nfsrv_descript {
  594         mbuf_t                  nd_mrep;        /* Request mbuf list */
  595         mbuf_t                  nd_md;          /* Current dissect mbuf */
  596         mbuf_t                  nd_mreq;        /* Reply mbuf list */
  597         mbuf_t                  nd_mb;          /* Current build mbuf */
  598         NFSSOCKADDR_T           nd_nam;         /* and socket addr */
  599         NFSSOCKADDR_T           nd_nam2;        /* return socket addr */
  600         caddr_t                 nd_dpos;        /* Current dissect pos */
  601         caddr_t                 nd_bpos;        /* Current build pos */
  602         u_int16_t               nd_procnum;     /* RPC # */
  603         u_int32_t               nd_flag;        /* nd_flag */
  604         u_int32_t               nd_repstat;     /* Reply status */
  605         int                     *nd_errp;       /* Pointer to ret status */
  606         u_int32_t               nd_retxid;      /* Reply xid */
  607         struct nfsrvcache       *nd_rp;         /* Assoc. cache entry */
  608         fhandle_t               nd_fh;          /* File handle */
  609         struct ucred            *nd_cred;       /* Credentials */
  610         uid_t                   nd_saveduid;    /* Saved uid */
  611         u_int64_t               nd_sockref;     /* Rcv socket ref# */
  612         u_int64_t               nd_compref;     /* Compound RPC ref# */
  613         time_t                  nd_tcpconntime; /* Time TCP connection est. */
  614         nfsquad_t               nd_clientid;    /* Implied clientid */
  615         int                     nd_gssnamelen;  /* principal name length */
  616         char                    *nd_gssname;    /* principal name */
  617         uint32_t                *nd_slotseq;    /* ptr to slot seq# in req */
  618         uint8_t                 nd_sessionid[NFSX_V4SESSIONID]; /* Session id */
  619         uint32_t                nd_slotid;      /* Slotid for this RPC */
  620         SVCXPRT                 *nd_xprt;       /* Server RPC handle */
  621         uint32_t                *nd_sequence;   /* Sequence Op. ptr */
  622 };
  623 
  624 #define nd_princlen     nd_gssnamelen
  625 #define nd_principal    nd_gssname
  626 
  627 /* Bits for "nd_flag" */
  628 #define ND_DONTSAVEREPLY        0x00000001
  629 #define ND_SAVEREPLY            0x00000002
  630 #define ND_NFSV2                0x00000004
  631 #define ND_NFSV3                0x00000008
  632 #define ND_NFSV4                0x00000010
  633 #define ND_KERBV                0x00000020
  634 #define ND_GSSINTEGRITY         0x00000040
  635 #define ND_GSSPRIVACY           0x00000080
  636 #define ND_WINDOWVERF           0x00000100
  637 #define ND_GSSINITREPLY         0x00000200
  638 #define ND_STREAMSOCK           0x00000400
  639 #define ND_PUBLOOKUP            0x00000800
  640 #define ND_USEGSSNAME           0x00001000
  641 #define ND_SAMETCPCONN          0x00002000
  642 #define ND_IMPLIEDCLID          0x00004000
  643 #define ND_NOMOREDATA           0x00008000
  644 #define ND_V4WCCATTR            0x00010000
  645 #define ND_NFSCB                0x00020000
  646 #define ND_AUTHNONE             0x00040000
  647 #define ND_EXAUTHSYS            0x00080000
  648 #define ND_EXGSS                0x00100000
  649 #define ND_EXGSSINTEGRITY       0x00200000
  650 #define ND_EXGSSPRIVACY         0x00400000
  651 #define ND_INCRSEQID            0x00800000
  652 #define ND_NFSCL                0x01000000
  653 #define ND_NFSV41               0x02000000
  654 #define ND_HASSEQUENCE          0x04000000
  655 #define ND_CACHETHIS            0x08000000
  656 #define ND_LASTOP               0x10000000
  657 #define ND_LOOPBADSESS          0x20000000
  658 
  659 /*
  660  * ND_GSS should be the "or" of all GSS type authentications.
  661  */
  662 #define ND_GSS          (ND_KERBV)
  663 
  664 struct nfsv4_opflag {
  665         int     retfh;
  666         int     needscfh;
  667         int     savereply;
  668         int     modifyfs;
  669         int     lktype;
  670         int     needsseq;
  671         int     loopbadsess;
  672 };
  673 
  674 /*
  675  * Flags used to indicate what to do w.r.t. seqid checking.
  676  */
  677 #define NFSRVSEQID_FIRST        0x01
  678 #define NFSRVSEQID_LAST         0x02
  679 #define NFSRVSEQID_OPEN         0x04
  680 
  681 /*
  682  * assign a doubly linked list to a new head
  683  * and prepend one list into another.
  684  */
  685 #define LIST_NEWHEAD(nhead, ohead, field) do {                          \
  686         if (((nhead)->lh_first = (ohead)->lh_first) != NULL)            \
  687                 (ohead)->lh_first->field.le_prev = &(nhead)->lh_first;  \
  688         (ohead)->lh_first = NULL;                                       \
  689     } while (0)
  690 
  691 #define LIST_PREPEND(head, phead, lelm, field) do {                     \
  692         if ((head)->lh_first != NULL) {                                 \
  693                 (lelm)->field.le_next = (head)->lh_first;               \
  694                 (lelm)->field.le_next->field.le_prev =                  \
  695                     &(lelm)->field.le_next;                             \
  696         }                                                               \
  697         (head)->lh_first = (phead)->lh_first;                           \
  698         (head)->lh_first->field.le_prev = &(head)->lh_first;            \
  699     } while (0)
  700 
  701 /*
  702  * File handle structure for client. Malloc'd to the correct length with
  703  * malloc type M_NFSFH.
  704  */
  705 struct nfsfh {
  706         u_int16_t       nfh_len;        /* Length of file handle */
  707         u_int8_t        nfh_fh[1];      /* and the file handle */
  708 };
  709 
  710 /*
  711  * File handle structure for server. The NFSRV_MAXFH constant is
  712  * set in nfsdport.h. I use a 32bit length, so that alignment is
  713  * preserved.
  714  */
  715 struct nfsrvfh {
  716         u_int32_t       nfsrvfh_len;
  717         u_int8_t        nfsrvfh_data[NFSRV_MAXFH];
  718 };
  719 
  720 /*
  721  * This structure is used for sleep locks on the NFSv4 nfsd threads and
  722  * NFSv4 client data structures.
  723  */
  724 struct nfsv4lock {
  725         u_int32_t       nfslock_usecnt;
  726         u_int8_t        nfslock_lock;
  727 };
  728 #define NFSV4LOCK_LOCK          0x01
  729 #define NFSV4LOCK_LOCKWANTED    0x02
  730 #define NFSV4LOCK_WANTED        0x04
  731 
  732 /*
  733  * Values for the override argument for nfsvno_accchk().
  734  */
  735 #define NFSACCCHK_NOOVERRIDE            0
  736 #define NFSACCCHK_ALLOWROOT             1
  737 #define NFSACCCHK_ALLOWOWNER            2
  738 
  739 /*
  740  * and values for the vpislocked argument for nfsvno_accchk().
  741  */
  742 #define NFSACCCHK_VPNOTLOCKED           0
  743 #define NFSACCCHK_VPISLOCKED            1
  744 
  745 /*
  746  * Slot for the NFSv4.1 Sequence Op.
  747  */
  748 struct nfsslot {
  749         int             nfssl_inprog;
  750         uint32_t        nfssl_seq;
  751         struct mbuf     *nfssl_reply;
  752 };
  753 
  754 /* Enumerated type for nfsuserd state. */
  755 typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state;
  756 
  757 #endif  /* _KERNEL */
  758 
  759 #endif  /* _NFS_NFS_H */

Cache object: e7d5bddc8a3f0a969d024701950c9b0b


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