xdr.c (71af75b6929458d85f63c0649dc26d6f4c19729e) xdr.c (16c663642c7ec03cd4cee5fec520bb69e97babe4)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/lockd/xdr.c
4 *
5 * XDR support for lockd and the lock client.
6 *
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8 */

--- 132 unchanged lines hidden (view full) ---

141}
142
143
144/*
145 * Decode Call arguments
146 */
147
148int
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/lockd/xdr.c
4 *
5 * XDR support for lockd and the lock client.
6 *
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8 */

--- 132 unchanged lines hidden (view full) ---

141}
142
143
144/*
145 * Decode Call arguments
146 */
147
148int
149nlmsvc_decode_void(struct svc_rqst *rqstp, __be32 *p)
149nlmsvc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
150{
151 return 1;
152}
153
154int
150{
151 return 1;
152}
153
154int
155nlmsvc_decode_testargs(struct svc_rqst *rqstp, __be32 *p)
155nlmsvc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
156{
156{
157 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
158 struct nlm_args *argp = rqstp->rq_argp;
159 u32 exclusive;
160
161 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
162 return 0;
163 if (xdr_stream_decode_bool(xdr, &exclusive) < 0)
164 return 0;
165 if (!svcxdr_decode_lock(xdr, &argp->lock))
166 return 0;
167 if (exclusive)
168 argp->lock.fl.fl_type = F_WRLCK;
169
170 return 1;
171}
172
173int
157 struct nlm_args *argp = rqstp->rq_argp;
158 u32 exclusive;
159
160 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
161 return 0;
162 if (xdr_stream_decode_bool(xdr, &exclusive) < 0)
163 return 0;
164 if (!svcxdr_decode_lock(xdr, &argp->lock))
165 return 0;
166 if (exclusive)
167 argp->lock.fl.fl_type = F_WRLCK;
168
169 return 1;
170}
171
172int
174nlmsvc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p)
173nlmsvc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
175{
174{
176 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
177 struct nlm_args *argp = rqstp->rq_argp;
178 u32 exclusive;
179
180 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
181 return 0;
182 if (xdr_stream_decode_bool(xdr, &argp->block) < 0)
183 return 0;
184 if (xdr_stream_decode_bool(xdr, &exclusive) < 0)

--- 7 unchanged lines hidden (view full) ---

192 if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
193 return 0;
194 argp->monitor = 1; /* monitor client by default */
195
196 return 1;
197}
198
199int
175 struct nlm_args *argp = rqstp->rq_argp;
176 u32 exclusive;
177
178 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
179 return 0;
180 if (xdr_stream_decode_bool(xdr, &argp->block) < 0)
181 return 0;
182 if (xdr_stream_decode_bool(xdr, &exclusive) < 0)

--- 7 unchanged lines hidden (view full) ---

190 if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
191 return 0;
192 argp->monitor = 1; /* monitor client by default */
193
194 return 1;
195}
196
197int
200nlmsvc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p)
198nlmsvc_decode_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
201{
199{
202 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
203 struct nlm_args *argp = rqstp->rq_argp;
204 u32 exclusive;
205
206 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
207 return 0;
208 if (xdr_stream_decode_bool(xdr, &argp->block) < 0)
209 return 0;
210 if (xdr_stream_decode_bool(xdr, &exclusive) < 0)
211 return 0;
212 if (!svcxdr_decode_lock(xdr, &argp->lock))
213 return 0;
214 if (exclusive)
215 argp->lock.fl.fl_type = F_WRLCK;
216
217 return 1;
218}
219
220int
200 struct nlm_args *argp = rqstp->rq_argp;
201 u32 exclusive;
202
203 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
204 return 0;
205 if (xdr_stream_decode_bool(xdr, &argp->block) < 0)
206 return 0;
207 if (xdr_stream_decode_bool(xdr, &exclusive) < 0)
208 return 0;
209 if (!svcxdr_decode_lock(xdr, &argp->lock))
210 return 0;
211 if (exclusive)
212 argp->lock.fl.fl_type = F_WRLCK;
213
214 return 1;
215}
216
217int
221nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p)
218nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
222{
219{
223 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
224 struct nlm_args *argp = rqstp->rq_argp;
225
226 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
227 return 0;
228 if (!svcxdr_decode_lock(xdr, &argp->lock))
229 return 0;
230 argp->lock.fl.fl_type = F_UNLCK;
231
232 return 1;
233}
234
235int
220 struct nlm_args *argp = rqstp->rq_argp;
221
222 if (!svcxdr_decode_cookie(xdr, &argp->cookie))
223 return 0;
224 if (!svcxdr_decode_lock(xdr, &argp->lock))
225 return 0;
226 argp->lock.fl.fl_type = F_UNLCK;
227
228 return 1;
229}
230
231int
236nlmsvc_decode_res(struct svc_rqst *rqstp, __be32 *p)
232nlmsvc_decode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr)
237{
233{
238 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
239 struct nlm_res *resp = rqstp->rq_argp;
240
241 if (!svcxdr_decode_cookie(xdr, &resp->cookie))
242 return 0;
243 if (!svcxdr_decode_stats(xdr, &resp->status))
244 return 0;
245
246 return 1;
247}
248
249int
234 struct nlm_res *resp = rqstp->rq_argp;
235
236 if (!svcxdr_decode_cookie(xdr, &resp->cookie))
237 return 0;
238 if (!svcxdr_decode_stats(xdr, &resp->status))
239 return 0;
240
241 return 1;
242}
243
244int
250nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
245nlmsvc_decode_reboot(struct svc_rqst *rqstp, struct xdr_stream *xdr)
251{
246{
252 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
253 struct nlm_reboot *argp = rqstp->rq_argp;
247 struct nlm_reboot *argp = rqstp->rq_argp;
248 __be32 *p;
254 u32 len;
255
256 if (xdr_stream_decode_u32(xdr, &len) < 0)
257 return 0;
258 if (len > SM_MAXSTRLEN)
259 return 0;
260 p = xdr_inline_decode(xdr, len);
261 if (!p)

--- 6 unchanged lines hidden (view full) ---

268 if (!p)
269 return 0;
270 memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
271
272 return 1;
273}
274
275int
249 u32 len;
250
251 if (xdr_stream_decode_u32(xdr, &len) < 0)
252 return 0;
253 if (len > SM_MAXSTRLEN)
254 return 0;
255 p = xdr_inline_decode(xdr, len);
256 if (!p)

--- 6 unchanged lines hidden (view full) ---

263 if (!p)
264 return 0;
265 memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
266
267 return 1;
268}
269
270int
276nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
271nlmsvc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
277{
272{
278 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
279 struct nlm_args *argp = rqstp->rq_argp;
280 struct nlm_lock *lock = &argp->lock;
281
282 memset(lock, 0, sizeof(*lock));
283 locks_init_lock(&lock->fl);
284 lock->svid = ~(u32)0;
285
286 if (!svcxdr_decode_cookie(xdr, &argp->cookie))

--- 9 unchanged lines hidden (view full) ---

296 return 0;
297 if (xdr_stream_decode_u32(xdr, &argp->fsm_access) < 0)
298 return 0;
299
300 return 1;
301}
302
303int
273 struct nlm_args *argp = rqstp->rq_argp;
274 struct nlm_lock *lock = &argp->lock;
275
276 memset(lock, 0, sizeof(*lock));
277 locks_init_lock(&lock->fl);
278 lock->svid = ~(u32)0;
279
280 if (!svcxdr_decode_cookie(xdr, &argp->cookie))

--- 9 unchanged lines hidden (view full) ---

290 return 0;
291 if (xdr_stream_decode_u32(xdr, &argp->fsm_access) < 0)
292 return 0;
293
294 return 1;
295}
296
297int
304nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p)
298nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr)
305{
299{
306 struct xdr_stream *xdr = &rqstp->rq_arg_stream;
307 struct nlm_args *argp = rqstp->rq_argp;
308 struct nlm_lock *lock = &argp->lock;
309
310 if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len))
311 return 0;
312 if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
313 return 0;
314

--- 50 unchanged lines hidden ---
300 struct nlm_args *argp = rqstp->rq_argp;
301 struct nlm_lock *lock = &argp->lock;
302
303 if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len))
304 return 0;
305 if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
306 return 0;
307

--- 50 unchanged lines hidden ---