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  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: nfsm_subs.h,v 1.50.52.1 2009/04/13 21:06:50 snj 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, char *); \
   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, char *) + 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(tl,(n)->n_fhp, (n)->n_fhsize); \
  109                         } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
  110                                 (void *)(n)->n_fhp, (n)->n_fhsize)) != 0) { \
  111                                 error = t2; \
  112                                 m_freem(mreq); \
  113                                 goto nfsmout; \
  114                         } \
  115                 } else { \
  116                         nfsm_build(cp, void *, NFSX_V2FH); \
  117                         memcpy(cp, (n)->n_fhp, NFSX_V2FH); \
  118                 } }
  119 
  120 #define nfsm_srvfhtom(f, v3) \
  121                 { if (v3) { \
  122                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + \
  123                             NFSRVFH_SIZE(f)); \
  124                         *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
  125                         memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
  126                 } else { \
  127                         KASSERT(NFSRVFH_SIZE(f) == NFSX_V2FH); \
  128                         nfsm_build(cp, void *, NFSX_V2FH); \
  129                         memcpy(cp, NFSRVFH_DATA(f), NFSX_V2FH); \
  130                 } }
  131 
  132 #define nfsm_srvpostop_fh(f) \
  133                 { nfsm_build(tl, u_int32_t *, \
  134                     2 * NFSX_UNSIGNED + NFSRVFH_SIZE(f)); \
  135                 *tl++ = nfs_true; \
  136                 *tl++ = txdr_unsigned(NFSRVFH_SIZE(f)); \
  137                 memcpy(tl, NFSRVFH_DATA(f), NFSRVFH_SIZE(f)); \
  138                 }
  139 
  140 /*
  141  * nfsm_mtofh: dissect a "resulted obj" part of create-like operations
  142  * like mkdir.
  143  *
  144  * for nfsv3, dissect post_op_fh3 and following post_op_attr.
  145  * for nfsv2, dissect fhandle and following fattr.
  146  *
  147  * d: (IN) the vnode of the parent directry.
  148  * v: (OUT) the corresponding vnode (we allocate one if needed)
  149  * v3: (IN) true for nfsv3.
  150  * f: (OUT) true if we got valid filehandle.  always true for nfsv2.
  151  */
  152 
  153 #define nfsm_mtofh(d, v, v3, f) \
  154                 { struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
  155                 int hasattr = 0; \
  156                 if (v3) { \
  157                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  158                         (f) = fxdr_unsigned(int, *tl); \
  159                 } else { \
  160                         (f) = 1; \
  161                         hasattr = 1; \
  162                 } \
  163                 if (f) { \
  164                         nfsm_getfh(ttfhp, ttfhsize, (v3)); \
  165                         if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
  166                                 &ttnp)) != 0) { \
  167                                 error = t1; \
  168                                 m_freem(mrep); \
  169                                 goto nfsmout; \
  170                         } \
  171                         (v) = NFSTOV(ttnp); \
  172                 } \
  173                 if (v3) { \
  174                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  175                         if (f) \
  176                                 hasattr = fxdr_unsigned(int, *tl); \
  177                         else if (fxdr_unsigned(int, *tl)) \
  178                                 nfsm_adv(NFSX_V3FATTR); \
  179                 } \
  180                 if (f && hasattr) \
  181                         nfsm_loadattr((v), (struct vattr *)0, 0); \
  182                 }
  183 
  184 /*
  185  * nfsm_getfh: dissect a filehandle.
  186  *
  187  * f: (OUT) a filehandle.
  188  * s: (OUT) size of the filehandle in bytes.
  189  * v3: (IN) true if nfsv3.
  190  */
  191 
  192 #define nfsm_getfh(f, s, v3) \
  193                 { if (v3) { \
  194                         nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  195                         if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
  196                                 (s) > NFSX_V3FHMAX) { \
  197                                 m_freem(mrep); \
  198                                 error = EBADRPC; \
  199                                 goto nfsmout; \
  200                         } \
  201                 } else \
  202                         (s) = NFSX_V2FH; \
  203                 nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
  204 
  205 #define nfsm_loadattr(v, a, flags) \
  206                 { struct vnode *ttvp = (v); \
  207                 if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, (a), (flags))) \
  208                     != 0) { \
  209                         error = t1; \
  210                         m_freem(mrep); \
  211                         goto nfsmout; \
  212                 } \
  213                 (v) = ttvp; }
  214 
  215 /*
  216  * nfsm_postop_attr: process nfsv3 post_op_attr
  217  *
  218  * dissect post_op_attr.  if we got a one,
  219  * call nfsm_loadattrcache to update attribute cache.
  220  *
  221  * v: (IN/OUT) the corresponding vnode
  222  * f: (OUT) true if we got valid attribute
  223  * flags: (IN) flags for nfsm_loadattrcache
  224  */
  225 
  226 #define nfsm_postop_attr(v, f, flags) \
  227                 { struct vnode *ttvp = (v); \
  228                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  229                 if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
  230                         if ((t1 = nfsm_loadattrcache(&ttvp, &md, &dpos, \
  231                                 (struct vattr *)0, (flags))) != 0) { \
  232                                 error = t1; \
  233                                 (f) = 0; \
  234                                 m_freem(mrep); \
  235                                 goto nfsmout; \
  236                         } \
  237                         (v) = ttvp; \
  238                 } }
  239 
  240 /*
  241  * nfsm_wcc_data: process nfsv3 wcc_data
  242  *
  243  * dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
  244  *
  245  * v: (IN/OUT) the corresponding vnode
  246  * f: (IN/OUT)
  247  *      NFSV3_WCCRATTR  return true if we got valid post_op_attr.
  248  *      NFSV3_WCCCHK    return true if pre_op_attr's mtime is the same
  249  *                      as our n_mtime.  (ie. our cache isn't stale.)
  250  * flags: (IN) flags for nfsm_loadattrcache
  251  * docheck: (IN) true if timestamp change is expected
  252  */
  253 
  254 /* Used as (f) for nfsm_wcc_data() */
  255 #define NFSV3_WCCRATTR  0
  256 #define NFSV3_WCCCHK    1
  257 
  258 #define nfsm_wcc_data(v, f, flags, docheck) \
  259                 { int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \
  260                 struct timespec ctime, mtime; \
  261                 struct nfsnode *nfsp = VTONFS(v); \
  262                 bool haspreopattr = false; \
  263                 nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
  264                 if (*tl == nfs_true) { \
  265                         haspreopattr = true; \
  266                         nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
  267                         fxdr_nfsv3time(tl + 2, &mtime); \
  268                         fxdr_nfsv3time(tl + 4, &ctime); \
  269                         if (nfsp->n_ctime == ctime.tv_sec) \
  270                                 renewctime = 1; \
  271                         if ((v)->v_type == VDIR) { \
  272                                 if (timespeccmp(&nfsp->n_nctime, &ctime, ==)) \
  273                                         renewnctime = 1; \
  274                         } \
  275                         if (f) { \
  276                                 ttretf = timespeccmp(&nfsp->n_mtime, &mtime, ==);\
  277                         } \
  278                 } \
  279                 nfsm_postop_attr((v), ttattrf, (flags)); \
  280                 nfsp = VTONFS(v); \
  281                 if (ttattrf) { \
  282                         if (haspreopattr && \
  283                             nfs_check_wccdata(nfsp, &ctime, &mtime, (docheck))) \
  284                                 renewctime = renewnctime = ttretf = 0; \
  285                         if (renewctime) \
  286                                 nfsp->n_ctime = nfsp->n_vattr->va_ctime.tv_sec; \
  287                         if (renewnctime) \
  288                                 nfsp->n_nctime = nfsp->n_vattr->va_ctime; \
  289                 } \
  290                 if (f) { \
  291                         (f) = ttretf; \
  292                 } else { \
  293                         (f) = ttattrf; \
  294                 } }
  295 
  296 /* If full is true, set all fields, otherwise just set mode and time fields */
  297 #define nfsm_v3attrbuild(a, full)                                               \
  298                 { if ((a)->va_mode != (mode_t)VNOVAL) {                         \
  299                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  300                         *tl++ = nfs_true;                                       \
  301                         *tl = txdr_unsigned((a)->va_mode);                      \
  302                 } else {                                                        \
  303                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  304                         *tl = nfs_false;                                        \
  305                 }                                                               \
  306                 if ((full) && (a)->va_uid != (uid_t)VNOVAL) {                   \
  307                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  308                         *tl++ = nfs_true;                                       \
  309                         *tl = txdr_unsigned((a)->va_uid);                       \
  310                 } else {                                                        \
  311                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  312                         *tl = nfs_false;                                        \
  313                 }                                                               \
  314                 if ((full) && (a)->va_gid != (gid_t)VNOVAL) {                   \
  315                         nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);         \
  316                         *tl++ = nfs_true;                                       \
  317                         *tl = txdr_unsigned((a)->va_gid);                       \
  318                 } else {                                                        \
  319                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  320                         *tl = nfs_false;                                        \
  321                 }                                                               \
  322                 if ((full) && (a)->va_size != VNOVAL) {                         \
  323                         nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);         \
  324                         *tl++ = nfs_true;                                       \
  325                         txdr_hyper((a)->va_size, tl);                           \
  326                 } else {                                                        \
  327                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  328                         *tl = nfs_false;                                        \
  329                 }                                                               \
  330                 if ((a)->va_atime.tv_sec != VNOVAL) {                           \
  331                         if ((a)->va_atime.tv_sec != time_second) {              \
  332                                 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
  333                                 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
  334                                 txdr_nfsv3time(&(a)->va_atime, tl);             \
  335                         } else {                                                \
  336                                 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);     \
  337                                 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);   \
  338                         }                                                       \
  339                 } else {                                                        \
  340                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  341                         *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);         \
  342                 }                                                               \
  343                 if ((a)->va_mtime.tv_sec != VNOVAL) {                           \
  344                         if ((a)->va_mtime.tv_sec != time_second) {              \
  345                                 nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
  346                                 *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
  347                                 txdr_nfsv3time(&(a)->va_mtime, tl);             \
  348                         } else {                                                \
  349                                 nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);     \
  350                                 *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);   \
  351                         }                                                       \
  352                 } else {                                                        \
  353                         nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);             \
  354                         *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);         \
  355                 }                                                               \
  356                 }
  357 
  358 
  359 #define nfsm_strsiz(s,m) \
  360                 { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
  361                 if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
  362                         m_freem(mrep); \
  363                         error = EBADRPC; \
  364                         goto nfsmout; \
  365                 } }
  366 
  367 #define nfsm_srvnamesiz(s) \
  368                 { nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
  369                 if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
  370                         error = NFSERR_NAMETOL; \
  371                 if (error) \
  372                         nfsm_reply(0); \
  373                 }
  374 
  375 #define nfsm_mtouio(p,s) \
  376                 if ((s) > 0 && \
  377                    (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
  378                         error = t1; \
  379                         m_freem(mrep); \
  380                         goto nfsmout; \
  381                 }
  382 
  383 #define nfsm_uiotom(p,s) \
  384                 if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
  385                         error = t1; \
  386                         m_freem(mreq); \
  387                         goto nfsmout; \
  388                 }
  389 
  390 #define nfsm_reqhead(n,a,s) \
  391                 mb = mreq = nfsm_reqh((n),(a),(s),&bpos)
  392 
  393 #define nfsm_reqdone    m_freem(mrep); \
  394                 nfsmout:
  395 
  396 #define nfsm_rndup(a)   (((a)+3)&(~0x3))
  397 #define nfsm_padlen(a)  (nfsm_rndup(a) - (a))
  398 
  399 #define nfsm_request1(v, t, p, c, rexmitp)      \
  400                 if ((error = nfs_request((v), mreq, (t), (p), \
  401                    (c), &mrep, &md, &dpos, (rexmitp))) != 0) { \
  402                         if (error & NFSERR_RETERR) \
  403                                 error &= ~NFSERR_RETERR; \
  404                         else \
  405                                 goto nfsmout; \
  406                 }
  407 
  408 #define nfsm_request(v, t, p, c)        nfsm_request1((v), (t), (p), (c), NULL)
  409 
  410 #define nfsm_strtom(a,s,m) \
  411                 if ((s) > (m)) { \
  412                         m_freem(mreq); \
  413                         error = ENAMETOOLONG; \
  414                         goto nfsmout; \
  415                 } \
  416                 t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
  417                 if (t2 <= M_TRAILINGSPACE(mb)) { \
  418                         nfsm_build(tl,u_int32_t *,t2); \
  419                         *tl++ = txdr_unsigned(s); \
  420                         *(tl+((t2>>2)-2)) = 0; \
  421                         memcpy(tl, (const char *)(a), (s)); \
  422                 } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
  423                         error = t2; \
  424                         m_freem(mreq); \
  425                         goto nfsmout; \
  426                 }
  427 
  428 #define nfsm_srvdone \
  429                 nfsmout: \
  430                 return(error)
  431 
  432 #define nfsm_reply(s) \
  433                 { \
  434                 nfsd->nd_repstat = error; \
  435                 if (error && !(nfsd->nd_flag & ND_NFSV3)) \
  436                    (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
  437                         mrq, &mb, &bpos); \
  438                 else \
  439                    (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
  440                         mrq, &mb, &bpos); \
  441                 if (mrep != NULL) { \
  442                         m_freem(mrep); \
  443                         mrep = NULL; \
  444                 } \
  445                 mreq = *mrq; \
  446                 if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
  447                         error == EBADRPC)) {\
  448                         error = 0; \
  449                         goto nfsmout; \
  450                         } \
  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, char *) + 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, char *); \
  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: c85018c5474159cab48414dd618d001f


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