1139823Simp/*- 21541Srgrimes * Copyright (c) 1989, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley by 61541Srgrimes * Rick Macklem at The University of Guelph. 71541Srgrimes * 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 4. Neither the name of the University nor the names of its contributors 171541Srgrimes * may be used to endorse or promote products derived from this software 181541Srgrimes * without specific prior written permission. 191541Srgrimes * 201541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301541Srgrimes * SUCH DAMAGE. 311541Srgrimes * 3222521Sdyson * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 3350477Speter * $FreeBSD: releng/11.0/sys/nfsclient/nfsm_subs.h 248198 2013-03-12 12:23:47Z glebius $ 341541Srgrimes */ 351541Srgrimes 3683651Speter#ifndef _NFSCLIENT_NFSM_SUBS_H_ 3783651Speter#define _NFSCLIENT_NFSM_SUBS_H_ 3822521Sdyson 3983651Speter#include <nfs/nfs_common.h> 402175Spaul 4183651Speter#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] 4283651Speter 4333054Sbdestruct ucred; 4433054Sbdestruct vnode; 459336Sdfr 461541Srgrimes/* 471541Srgrimes * These macros do strange and peculiar things to mbuf chains for 481541Srgrimes * the assistance of the nfs code. To attempt to use them for any 491541Srgrimes * other purpose will be dangerous. (they make weird assumptions) 501541Srgrimes */ 511541Srgrimes 521541Srgrimes/* 531541Srgrimes * First define what the actual subs. return 541541Srgrimes */ 55176224Sjhbu_int32_t nfs_xid_gen(void); 561541Srgrimes 5784079Speter/* *********************************** */ 5884079Speter/* Request generation phase macros */ 5984079Speter 6088091Siedowseint nfsm_fhtom_xx(struct vnode *v, int v3, struct mbuf **mb, 6188091Siedowse caddr_t *bpos); 6288091Siedowsevoid nfsm_v3attrbuild_xx(struct vattr *va, int full, struct mbuf **mb, 6388091Siedowse caddr_t *bpos); 6488091Siedowseint nfsm_strtom_xx(const char *a, int s, int m, struct mbuf **mb, 6588091Siedowse caddr_t *bpos); 661541Srgrimes 6784079Speter#define nfsm_bcheck(t1, mreq) \ 6883651Speterdo { \ 6983651Speter if (t1) { \ 7083651Speter error = t1; \ 7183651Speter m_freem(mreq); \ 7283651Speter goto nfsmout; \ 7383651Speter } \ 7483651Speter} while (0) 751541Srgrimes 7684079Speter#define nfsm_fhtom(v, v3) \ 7784079Speterdo { \ 7884079Speter int32_t t1; \ 7988091Siedowse t1 = nfsm_fhtom_xx((v), (v3), &mb, &bpos); \ 8084079Speter nfsm_bcheck(t1, mreq); \ 8184079Speter} while (0) 8284079Speter 8384079Speter/* If full is true, set all fields, otherwise just set mode and time fields */ 8484079Speter#define nfsm_v3attrbuild(a, full) \ 8588091Siedowse nfsm_v3attrbuild_xx(a, full, &mb, &bpos) 8684079Speter 8784079Speter#define nfsm_uiotom(p, s) \ 8884079Speterdo { \ 8984079Speter int t1; \ 9084079Speter t1 = nfsm_uiotombuf((p), &mb, (s), &bpos); \ 9184079Speter nfsm_bcheck(t1, mreq); \ 9284079Speter} while (0) 9384079Speter 9484079Speter#define nfsm_strtom(a, s, m) \ 9584079Speterdo { \ 9684079Speter int t1; \ 9788091Siedowse t1 = nfsm_strtom_xx((a), (s), (m), &mb, &bpos); \ 9884079Speter nfsm_bcheck(t1, mreq); \ 9984079Speter} while (0) 10084079Speter 10184079Speter/* *********************************** */ 10284079Speter/* Send the request */ 10384079Speter 10484079Speter#define nfsm_request(v, t, p, c) \ 10584079Speterdo { \ 106138496Sps sigset_t oldset; \ 107138496Sps nfs_set_sigmask(p, &oldset); \ 10884079Speter error = nfs_request((v), mreq, (t), (p), (c), &mrep, &md, &dpos); \ 109138496Sps nfs_restore_sigmask(p, &oldset); \ 11084079Speter if (error != 0) { \ 11184079Speter if (error & NFSERR_RETERR) \ 11284079Speter error &= ~NFSERR_RETERR; \ 11384079Speter else \ 11484079Speter goto nfsmout; \ 11584079Speter } \ 11684079Speter} while (0) 11784079Speter 11884079Speter/* *********************************** */ 11984079Speter/* Reply interpretation phase macros */ 12084079Speter 12184079Speterint nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f, 12284079Speter struct mbuf **md, caddr_t *dpos); 12388091Siedowseint nfsm_getfh_xx(nfsfh_t **f, int *s, int v3, struct mbuf **md, 12488091Siedowse caddr_t *dpos); 12588091Siedowseint nfsm_loadattr_xx(struct vnode **v, struct vattr *va, struct mbuf **md, 12688091Siedowse caddr_t *dpos); 127230394Sjhbint nfsm_postop_attr_xx(struct vnode **v, int *f, struct vattr *va, 128230394Sjhb struct mbuf **md, caddr_t *dpos); 12988091Siedowseint nfsm_wcc_data_xx(struct vnode **v, int *f, struct mbuf **md, 13088091Siedowse caddr_t *dpos); 13184079Speter 1329336Sdfr#define nfsm_mtofh(d, v, v3, f) \ 13383651Speterdo { \ 13483651Speter int32_t t1; \ 13588091Siedowse t1 = nfsm_mtofh_xx((d), &(v), (v3), &(f), &md, &dpos); \ 13684079Speter nfsm_dcheck(t1, mrep); \ 13783651Speter} while (0) 1381541Srgrimes 1399336Sdfr#define nfsm_getfh(f, s, v3) \ 14083651Speterdo { \ 14183651Speter int32_t t1; \ 14288091Siedowse t1 = nfsm_getfh_xx(&(f), &(s), (v3), &md, &dpos); \ 14384079Speter nfsm_dcheck(t1, mrep); \ 14483651Speter} while (0) 1459336Sdfr 1469336Sdfr#define nfsm_loadattr(v, a) \ 14783651Speterdo { \ 14883651Speter int32_t t1; \ 14988091Siedowse t1 = nfsm_loadattr_xx(&v, a, &md, &dpos); \ 15084079Speter nfsm_dcheck(t1, mrep); \ 15183651Speter} while (0) 1521541Srgrimes 1539336Sdfr#define nfsm_postop_attr(v, f) \ 15483651Speterdo { \ 15583651Speter int32_t t1; \ 156230394Sjhb t1 = nfsm_postop_attr_xx(&v, &f, NULL, &md, &dpos); \ 15784079Speter nfsm_dcheck(t1, mrep); \ 15883651Speter} while (0) 1599336Sdfr 160230394Sjhb#define nfsm_postop_attr_va(v, f, va) \ 161230394Sjhbdo { \ 162230394Sjhb int32_t t1; \ 163230394Sjhb t1 = nfsm_postop_attr_xx(&v, &f, va, &md, &dpos); \ 164230394Sjhb nfsm_dcheck(t1, mrep); \ 165230394Sjhb} while (0) 166230394Sjhb 1679336Sdfr/* Used as (f) for nfsm_wcc_data() */ 1689336Sdfr#define NFSV3_WCCRATTR 0 1699336Sdfr#define NFSV3_WCCCHK 1 1709336Sdfr 1719336Sdfr#define nfsm_wcc_data(v, f) \ 17283651Speterdo { \ 17383651Speter int32_t t1; \ 17488091Siedowse t1 = nfsm_wcc_data_xx(&v, &f, &md, &dpos); \ 17584079Speter nfsm_dcheck(t1, mrep); \ 17683651Speter} while (0) 1779336Sdfr 1782175Spaul#endif 179