1 /*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
33 * $FreeBSD$
34 */
35
36 #ifndef _NFSSERVER_NFSM_SUBS_H_
37 #define _NFSSERVER_NFSM_SUBS_H_
38
39 #include <nfs/nfs_common.h>
40
41 #define nfstov_mode(a) (fxdr_unsigned(u_int32_t, (a)) & ALLPERMS)
42
43 /*
44 * These macros do strange and peculiar things to mbuf chains for
45 * the assistance of the nfs code. To attempt to use them for any
46 * other purpose will be dangerous. (they make weird assumptions)
47 */
48
49 /*
50 * Now for the macros that do the simple stuff and call the functions
51 * for the hard stuff.
52 * These macros use several vars. declared in nfsm_reqhead and these
53 * vars. must not be used elsewhere unless you are careful not to corrupt
54 * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
55 * that may be used so long as the value is not expected to retained
56 * after a macro.
57 * I know, this is kind of dorkey, but it makes the actual op functions
58 * fairly clean and deals with the mess caused by the xdr discriminating
59 * unions.
60 */
61
62
63
64 /* ************************************* */
65 /* Dissection phase macros */
66
67 int nfsm_srvstrsiz_xx(int *s, int m, struct mbuf **md, caddr_t *dpos);
68 int nfsm_srvnamesiz_xx(int *s, int m, struct mbuf **md, caddr_t *dpos);
69 int nfsm_srvnamesiz0_xx(int *s, int m, struct mbuf **md, caddr_t *dpos);
70 int nfsm_srvmtofh_xx(fhandle_t *f, int v3, struct mbuf **md, caddr_t *dpos);
71 int nfsm_srvsattr_xx(struct vattr *a, struct mbuf **md, caddr_t *dpos);
72
73 #define nfsm_srvstrsiz(s, m) \
74 do { \
75 int t1; \
76 t1 = nfsm_srvstrsiz_xx(&(s), (m), &md, &dpos); \
77 if (t1) { \
78 error = t1; \
79 nfsm_reply(0); \
80 } \
81 } while (0)
82
83 #define nfsm_srvnamesiz(s) \
84 do { \
85 int t1; \
86 t1 = nfsm_srvnamesiz_xx(&(s), NFS_MAXNAMLEN, &md, &dpos); \
87 if (t1) { \
88 error = t1; \
89 nfsm_reply(0); \
90 } \
91 } while (0)
92
93 #define nfsm_srvpathsiz(s) \
94 do { \
95 int t1; \
96 t1 = nfsm_srvnamesiz0_xx(&(s), NFS_MAXPATHLEN, &md, &dpos); \
97 if (t1) { \
98 error = t1; \
99 nfsm_reply(0); \
100 } \
101 } while (0)
102
103 #define nfsm_srvmtofh(f) \
104 do { \
105 int t1; \
106 t1 = nfsm_srvmtofh_xx((f), nfsd->nd_flag & ND_NFSV3, &md, &dpos); \
107 if (t1) { \
108 error = t1; \
109 nfsm_reply(0); \
110 } \
111 } while (0)
112
113 /* XXX why is this different? */
114 #define nfsm_srvsattr(a) \
115 do { \
116 int t1; \
117 t1 = nfsm_srvsattr_xx((a), &md, &dpos); \
118 if (t1) { \
119 error = t1; \
120 m_freem(mrep); \
121 mrep = NULL; \
122 goto nfsmout; \
123 } \
124 } while (0)
125
126 /* ************************************* */
127 /* Prepare the reply */
128
129 #define nfsm_reply(s) \
130 do { \
131 if (mrep != NULL) { \
132 m_freem(mrep); \
133 mrep = NULL; \
134 } \
135 mreq = nfs_rephead((s), nfsd, error, &mb, &bpos); \
136 *mrq = mreq; \
137 if (error == EBADRPC) { \
138 error = 0; \
139 goto nfsmout; \
140 } \
141 } while (0)
142
143 #define nfsm_writereply(s) \
144 do { \
145 mreq = nfs_rephead((s), nfsd, error, &mb, &bpos); \
146 } while(0)
147
148 /* ************************************* */
149 /* Reply phase macros - add additional reply info */
150
151 void nfsm_srvfhtom_xx(fhandle_t *f, int v3, struct mbuf **mb,
152 caddr_t *bpos);
153 void nfsm_srvpostop_fh_xx(fhandle_t *f, struct mbuf **mb, caddr_t *bpos);
154 void nfsm_clget_xx(u_int32_t **tl, struct mbuf *mb, struct mbuf **mp,
155 char **bp, char **be, caddr_t bpos);
156
157 #define nfsm_srvfhtom(f, v3) \
158 nfsm_srvfhtom_xx((f), (v3), &mb, &bpos)
159
160 #define nfsm_srvpostop_fh(f) \
161 nfsm_srvpostop_fh_xx((f), &mb, &bpos)
162
163 #define nfsm_srvwcc_data(br, b, ar, a) \
164 nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos)
165
166 #define nfsm_srvpostop_attr(r, a) \
167 nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
168
169 #define nfsm_srvfillattr(a, f) \
170 nfsm_srvfattr(nfsd, (a), (f))
171
172 #define nfsm_clget \
173 nfsm_clget_xx(&tl, mb, &mp, &bp, &be, bpos)
174
175 #endif
Cache object: 2d7df3b09d171ab771b1c6f1025370e1
|