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/nfsclient/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 /*
    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  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *      This product includes software developed by the University of
   19  *      California, Berkeley and its contributors.
   20  * 4. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
   37  * $FreeBSD: releng/5.2/sys/nfsclient/nfsm_subs.h 122698 2003-11-14 20:54:10Z alfred $
   38  */
   39 
   40 #ifndef _NFSCLIENT_NFSM_SUBS_H_
   41 #define _NFSCLIENT_NFSM_SUBS_H_
   42 
   43 #include <nfs/nfs_common.h>
   44 
   45 #define nfsv2tov_type(a)        nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
   46 
   47 struct ucred;
   48 struct vnode;
   49 
   50 /*
   51  * These macros do strange and peculiar things to mbuf chains for
   52  * the assistance of the nfs code. To attempt to use them for any
   53  * other purpose will be dangerous. (they make weird assumptions)
   54  */
   55 
   56 /*
   57  * First define what the actual subs. return
   58  */
   59 struct mbuf *nfsm_reqhead(struct vnode *vp, u_long procid, int hsiz);
   60 struct mbuf *nfsm_rpchead(struct ucred *cr, int nmflag, int procid,
   61                           int auth_type, int auth_len,
   62                           struct mbuf *mrest, int mrest_len,
   63                           struct mbuf **mbp, u_int32_t *xidp);
   64 
   65 #define M_HASCL(m)      ((m)->m_flags & M_EXT)
   66 #define NFSMINOFF(m) \
   67         do { \
   68                 if (M_HASCL(m)) \
   69                         (m)->m_data = (m)->m_ext.ext_buf; \
   70                 else if ((m)->m_flags & M_PKTHDR) \
   71                         (m)->m_data = (m)->m_pktdat; \
   72                 else \
   73                         (m)->m_data = (m)->m_dat; \
   74         } while (0)
   75 #define NFSMSIZ(m)      ((M_HASCL(m))?MCLBYTES: \
   76                                 (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
   77 
   78 /*
   79  * Now for the macros that do the simple stuff and call the functions
   80  * for the hard stuff.
   81  * These macros use several vars. declared in nfsm_reqhead and these
   82  * vars. must not be used elsewhere unless you are careful not to corrupt
   83  * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
   84  * that may be used so long as the value is not expected to retained
   85  * after a macro.
   86  * I know, this is kind of dorkey, but it makes the actual op functions
   87  * fairly clean and deals with the mess caused by the xdr discriminating
   88  * unions.
   89  */
   90 
   91 
   92 /* *********************************** */
   93 /* Request generation phase macros */
   94 
   95 int     nfsm_fhtom_xx(struct vnode *v, int v3, struct mbuf **mb,
   96             caddr_t *bpos);
   97 void    nfsm_v3attrbuild_xx(struct vattr *va, int full, struct mbuf **mb,
   98             caddr_t *bpos);
   99 int     nfsm_strtom_xx(const char *a, int s, int m, struct mbuf **mb,
  100             caddr_t *bpos);
  101 
  102 #define nfsm_bcheck(t1, mreq) \
  103 do { \
  104         if (t1) { \
  105                 error = t1; \
  106                 m_freem(mreq); \
  107                 goto nfsmout; \
  108         } \
  109 } while (0)
  110 
  111 #define nfsm_fhtom(v, v3) \
  112 do { \
  113         int32_t t1; \
  114         t1 = nfsm_fhtom_xx((v), (v3), &mb, &bpos); \
  115         nfsm_bcheck(t1, mreq); \
  116 } while (0)
  117 
  118 /* If full is true, set all fields, otherwise just set mode and time fields */
  119 #define nfsm_v3attrbuild(a, full) \
  120         nfsm_v3attrbuild_xx(a, full, &mb, &bpos)
  121 
  122 #define nfsm_uiotom(p, s) \
  123 do { \
  124         int t1; \
  125         t1 = nfsm_uiotombuf((p), &mb, (s), &bpos); \
  126         nfsm_bcheck(t1, mreq); \
  127 } while (0)
  128 
  129 #define nfsm_strtom(a, s, m) \
  130 do { \
  131         int t1; \
  132         t1 = nfsm_strtom_xx((a), (s), (m), &mb, &bpos); \
  133         nfsm_bcheck(t1, mreq); \
  134 } while (0)
  135 
  136 /* *********************************** */
  137 /* Send the request */
  138 
  139 #define nfsm_request(v, t, p, c) \
  140 do { \
  141         error = nfs_request((v), mreq, (t), (p), (c), &mrep, &md, &dpos); \
  142         if (error != 0) { \
  143                 if (error & NFSERR_RETERR) \
  144                         error &= ~NFSERR_RETERR; \
  145                 else \
  146                         goto nfsmout; \
  147         } \
  148 } while (0)
  149 
  150 #define nfsm_request_mnt(n, t, p, c) \
  151 do { \
  152         error = nfs4_request_mnt((n), mreq, (t), (p), (c), &mrep, &md, &dpos); \
  153         if (error != 0) { \
  154                 if (error & NFSERR_RETERR) \
  155                         error &= ~NFSERR_RETERR; \
  156                 else \
  157                         goto nfsmout; \
  158         } \
  159 } while (0)
  160 
  161 /* *********************************** */
  162 /* Reply interpretation phase macros */
  163 
  164 int     nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f,
  165             struct mbuf **md, caddr_t *dpos);
  166 int     nfsm_getfh_xx(nfsfh_t **f, int *s, int v3, struct mbuf **md,
  167             caddr_t *dpos);
  168 int     nfsm_loadattr_xx(struct vnode **v, struct vattr *va, struct mbuf **md,
  169             caddr_t *dpos);
  170 int     nfsm_postop_attr_xx(struct vnode **v, int *f, struct mbuf **md,
  171             caddr_t *dpos);
  172 int     nfsm_wcc_data_xx(struct vnode **v, int *f, struct mbuf **md,
  173             caddr_t *dpos);
  174 
  175 #define nfsm_mtofh(d, v, v3, f) \
  176 do { \
  177         int32_t t1; \
  178         t1 = nfsm_mtofh_xx((d), &(v), (v3), &(f), &md, &dpos); \
  179         nfsm_dcheck(t1, mrep); \
  180 } while (0)
  181 
  182 #define nfsm_getfh(f, s, v3) \
  183 do { \
  184         int32_t t1; \
  185         t1 = nfsm_getfh_xx(&(f), &(s), (v3), &md, &dpos); \
  186         nfsm_dcheck(t1, mrep); \
  187 } while (0)
  188 
  189 #define nfsm_loadattr(v, a) \
  190 do { \
  191         int32_t t1; \
  192         t1 = nfsm_loadattr_xx(&v, a, &md, &dpos); \
  193         nfsm_dcheck(t1, mrep); \
  194 } while (0)
  195 
  196 #define nfsm_postop_attr(v, f) \
  197 do { \
  198         int32_t t1; \
  199         t1 = nfsm_postop_attr_xx(&v, &f, &md, &dpos); \
  200         nfsm_dcheck(t1, mrep); \
  201 } while (0)
  202 
  203 /* Used as (f) for nfsm_wcc_data() */
  204 #define NFSV3_WCCRATTR  0
  205 #define NFSV3_WCCCHK    1
  206 
  207 #define nfsm_wcc_data(v, f) \
  208 do { \
  209         int32_t t1; \
  210         t1 = nfsm_wcc_data_xx(&v, &f, &md, &dpos); \
  211         nfsm_dcheck(t1, mrep); \
  212 } while (0)
  213 
  214 #endif

Cache object: 5df041c2233dff34fa61c8f0e655f5b0


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