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