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.47 2006/09/02 12:40:36 yamt 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  * Now for the macros that do the simple stuff and call the functions
   59  * for the hard stuff.
   60  * These macros use several vars. declared in nfsm_reqhead and these
   61  * vars. must not be used elsewhere unless you are careful not to corrupt
   62  * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
   63  * that may be used so long as the value is not expected to retained
   64  * after a macro.
   65  * I know, this is kind of dorkey, but it makes the actual op functions
   66  * fairly clean and deals with the mess caused by the xdr discriminating
   67  * unions.
   68  */
   69 
   70 #define nfsm_build(a,c,s) \
   71                 { if ((s) > M_TRAILINGSPACE(mb)) { \
   72                         struct mbuf *mb2; \
   73                         mb2 = m_get(M_WAIT, MT_DATA); \
   74                         MCLAIM(mb2, &nfs_mowner); \
   75                         if ((s) > MLEN) \
   76                                 panic("build > MLEN"); \
   77                         mb->m_next = mb2; \
   78                         mb = mb2; \
   79                         mb->m_len = 0; \
   80                         bpos = mtod(mb, caddr_t); \
   81                 } \
   82                 (a) = (c)(bpos); \
   83                 mb->m_len += (s); \
   84                 bpos += (s); }
   85 
   86 #define nfsm_aligned(p) ALIGNED_POINTER(p,u_int32_t)
   87 
   88 #define nfsm_dissect(a, c, s) \
   89                 { t1 = mtod(md, caddr_t)+md->m_len-dpos; \
   90                 if (t1 >= (s) && nfsm_aligned(dpos)) { \
   91                         (a) = (c)(dpos); \
   92                         dpos += (s); \
   93                 } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
   94                         error = t1; \
   95                         m_freem(mrep); \
   96                         goto nfsmout; \
   97                 } else { \
   98                         (a) = (c)cp2; \
   99                 } }
  100 
  101 #define nfsm_fhtom(n, v3) \
  102               { if (v3) { \
  103                         t2 = nfsm_rndup((n)->n_fhsize) + NFSX_UNSIGNED; \
  104                         if (t2 <= M_TRAILINGSPACE(mb)) { \
  105                                 nfsm_build(tl, u_int32_t *, t2); \
  106                                 *tl++ = txdr_unsigned((n)->n_fhsize); \
  107                                 *(tl + ((t2>>2) - 2)) = 0; \
  108                                 memcpy((caddr_t)tl,(caddr_t)(n)->n_fhp, \
  109                                         (n)->n_fhsize); \
  110                         } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
  111                                 (caddr_t)(n)->n_fhp, \
  112                                   (n)->n_fhsize)) != 0) { \
  113                                 error = t2; \
  114                                 m_freem(mreq); \
  115                                 goto nfsmout; \
  116                         } \
  117                 } else { \
  118                         nfsm_build(cp, caddr_t, NFSX_V2FH); \
  119                         memcpy(cp, (caddr_t)(n)->n_fhp, NFSX_V2FH); \
  120                 } }
  121 
  122 #define nfsm_srvfhtom(f, v3) \
  123                 { if (v3) { \
  124                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + \
  125                             NFSRVFH_SIZE(f)); \
  126                         *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
  127                         memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
  128                 } else { \
  129                         KASSERT(NFSRVFH_SIZE(f) == NFSX_V2FH); \
  130                         nfsm_build(cp, caddr_t, NFSX_V2FH); \
  131                         memcpy(cp, NFSRVFH_DATA(f), NFSX_V2FH); \
  132                 } }
  133 
  134 #define nfsm_srvpostop_fh(f) \
  135                 { nfsm_build(tl, u_int32_t *, \
  136                     2 * NFSX_UNSIGNED + NFSRVFH_SIZE(f)); \
  137                 *tl++ = nfs_true; \
  138                 *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
  139                 memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
  140                 }
  141 
  142 /*
  143  * nfsm_mtofh: dissect a "resulted obj" part of create-like operations
  144  * like mkdir.
  145  *
  146  * for nfsv3, dissect post_op_fh3 and following post_op_attr.
  147  * for nfsv2, dissect fhandle and following fattr.
  148  *
  149  * d: (IN) the vnode of the parent directry.
  150  * v: (OUT) the corresponding vnode (we allocate one if needed)
  151  * v3: (IN) true for nfsv3.
  152  * f: (OUT) true if we got valid filehandle.  always true for nfsv2.
  153  */
  154 
  155 #define nfsm_mtofh(d, v, v3, f) \
  156                 { struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
  157                 int hasattr = 0; \
  158                 if (v3) { \
  159                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  160                         (f) = fxdr_unsigned(int, *tl); \
  161                 } else { \
  162                         (f) = 1; \
  163                         hasattr = 1; \
  164                 } \
  165                 if (f) { \
  166                         nfsm_getfh(ttfhp, ttfhsize, (v3)); \
  167                         if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
  168                                 &ttnp)) != 0) { \
  169                                 error = t1; \
  170                                 m_freem(mrep); \
  171                                 goto nfsmout; \
  172                         } \
  173                         (v) = NFSTOV(ttnp); \
  174                 } \
  175                 if (v3) { \
  176                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  177                         if (f) \
  178                                 hasattr = fxdr_unsigned(int, *tl); \
  179                         else if (fxdr_unsigned(int, *tl)) \
  180                                 nfsm_adv(NFSX_V3FATTR); \
  181                 } \
  182                 if (f && hasattr) \
  183                         nfsm_loadattr((v), (struct vattr *)0, 0); \
  184                 }
  185 
  186 /*
  187  * nfsm_getfh: dissect a filehandle.
  188  *
  189  * f: (OUT) a filehandle.
  190  * s: (OUT) size of the filehandle in bytes.
  191  * v3: (IN) true if nfsv3.
  192  */
  193 
  194 #define nfsm_getfh(f, s, v3) \
  195                 { if (v3) { \
  196                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  197                         if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
  198                                 (s) > NFSX_V3FHMAX) { \
  199                                 m_freem(mrep); \
  200                                 error = EBADRPC; \
  201                                 goto nfsmout; \
  202                         } \
  203                 } else \
  204                         (s) = NFSX_V2FH; \
  205                 nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
  206 
  207 #define nfsm_loadattr(v, a, flags) \
  208                 { struct vnode *ttvp = (v); \
  209                 if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \
  210                     != 0) { \
  211                         error = t1; \
  212                         m_freem(mrep); \
  213                         goto nfsmout; \
  214                 } \
  215                 (v) = ttvp; }
  216 
  217 /*
  218  * nfsm_postop_attr: process nfsv3 post_op_attr
  219  *
  220  * dissect post_op_attr.  if we got a one,
  221  * call nfsm_loadattrcache to update attribute cache.
  222  *
  223  * v: (IN/OUT) the corresponding vnode
  224  * f: (OUT) true if we got valid attribute
  225  * flags: (IN) flags for nfsm_loadattrcache
  226  */
  227 
  228 #define nfsm_postop_attr(v, f, flags) \
  229                 { struct vnode *ttvp = (v); \
  230                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  231                 if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
  232                         if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \
  233                                 (struct vattr *)0, (flags))) != 0) { \
  234                                 error = t1; \
  235                                 (f) = 0; \
  236                                 m_freem(mrep); \
  237                                 goto nfsmout; \
  238                         } \
  239                         (v) = ttvp; \
  240                 } }
  241 
  242 /*
  243  * nfsm_wcc_data: process nfsv3 wcc_data
  244  *
  245  * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
  246  *
  247  * v: (IN/OUT) the corresponding vnode
  248  * f: (IN/OUT)
  249  *      NFSV3_WCCRATTR  return true if we got valid post_op_attr.
  250  *      NFSV3_WCCCHK    return true if pre_op_attr's mtime is the same
  251  *                      as our n_mtime.  (ie. our cache isn't stale.)
  252  * flags: (IN) flags for nfsm_loadattrcache
  253  * docheck: (IN) TRUE if timestamp change is expected
  254  */
  255 
  256 /* Used as (f) for nfsm_wcc_data() */
  257 #define NFSV3_WCCRATTR  0
  258 #define NFSV3_WCCCHK    1
  259 
  260 #define nfsm_wcc_data(v, f, flags, docheck) \
  261                 { int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \
  262                 struct timespec ctime, mtime; \
  263                 struct nfsnode *nfsp = VTONFS(v); \
  264                 boolean_t haspreopattr = FALSE; \
  265                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  266                 if (*tl == nfs_true) { \
  267                         haspreopattr = TRUE; \
  268                         nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
  269                         fxdr_nfsv3time(tl + 2, &mtime); \
  270                         fxdr_nfsv3time(tl + 4, &ctime); \
  271                         if (nfsp->n_ctime == ctime.tv_sec) \
  272                                 renewctime = 1; \
  273                         if ((v)->v_type == VDIR) { \
  274                                 if (timespeccmp(&nfsp->n_nctime, &ctime, ==)) \
  275                                         renewnctime = 1; \
  276                         } \
  277                         if (f) { \
  278                                 ttretf = timespeccmp(&nfsp->n_mtime, &mtime, ==);\
  279                         } \
  280                 } \
  281                 nfsm_postop_attr((v), ttattrf, (flags)); \
  282                 nfsp = VTONFS(v); \
  283                 if (ttattrf) { \
  284                         if (haspreopattr && \
  285                             nfs_check_wccdata(nfsp, &ctime, &mtime, (docheck))) \
  286                                 renewctime = renewnctime = ttretf = 0; \
  287                         if (renewctime) \
  288                                 nfsp->n_ctime = nfsp->n_vattr->va_ctime.tv_sec; \
  289                         if (renewnctime) \
  290                                 nfsp->n_nctime = nfsp->n_vattr->va_ctime; \
  291                 } \
  292                 if (f) { \
  293                         (f) = ttretf; \
  294                 } else { \
  295                         (f) = ttattrf; \
  296                 } }
  297 
  298 /* If full is true, set all fields, otherwise just set mode and time fields */
  299 #define nfsm_v3attrbuild(a, full)                                               \
  300                 { if ((a)->va_mode != (mode_t)VNOVAL) {                         \
  301                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  302                         *tl++ = nfs_true;                                       \
  303                         *tl = txdr_unsigned((a)->va_mode);                      \
  304                 } else {                                                        \
  305                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  306                         *tl = nfs_false;                                        \
  307                 }                                                               \
  308                 if ((full) && (a)->va_uid != (uid_t)VNOVAL) {                   \
  309                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  310                         *tl++ = nfs_true;                                       \
  311                         *tl = txdr_unsigned((a)->va_uid);                       \
  312                 } else {                                                        \
  313                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  314                         *tl = nfs_false;                                        \
  315                 }                                                               \
  316                 if ((full) && (a)->va_gid != (gid_t)VNOVAL) {                   \
  317                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  318                         *tl++ = nfs_true;                                       \
  319                         *tl = txdr_unsigned((a)->va_gid);                       \
  320                 } else {                                                        \
  321                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  322                         *tl = nfs_false;                                        \
  323                 }                                                               \
  324                 if ((full) && (a)->va_size != VNOVAL) {                         \
  325                         nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);         \
  326                         *tl++ = nfs_true;                                       \
  327                         txdr_hyper((a)->va_size, tl);                           \
  328                 } else {                                                        \
  329                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  330                         *tl = nfs_false;                                        \
  331                 }                                                               \
  332                 if ((a)->va_atime.tv_sec != VNOVAL) {                           \
  333                         if ((a)->va_atime.tv_sec != time_second) {              \
  334                                 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
  335                                 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
  336                                 txdr_nfsv3time(&(a)->va_atime, tl);             \
  337                         } else {                                                \
  338                                 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);     \
  339                                 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);   \
  340                         }                                                       \
  341                 } else {                                                        \
  342                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  343                         *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);         \
  344                 }                                                               \
  345                 if ((a)->va_mtime.tv_sec != VNOVAL) {                           \
  346                         if ((a)->va_mtime.tv_sec != time_second) {              \
  347                                 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
  348                                 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
  349                                 txdr_nfsv3time(&(a)->va_mtime, tl);             \
  350                         } else {                                                \
  351                                 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);     \
  352                                 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);   \
  353                         }                                                       \
  354                 } else {                                                        \
  355                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  356                         *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);         \
  357                 }                                                               \
  358                 }
  359 
  360 
  361 #define nfsm_strsiz(s,m) \
  362                 { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
  363                 if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
  364                         m_freem(mrep); \
  365                         error = EBADRPC; \
  366                         goto nfsmout; \
  367                 } }
  368 
  369 #define nfsm_srvnamesiz(s) \
  370                 { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
  371                 if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
  372                         error = NFSERR_NAMETOL; \
  373                 if (error) \
  374                         nfsm_reply(0); \
  375                 }
  376 
  377 #define nfsm_mtouio(p,s) \
  378                 if ((s) > 0 && \
  379                    (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
  380                         error = t1; \
  381                         m_freem(mrep); \
  382                         goto nfsmout; \
  383                 }
  384 
  385 #define nfsm_uiotom(p,s) \
  386                 if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
  387                         error = t1; \
  388                         m_freem(mreq); \
  389                         goto nfsmout; \
  390                 }
  391 
  392 #define nfsm_reqhead(n,a,s) \
  393                 mb = mreq = nfsm_reqh((n),(a),(s),&bpos)
  394 
  395 #define nfsm_reqdone    m_freem(mrep); \
  396                 nfsmout:
  397 
  398 #define nfsm_rndup(a)   (((a)+3)&(~0x3))
  399 #define nfsm_padlen(a)  (nfsm_rndup(a) - (a))
  400 
  401 #define nfsm_request1(v, t, p, c, rexmitp)      \
  402                 if ((error = nfs_request((v), mreq, (t), (p), \
  403                    (c), &mrep, &md, &dpos, (rexmitp))) != 0) { \
  404                         if (error & NFSERR_RETERR) \
  405                                 error &= ~NFSERR_RETERR; \
  406                         else \
  407                                 goto nfsmout; \
  408                 }
  409 
  410 #define nfsm_request(v, t, p, c)        nfsm_request1((v), (t), (p), (c), NULL)
  411 
  412 #define nfsm_strtom(a,s,m) \
  413                 if ((s) > (m)) { \
  414                         m_freem(mreq); \
  415                         error = ENAMETOOLONG; \
  416                         goto nfsmout; \
  417                 } \
  418                 t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
  419                 if (t2 <= M_TRAILINGSPACE(mb)) { \
  420                         nfsm_build(tl,u_int32_t *,t2); \
  421                         *tl++ = txdr_unsigned(s); \
  422                         *(tl+((t2>>2)-2)) = 0; \
  423                         memcpy((caddr_t)tl, (const char *)(a), (s)); \
  424                 } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
  425                         error = t2; \
  426                         m_freem(mreq); \
  427                         goto nfsmout; \
  428                 }
  429 
  430 #define nfsm_srvdone \
  431                 nfsmout: \
  432                 return(error)
  433 
  434 #define nfsm_reply(s) \
  435                 { \
  436                 nfsd->nd_repstat = error; \
  437                 if (error && !(nfsd->nd_flag & ND_NFSV3)) \
  438                    (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
  439                         mrq, &mb, &bpos); \
  440                 else \
  441                    (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
  442                         mrq, &mb, &bpos); \
  443                 if (mrep != NULL) { \
  444                         m_freem(mrep); \
  445                         mrep = NULL; \
  446                 } \
  447                 mreq = *mrq; \
  448                 if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
  449                         error == EBADRPC)) \
  450                         return(0); \
  451                 }
  452 
  453 #define nfsm_writereply(s, v3) \
  454                 { \
  455                 nfsd->nd_repstat = error; \
  456                 if (error && !(v3)) \
  457                    (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
  458                         &mreq, &mb, &bpos); \
  459                 else \
  460                    (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
  461                         &mreq, &mb, &bpos); \
  462                 }
  463 
  464 #define nfsm_adv(s) \
  465                 { t1 = mtod(md, caddr_t)+md->m_len-dpos; \
  466                 if (t1 >= (s)) { \
  467                         dpos += (s); \
  468                 } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
  469                         error = t1; \
  470                         m_freem(mrep); \
  471                         goto nfsmout; \
  472                 } }
  473 
  474 #define nfsm_srvmtofh(nsfh) \
  475         { int fhlen = NFSX_V3FH; \
  476                 if (nfsd->nd_flag & ND_NFSV3) { \
  477                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  478                         fhlen = fxdr_unsigned(int, *tl); \
  479                         if (fhlen > NFSX_V3FHMAX || \
  480                             (fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \
  481                                 error = EBADRPC; \
  482                                 nfsm_reply(0); \
  483                         } \
  484                 } else { \
  485                         fhlen = NFSX_V2FH; \
  486                 } \
  487                 (nsfh)->nsfh_size = fhlen; \
  488                 if (fhlen != 0) { \
  489                         nfsm_dissect(tl, u_int32_t *, fhlen); \
  490                         memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \
  491                 } \
  492         }
  493 
  494 #define nfsm_clget \
  495                 if (bp >= be) { \
  496                         if (mp == mb) \
  497                                 mp->m_len += bp-bpos; \
  498                         mp = m_get(M_WAIT, MT_DATA); \
  499                         MCLAIM(mp, &nfs_mowner); \
  500                         m_clget(mp, M_WAIT); \
  501                         mp->m_len = NFSMSIZ(mp); \
  502                         mp2->m_next = mp; \
  503                         mp2 = mp; \
  504                         bp = mtod(mp, caddr_t); \
  505                         be = bp+mp->m_len; \
  506                 } \
  507                 tl = (u_int32_t *)bp
  508 
  509 #define nfsm_srvfillattr(a, f) \
  510                 nfsm_srvfattr(nfsd, (a), (f))
  511 
  512 #define nfsm_srvwcc_data(br, b, ar, a) \
  513                 nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
  514 
  515 #define nfsm_srvpostop_attr(r, a) \
  516                 nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
  517 
  518 #define nfsm_srvsattr(a) \
  519                 { \
  520                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  521                 if (*tl == nfs_true) { \
  522                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  523                         (a)->va_mode = nfstov_mode(*tl); \
  524                 } \
  525                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  526                 if (*tl == nfs_true) { \
  527                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  528                         (a)->va_uid = fxdr_unsigned(uid_t, *tl); \
  529                 } \
  530                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  531                 if (*tl == nfs_true) { \
  532                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  533                         (a)->va_gid = fxdr_unsigned(gid_t, *tl); \
  534                 } \
  535                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  536                 if (*tl == nfs_true) { \
  537                         nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
  538                         (a)->va_size = fxdr_hyper(tl); \
  539                 } \
  540                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  541                 switch (fxdr_unsigned(int, *tl)) { \
  542                 case NFSV3SATTRTIME_TOCLIENT: \
  543                         nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
  544                         fxdr_nfsv3time(tl, &(a)->va_atime); \
  545                         break; \
  546                 case NFSV3SATTRTIME_TOSERVER: \
  547                         getnanotime(&(a)->va_atime); \
  548                         (a)->va_vaflags |= VA_UTIMES_NULL; \
  549                         break; \
  550                 }; \
  551                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  552                 switch (fxdr_unsigned(int, *tl)) { \
  553                 case NFSV3SATTRTIME_TOCLIENT: \
  554                         nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
  555                         fxdr_nfsv3time(tl, &(a)->va_mtime); \
  556                         (a)->va_vaflags &= ~VA_UTIMES_NULL; \
  557                         break; \
  558                 case NFSV3SATTRTIME_TOSERVER: \
  559                         getnanotime(&(a)->va_mtime); \
  560                         (a)->va_vaflags |= VA_UTIMES_NULL; \
  561                         break; \
  562                 }; }
  563 
  564 #endif

Cache object: fcea3b68c18093367f084a905a3371a9


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