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