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/nfsm_subs.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 /*      $NetBSD: nfsm_subs.h,v 1.55 2021/08/12 20:25:27 andvar Exp $    */
    2 
    3 /*
    4  * Copyright (c) 1989, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * This code is derived from software contributed to Berkeley by
    8  * Rick Macklem at The University of Guelph.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. Neither the name of the University nor the names of its contributors
   19  *    may be used to endorse or promote products derived from this software
   20  *    without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  *      @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
   35  */
   36 
   37 
   38 #ifndef _NFS_NFSM_SUBS_H_
   39 #define _NFS_NFSM_SUBS_H_
   40 
   41 
   42 /*
   43  * These macros do strange and peculiar things to mbuf chains for
   44  * the assistance of the nfs code. To attempt to use them for any
   45  * other purpose will be dangerous. (they make weird assumptions)
   46  */
   47 
   48 /*
   49  * First define what the actual subs. return
   50  */
   51 
   52 #define M_HASCL(m)      ((m)->m_flags & M_EXT)
   53 #define NFSMADV(m, s)   (m)->m_data += (s)
   54 #define NFSMSIZ(m)      ((M_HASCL(m)) ? (m)->m_ext.ext_size : \
   55                                 (((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN))
   56 
   57 /*
   58  * NFSv2 can only handle signed 32bit quantities and some clients
   59  * get confused by larger than 16bit block sizes. Limit values
   60  * for better compatibility.
   61  */
   62 #define NFS_V2CLAMP32(x) ((x) > INT32_MAX ? INT32_MAX : (int32_t)(x))
   63 #define NFS_V2CLAMP16(x) ((x) > INT16_MAX ? INT16_MAX : (int32_t)(x))
   64 
   65 /*
   66  * Now for the macros that do the simple stuff and call the functions
   67  * for the hard stuff.
   68  * These macros use several vars. declared in nfsm_reqhead and these
   69  * vars. must not be used elsewhere unless you are careful not to corrupt
   70  * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
   71  * that may be used so long as the value is not expected to retained
   72  * after a macro.
   73  * I know, this is kind of dorkey, but it makes the actual op functions
   74  * fairly clean and deals with the mess caused by the xdr discriminating
   75  * unions.
   76  */
   77 
   78 #define nfsm_build(a,c,s) \
   79                 { if ((s) > M_TRAILINGSPACE(mb)) { \
   80                         struct mbuf *mb2; \
   81                         mb2 = m_get(M_WAIT, MT_DATA); \
   82                         MCLAIM(mb2, &nfs_mowner); \
   83                         if ((s) > MLEN) \
   84                                 panic("build > MLEN"); \
   85                         mb->m_next = mb2; \
   86                         mb = mb2; \
   87                         mb->m_len = 0; \
   88                         bpos = mtod(mb, char *); \
   89                 } \
   90                 (a) = (c)(bpos); \
   91                 mb->m_len += (s); \
   92                 bpos += (s); }
   93 
   94 #define nfsm_aligned(p) ALIGNED_POINTER(p,u_int32_t)
   95 
   96 #define nfsm_dissect(a, c, s) \
   97                 { t1 = mtod(md, char *) + md->m_len-dpos; \
   98                 if (t1 >= (s) && nfsm_aligned(dpos)) { \
   99                         (a) = (c)(dpos); \
  100                         dpos += (s); \
  101                 } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
  102                         error = t1; \
  103                         m_freem(mrep); \
  104                         goto nfsmout; \
  105                 } else { \
  106                         (a) = (c)cp2; \
  107                 } }
  108 
  109 #define nfsm_fhtom(n, v3) \
  110               { if (v3) { \
  111                         t2 = nfsm_rndup((n)->n_fhsize) + NFSX_UNSIGNED; \
  112                         if (t2 <= M_TRAILINGSPACE(mb)) { \
  113                                 nfsm_build(tl, u_int32_t *, t2); \
  114                                 *tl++ = txdr_unsigned((n)->n_fhsize); \
  115                                 *(tl + ((t2>>2) - 2)) = 0; \
  116                                 memcpy(tl,(n)->n_fhp, (n)->n_fhsize); \
  117                         } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
  118                                 (void *)(n)->n_fhp, (n)->n_fhsize)) != 0) { \
  119                                 error = t2; \
  120                                 m_freem(mreq); \
  121                                 goto nfsmout; \
  122                         } \
  123                 } else { \
  124                         nfsm_build(cp, void *, NFSX_V2FH); \
  125                         memcpy(cp, (n)->n_fhp, NFSX_V2FH); \
  126                 } }
  127 
  128 #define nfsm_srvfhtom(f, v3) \
  129                 { if (v3) { \
  130                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + \
  131                             NFSRVFH_SIZE(f)); \
  132                         *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
  133                         memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
  134                 } else { \
  135                         KASSERT(NFSRVFH_SIZE(f) == NFSX_V2FH); \
  136                         nfsm_build(cp, void *, NFSX_V2FH); \
  137                         memcpy(cp, NFSRVFH_DATA(f), NFSX_V2FH); \
  138                 } }
  139 
  140 #define nfsm_srvpostop_fh(f) \
  141                 { nfsm_build(tl, u_int32_t *, \
  142                     2 * NFSX_UNSIGNED + NFSRVFH_SIZE(f)); \
  143                 *tl++ = nfs_true; \
  144                 *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
  145                 memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
  146                 }
  147 
  148 /*
  149  * nfsm_mtofh: dissect a "resulted obj" part of create-like operations
  150  * like mkdir.
  151  *
  152  * for nfsv3, dissect post_op_fh3 and following post_op_attr.
  153  * for nfsv2, dissect fhandle and following fattr.
  154  *
  155  * d: (IN) the vnode of the parent directory.
  156  * v: (OUT) the corresponding vnode (we allocate one if needed)
  157  * v3: (IN) true for nfsv3.
  158  * f: (OUT) true if we got valid filehandle.  always true for nfsv2.
  159  */
  160 
  161 #define nfsm_mtofh(d, v, v3, f) \
  162                 { struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
  163                 int hasattr = 0; \
  164                 if (v3) { \
  165                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  166                         (f) = fxdr_unsigned(int, *tl); \
  167                 } else { \
  168                         (f) = 1; \
  169                         hasattr = 1; \
  170                 } \
  171                 if (f) { \
  172                         nfsm_getfh(ttfhp, ttfhsize, (v3)); \
  173                         if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
  174                                 &ttnp)) != 0) { \
  175                                 error = t1; \
  176                                 m_freem(mrep); \
  177                                 goto nfsmout; \
  178                         } \
  179                         (v) = NFSTOV(ttnp); \
  180                 } \
  181                 if (v3) { \
  182                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  183                         if (f) \
  184                                 hasattr = fxdr_unsigned(int, *tl); \
  185                         else if (fxdr_unsigned(int, *tl)) \
  186                                 nfsm_adv(NFSX_V3FATTR); \
  187                 } \
  188                 if (f && hasattr) \
  189                         nfsm_loadattr((v), (struct vattr *)0, 0); \
  190                 }
  191 
  192 /*
  193  * nfsm_getfh: dissect a filehandle.
  194  *
  195  * f: (OUT) a filehandle.
  196  * s: (OUT) size of the filehandle in bytes.
  197  * v3: (IN) true if nfsv3.
  198  */
  199 
  200 #define nfsm_getfh(f, s, v3) \
  201                 { if (v3) { \
  202                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  203                         if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
  204                                 (s) > NFSX_V3FHMAX) { \
  205                                 m_freem(mrep); \
  206                                 error = EBADRPC; \
  207                                 goto nfsmout; \
  208                         } \
  209                 } else \
  210                         (s) = NFSX_V2FH; \
  211                 nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
  212 
  213 #define nfsm_loadattr(v, a, flags) \
  214                 { struct vnode *ttvp = (v); \
  215                 if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \
  216                     != 0) { \
  217                         error = t1; \
  218                         m_freem(mrep); \
  219                         goto nfsmout; \
  220                 } \
  221                 (v) = ttvp; }
  222 
  223 /*
  224  * nfsm_postop_attr: process nfsv3 post_op_attr
  225  *
  226  * dissect post_op_attr.  if we got a one,
  227  * call nfsm_loadattrcache to update attribute cache.
  228  *
  229  * v: (IN/OUT) the corresponding vnode
  230  * f: (OUT) true if we got valid attribute
  231  * flags: (IN) flags for nfsm_loadattrcache
  232  */
  233 
  234 #define nfsm_postop_attr(v, f, flags) \
  235                 { struct vnode *ttvp = (v); \
  236                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  237                 if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
  238                         if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \
  239                                 (struct vattr *)0, (flags))) != 0) { \
  240                                 error = t1; \
  241                                 (f) = 0; \
  242                                 m_freem(mrep); \
  243                                 goto nfsmout; \
  244                         } \
  245                         (v) = ttvp; \
  246                 } }
  247 
  248 /*
  249  * nfsm_wcc_data: process nfsv3 wcc_data
  250  *
  251  * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
  252  *
  253  * v: (IN/OUT) the corresponding vnode
  254  * f: (IN/OUT)
  255  *      NFSV3_WCCRATTR  return true if we got valid post_op_attr.
  256  *      NFSV3_WCCCHK    return true if pre_op_attr's mtime is the same
  257  *                      as our n_mtime.  (ie. our cache isn't stale.)
  258  * flags: (IN) flags for nfsm_loadattrcache
  259  * docheck: (IN) true if timestamp change is expected
  260  */
  261 
  262 /* Used as (f) for nfsm_wcc_data() */
  263 #define NFSV3_WCCRATTR  0
  264 #define NFSV3_WCCCHK    1
  265 
  266 #define nfsm_wcc_data(v, f, flags, docheck) \
  267                 { int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \
  268                 struct timespec ctime, mtime; \
  269                 struct nfsnode *nfsp = VTONFS(v); \
  270                 bool haspreopattr = false; \
  271                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  272                 if (*tl == nfs_true) { \
  273                         haspreopattr = true; \
  274                         nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
  275                         fxdr_nfsv3time(tl + 2, &mtime); \
  276                         fxdr_nfsv3time(tl + 4, &ctime); \
  277                         if (nfsp->n_ctime == ctime.tv_sec) \
  278                                 renewctime = 1; \
  279                         if ((v)->v_type == VDIR) { \
  280                                 if (timespeccmp(&nfsp->n_nctime, &ctime, ==)) \
  281                                         renewnctime = 1; \
  282                         } \
  283                         if (f) { \
  284                                 ttretf = timespeccmp(&nfsp->n_mtime, &mtime, ==);\
  285                         } \
  286                 } \
  287                 nfsm_postop_attr((v), ttattrf, (flags)); \
  288                 nfsp = VTONFS(v); \
  289                 if (ttattrf) { \
  290                         if (haspreopattr && \
  291                             nfs_check_wccdata(nfsp, &ctime, &mtime, (docheck))) \
  292                                 renewctime = renewnctime = ttretf = 0; \
  293                         if (renewctime) \
  294                                 nfsp->n_ctime = nfsp->n_vattr->va_ctime.tv_sec; \
  295                         if (renewnctime) \
  296                                 nfsp->n_nctime = nfsp->n_vattr->va_ctime; \
  297                 } \
  298                 if (f) { \
  299                         (f) = ttretf; \
  300                 } else { \
  301                         (f) = ttattrf; \
  302                 } }
  303 
  304 /* If full is true, set all fields, otherwise just set mode and time fields */
  305 #define nfsm_v3attrbuild(a, full)                                               \
  306                 { if ((a)->va_mode != (mode_t)VNOVAL) {                         \
  307                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  308                         *tl++ = nfs_true;                                       \
  309                         *tl = txdr_unsigned((a)->va_mode);                      \
  310                 } else {                                                        \
  311                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  312                         *tl = nfs_false;                                        \
  313                 }                                                               \
  314                 if ((full) && (a)->va_uid != (uid_t)VNOVAL) {                   \
  315                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  316                         *tl++ = nfs_true;                                       \
  317                         *tl = txdr_unsigned((a)->va_uid);                       \
  318                 } else {                                                        \
  319                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  320                         *tl = nfs_false;                                        \
  321                 }                                                               \
  322                 if ((full) && (a)->va_gid != (gid_t)VNOVAL) {                   \
  323                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  324                         *tl++ = nfs_true;                                       \
  325                         *tl = txdr_unsigned((a)->va_gid);                       \
  326                 } else {                                                        \
  327                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  328                         *tl = nfs_false;                                        \
  329                 }                                                               \
  330                 if ((full) && (a)->va_size != VNOVAL) {                         \
  331                         nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);         \
  332                         *tl++ = nfs_true;                                       \
  333                         txdr_hyper((a)->va_size, tl);                           \
  334                 } else {                                                        \
  335                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  336                         *tl = nfs_false;                                        \
  337                 }                                                               \
  338                 if ((a)->va_atime.tv_sec != VNOVAL) {                           \
  339                         if ((a)->va_atime.tv_sec != time_second) {              \
  340                                 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
  341                                 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
  342                                 txdr_nfsv3time(&(a)->va_atime, tl);             \
  343                         } else {                                                \
  344                                 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);     \
  345                                 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);   \
  346                         }                                                       \
  347                 } else {                                                        \
  348                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  349                         *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);         \
  350                 }                                                               \
  351                 if ((a)->va_mtime.tv_sec != VNOVAL) {                           \
  352                         if ((a)->va_mtime.tv_sec != time_second) {              \
  353                                 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
  354                                 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
  355                                 txdr_nfsv3time(&(a)->va_mtime, tl);             \
  356                         } else {                                                \
  357                                 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);     \
  358                                 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);   \
  359                         }                                                       \
  360                 } else {                                                        \
  361                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  362                         *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);         \
  363                 }                                                               \
  364                 }
  365 
  366 
  367 #define nfsm_strsiz(s,m) \
  368                 { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
  369                 if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
  370                         m_freem(mrep); \
  371                         error = EBADRPC; \
  372                         goto nfsmout; \
  373                 } }
  374 
  375 #define nfsm_srvnamesiz(s) \
  376                 { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
  377                 if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
  378                         error = NFSERR_NAMETOL; \
  379                 if (error) \
  380                         nfsm_reply(0); \
  381                 }
  382 
  383 #define nfsm_mtouio(p,s) \
  384                 if ((s) > 0 && \
  385                    (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
  386                         error = t1; \
  387                         m_freem(mrep); \
  388                         goto nfsmout; \
  389                 }
  390 
  391 #define nfsm_uiotom(p,s) \
  392                 if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
  393                         error = t1; \
  394                         m_freem(mreq); \
  395                         goto nfsmout; \
  396                 }
  397 
  398 #define nfsm_reqhead(n,a,s) \
  399                 mb = mreq = nfsm_reqh((n),(a),(s),&bpos)
  400 
  401 #define nfsm_reqdone    m_freem(mrep); \
  402                 nfsmout:
  403 
  404 #define nfsm_rndup(a)   (((a)+3)&(~0x3))
  405 #define nfsm_padlen(a)  (nfsm_rndup(a) - (a))
  406 
  407 #define nfsm_request1(v, t, p, c, rexmitp)      \
  408                 if ((error = nfs_request((v), mreq, (t), (p), \
  409                    (c), &mrep, &md, &dpos, (rexmitp))) != 0) { \
  410                         if (error & NFSERR_RETERR) \
  411                                 error &= ~NFSERR_RETERR; \
  412                         else \
  413                                 goto nfsmout; \
  414                 }
  415 
  416 #define nfsm_request(v, t, p, c)        nfsm_request1((v), (t), (p), (c), NULL)
  417 
  418 #define nfsm_strtom(a,s,m) \
  419                 if ((s) > (m)) { \
  420                         m_freem(mreq); \
  421                         error = ENAMETOOLONG; \
  422                         goto nfsmout; \
  423                 } \
  424                 t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
  425                 if (t2 <= M_TRAILINGSPACE(mb)) { \
  426                         nfsm_build(tl,u_int32_t *,t2); \
  427                         *tl++ = txdr_unsigned(s); \
  428                         *(tl+((t2>>2)-2)) = 0; \
  429                         memcpy(tl, (const char *)(a), (s)); \
  430                 } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
  431                         error = t2; \
  432                         m_freem(mreq); \
  433                         goto nfsmout; \
  434                 }
  435 
  436 #define nfsm_srvdone \
  437                 nfsmout: \
  438                 return(error)
  439 
  440 #define nfsm_reply(s) \
  441                 { \
  442                 nfsd->nd_repstat = error; \
  443                 if (error && !(nfsd->nd_flag & ND_NFSV3)) \
  444                    (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
  445                         mrq, &mb, &bpos); \
  446                 else \
  447                    (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
  448                         mrq, &mb, &bpos); \
  449                 if (mrep != NULL) { \
  450                         m_freem(mrep); \
  451                         mrep = NULL; \
  452                 } \
  453                 mreq = *mrq; \
  454                 if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
  455                         error == EBADRPC)) {\
  456                         error = 0; \
  457                         goto nfsmout; \
  458                         } \
  459                 }
  460 
  461 #define nfsm_writereply(s, v3) \
  462                 { \
  463                 nfsd->nd_repstat = error; \
  464                 if (error && !(v3)) \
  465                    (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
  466                         &mreq, &mb, &bpos); \
  467                 else \
  468                    (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
  469                         &mreq, &mb, &bpos); \
  470                 }
  471 
  472 #define nfsm_adv(s) \
  473                 { t1 = mtod(md, char *) + md->m_len - dpos; \
  474                 if (t1 >= (s)) { \
  475                         dpos += (s); \
  476                 } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
  477                         error = t1; \
  478                         m_freem(mrep); \
  479                         goto nfsmout; \
  480                 } }
  481 
  482 #define nfsm_srvmtofh(nsfh) \
  483         { int fhlen = NFSX_V3FH; \
  484                 if (nfsd->nd_flag & ND_NFSV3) { \
  485                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  486                         fhlen = fxdr_unsigned(int, *tl); \
  487                         if (fhlen > NFSX_V3FHMAX || \
  488                             (fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \
  489                                 error = EBADRPC; \
  490                                 nfsm_reply(0); \
  491                         } \
  492                 } else { \
  493                         fhlen = NFSX_V2FH; \
  494                 } \
  495                 (nsfh)->nsfh_size = fhlen; \
  496                 if (fhlen != 0) { \
  497                         nfsm_dissect(tl, u_int32_t *, fhlen); \
  498                         memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \
  499                 } \
  500         }
  501 
  502 #define nfsm_clget \
  503                 if (bp >= be) { \
  504                         if (mp == mb) \
  505                                 mp->m_len += bp-bpos; \
  506                         mp = m_get(M_WAIT, MT_DATA); \
  507                         MCLAIM(mp, &nfs_mowner); \
  508                         m_clget(mp, M_WAIT); \
  509                         mp->m_len = NFSMSIZ(mp); \
  510                         mp2->m_next = mp; \
  511                         mp2 = mp; \
  512                         bp = mtod(mp, char *); \
  513                         be = bp+mp->m_len; \
  514                 } \
  515                 tl = (u_int32_t *)bp
  516 
  517 #define nfsm_srvfillattr(a, f) \
  518                 nfsm_srvfattr(nfsd, (a), (f))
  519 
  520 #define nfsm_srvwcc_data(br, b, ar, a) \
  521                 nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
  522 
  523 #define nfsm_srvpostop_attr(r, a) \
  524                 nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
  525 
  526 #define nfsm_srvsattr(a) \
  527                 { \
  528                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  529                 if (*tl == nfs_true) { \
  530                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  531                         (a)->va_mode = nfstov_mode(*tl); \
  532                 } \
  533                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  534                 if (*tl == nfs_true) { \
  535                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  536                         (a)->va_uid = fxdr_unsigned(uid_t, *tl); \
  537                 } \
  538                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  539                 if (*tl == nfs_true) { \
  540                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  541                         (a)->va_gid = fxdr_unsigned(gid_t, *tl); \
  542                 } \
  543                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  544                 if (*tl == nfs_true) { \
  545                         nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
  546                         (a)->va_size = fxdr_hyper(tl); \
  547                 } \
  548                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  549                 switch (fxdr_unsigned(int, *tl)) { \
  550                 case NFSV3SATTRTIME_TOCLIENT: \
  551                         nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
  552                         fxdr_nfsv3time(tl, &(a)->va_atime); \
  553                         break; \
  554                 case NFSV3SATTRTIME_TOSERVER: \
  555                         getnanotime(&(a)->va_atime); \
  556                         (a)->va_vaflags |= VA_UTIMES_NULL; \
  557                         break; \
  558                 }; \
  559                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  560                 switch (fxdr_unsigned(int, *tl)) { \
  561                 case NFSV3SATTRTIME_TOCLIENT: \
  562                         nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
  563                         fxdr_nfsv3time(tl, &(a)->va_mtime); \
  564                         (a)->va_vaflags &= ~VA_UTIMES_NULL; \
  565                         break; \
  566                 case NFSV3SATTRTIME_TOSERVER: \
  567                         getnanotime(&(a)->va_mtime); \
  568                         (a)->va_vaflags |= VA_UTIMES_NULL; \
  569                         break; \
  570                 }; }
  571 
  572 #endif

Cache object: 5e1491d0680441eca5883eee17b461b3


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