/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
*/
/*
* These macros do strange and peculiar things to mbuf chains for
* the assistance of the nfs code. To attempt to use them for any
* other purpose will be dangerous. (they make weird assumptions)
*/
/*
* NFSv2 can only handle signed 32bit quantities and some clients
* get confused by larger than 16bit block sizes. Limit values
* for better compatibility.
*/
#define NFS_V2CLAMP32(x) ((x) > INT32_MAX ? INT32_MAX : (int32_t)(x))
#define NFS_V2CLAMP16(x) ((x) > INT16_MAX ? INT16_MAX : (int32_t)(x))
/*
* Now for the macros that do the simple stuff and call the functions
* for the hard stuff.
* These macros use several vars. declared in nfsm_reqhead and these
* vars. must not be used elsewhere unless you are careful not to corrupt
* them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
* that may be used so long as the value is not expected to retained
* after a macro.
* I know, this is kind of dorkey, but it makes the actual op functions
* fairly clean and deals with the mess caused by the xdr discriminating
* unions.
*/
/*
* nfsm_mtofh: dissect a "resulted obj" part of create-like operations
* like mkdir.
*
* for nfsv3, dissect post_op_fh3 and following post_op_attr.
* for nfsv2, dissect fhandle and following fattr.
*
* d: (IN) the vnode of the parent directory.
* v: (OUT) the corresponding vnode (we allocate one if needed)
* v3: (IN) true for nfsv3.
* f: (OUT) true if we got valid filehandle. always true for nfsv2.
*/
/*
* nfsm_postop_attr: process nfsv3 post_op_attr
*
* dissect post_op_attr. if we got a one,
* call nfsm_loadattrcache to update attribute cache.
*
* v: (IN/OUT) the corresponding vnode
* f: (OUT) true if we got valid attribute
* flags: (IN) flags for nfsm_loadattrcache
*/
/*
* nfsm_wcc_data: process nfsv3 wcc_data
*
* dissect pre_op_attr and then let nfsm_postop_attr dissect post_op_attr.
*
* v: (IN/OUT) the corresponding vnode
* f: (IN/OUT)
* NFSV3_WCCRATTR return true if we got valid post_op_attr.
* NFSV3_WCCCHK return true if pre_op_attr's mtime is the same
* as our n_mtime. (ie. our cache isn't stale.)
* flags: (IN) flags for nfsm_loadattrcache
* docheck: (IN) true if timestamp change is expected
*/
/* Used as (f) for nfsm_wcc_data() */
#define NFSV3_WCCRATTR 0
#define NFSV3_WCCCHK 1