1*6ca35587Sdholland /* $NetBSD: nfscl.h,v 1.1.1.1 2013/09/30 07:19:39 dholland Exp $ */ 2*6ca35587Sdholland /*- 3*6ca35587Sdholland * Copyright (c) 2009 Rick Macklem, University of Guelph 4*6ca35587Sdholland * All rights reserved. 5*6ca35587Sdholland * 6*6ca35587Sdholland * Redistribution and use in source and binary forms, with or without 7*6ca35587Sdholland * modification, are permitted provided that the following conditions 8*6ca35587Sdholland * are met: 9*6ca35587Sdholland * 1. Redistributions of source code must retain the above copyright 10*6ca35587Sdholland * notice, this list of conditions and the following disclaimer. 11*6ca35587Sdholland * 2. Redistributions in binary form must reproduce the above copyright 12*6ca35587Sdholland * notice, this list of conditions and the following disclaimer in the 13*6ca35587Sdholland * documentation and/or other materials provided with the distribution. 14*6ca35587Sdholland * 15*6ca35587Sdholland * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*6ca35587Sdholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*6ca35587Sdholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*6ca35587Sdholland * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*6ca35587Sdholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*6ca35587Sdholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*6ca35587Sdholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*6ca35587Sdholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*6ca35587Sdholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*6ca35587Sdholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*6ca35587Sdholland * SUCH DAMAGE. 26*6ca35587Sdholland * 27*6ca35587Sdholland * FreeBSD: head/sys/fs/nfs/nfscl.h 244042 2012-12-08 22:52:39Z rmacklem 28*6ca35587Sdholland * $NetBSD: nfscl.h,v 1.1.1.1 2013/09/30 07:19:39 dholland Exp $ 29*6ca35587Sdholland */ 30*6ca35587Sdholland 31*6ca35587Sdholland #ifndef _NFS_NFSCL_H 32*6ca35587Sdholland #define _NFS_NFSCL_H 33*6ca35587Sdholland 34*6ca35587Sdholland /* 35*6ca35587Sdholland * Extra stuff for a NFSv4 nfsnode. 36*6ca35587Sdholland * MALLOC'd to the correct length for the name and file handle. 37*6ca35587Sdholland * n4_data has the file handle, followed by the file name. 38*6ca35587Sdholland * The macro NFS4NODENAME() returns a pointer to the start of the 39*6ca35587Sdholland * name. 40*6ca35587Sdholland */ 41*6ca35587Sdholland struct nfsv4node { 42*6ca35587Sdholland u_int16_t n4_fhlen; 43*6ca35587Sdholland u_int16_t n4_namelen; 44*6ca35587Sdholland u_int8_t n4_data[1]; 45*6ca35587Sdholland }; 46*6ca35587Sdholland 47*6ca35587Sdholland #define NFS4NODENAME(n) (&((n)->n4_data[(n)->n4_fhlen])) 48*6ca35587Sdholland 49*6ca35587Sdholland /* 50*6ca35587Sdholland * Just a macro to convert the nfscl_reqstart arguments. 51*6ca35587Sdholland */ 52*6ca35587Sdholland #define NFSCL_REQSTART(n, p, v) \ 53*6ca35587Sdholland nfscl_reqstart((n), (p), VFSTONFS((v)->v_mount), \ 54*6ca35587Sdholland VTONFS(v)->n_fhp->nfh_fh, VTONFS(v)->n_fhp->nfh_len, NULL, NULL) 55*6ca35587Sdholland 56*6ca35587Sdholland /* 57*6ca35587Sdholland * These two macros convert between a lease duration and renew interval. 58*6ca35587Sdholland * For now, just make the renew interval 1/2 the lease duration. 59*6ca35587Sdholland * (They should be inverse operators.) 60*6ca35587Sdholland */ 61*6ca35587Sdholland #define NFSCL_RENEW(l) (((l) < 2) ? 1 : ((l) / 2)) 62*6ca35587Sdholland #define NFSCL_LEASE(r) ((r) * 2) 63*6ca35587Sdholland 64*6ca35587Sdholland /* 65*6ca35587Sdholland * These flag bits are used for the argument to nfscl_fillsattr() to 66*6ca35587Sdholland * indicate special handling of the attributes. 67*6ca35587Sdholland */ 68*6ca35587Sdholland #define NFSSATTR_FULL 0x1 69*6ca35587Sdholland #define NFSSATTR_SIZE0 0x2 70*6ca35587Sdholland #define NFSSATTR_SIZENEG1 0x4 71*6ca35587Sdholland #define NFSSATTR_SIZERDEV 0x8 72*6ca35587Sdholland 73*6ca35587Sdholland /* Use this macro for debug printfs. */ 74*6ca35587Sdholland #define NFSCL_DEBUG(level, ...) do { \ 75*6ca35587Sdholland if (nfscl_debuglevel >= (level)) \ 76*6ca35587Sdholland printf(__VA_ARGS__); \ 77*6ca35587Sdholland } while (0) 78*6ca35587Sdholland 79*6ca35587Sdholland #endif /* _NFS_NFSCL_H */ 80