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

Cache object: fb37860cbfd03124e54fd3dded5849c6


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