1191783Srmacklem/*- 2191783Srmacklem * Copyright (c) 2009 Rick Macklem, University of Guelph 3191783Srmacklem * All rights reserved. 4191783Srmacklem * 5191783Srmacklem * Redistribution and use in source and binary forms, with or without 6191783Srmacklem * modification, are permitted provided that the following conditions 7191783Srmacklem * are met: 8191783Srmacklem * 1. Redistributions of source code must retain the above copyright 9191783Srmacklem * notice, this list of conditions and the following disclaimer. 10191783Srmacklem * 2. Redistributions in binary form must reproduce the above copyright 11191783Srmacklem * notice, this list of conditions and the following disclaimer in the 12191783Srmacklem * documentation and/or other materials provided with the distribution. 13191783Srmacklem * 14191783Srmacklem * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15191783Srmacklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16191783Srmacklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17191783Srmacklem * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18191783Srmacklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19191783Srmacklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20191783Srmacklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21191783Srmacklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22191783Srmacklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23191783Srmacklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24191783Srmacklem * SUCH DAMAGE. 25191783Srmacklem * 26191783Srmacklem * $FreeBSD: releng/10.2/sys/fs/nfs/nfscl.h 244042 2012-12-08 22:52:39Z rmacklem $ 27191783Srmacklem */ 28191783Srmacklem 29191783Srmacklem#ifndef _NFS_NFSCL_H 30191783Srmacklem#define _NFS_NFSCL_H 31191783Srmacklem 32191783Srmacklem/* 33191783Srmacklem * Extra stuff for a NFSv4 nfsnode. 34191783Srmacklem * MALLOC'd to the correct length for the name and file handle. 35191783Srmacklem * n4_data has the file handle, followed by the file name. 36191783Srmacklem * The macro NFS4NODENAME() returns a pointer to the start of the 37191783Srmacklem * name. 38191783Srmacklem */ 39191783Srmacklemstruct nfsv4node { 40191783Srmacklem u_int16_t n4_fhlen; 41191783Srmacklem u_int16_t n4_namelen; 42191783Srmacklem u_int8_t n4_data[1]; 43191783Srmacklem}; 44191783Srmacklem 45191783Srmacklem#define NFS4NODENAME(n) (&((n)->n4_data[(n)->n4_fhlen])) 46191783Srmacklem 47191783Srmacklem/* 48191783Srmacklem * Just a macro to convert the nfscl_reqstart arguments. 49191783Srmacklem */ 50191783Srmacklem#define NFSCL_REQSTART(n, p, v) \ 51191783Srmacklem nfscl_reqstart((n), (p), VFSTONFS((v)->v_mount), \ 52244042Srmacklem VTONFS(v)->n_fhp->nfh_fh, VTONFS(v)->n_fhp->nfh_len, NULL, NULL) 53191783Srmacklem 54191783Srmacklem/* 55191783Srmacklem * These two macros convert between a lease duration and renew interval. 56191783Srmacklem * For now, just make the renew interval 1/2 the lease duration. 57191783Srmacklem * (They should be inverse operators.) 58191783Srmacklem */ 59191783Srmacklem#define NFSCL_RENEW(l) (((l) < 2) ? 1 : ((l) / 2)) 60191783Srmacklem#define NFSCL_LEASE(r) ((r) * 2) 61191783Srmacklem 62191783Srmacklem/* 63191783Srmacklem * These flag bits are used for the argument to nfscl_fillsattr() to 64191783Srmacklem * indicate special handling of the attributes. 65191783Srmacklem */ 66191783Srmacklem#define NFSSATTR_FULL 0x1 67191783Srmacklem#define NFSSATTR_SIZE0 0x2 68191783Srmacklem#define NFSSATTR_SIZENEG1 0x4 69191783Srmacklem#define NFSSATTR_SIZERDEV 0x8 70191783Srmacklem 71240289Srmacklem/* Use this macro for debug printfs. */ 72240289Srmacklem#define NFSCL_DEBUG(level, ...) do { \ 73240289Srmacklem if (nfscl_debuglevel >= (level)) \ 74240289Srmacklem printf(__VA_ARGS__); \ 75240289Srmacklem } while (0) 76240289Srmacklem 77191783Srmacklem#endif /* _NFS_NFSCL_H */ 78