]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | /* |
3 | * linux/fs/lockd/svc4proc.c | |
4 | * | |
5 | * Lockd server procedures. We don't implement the NLM_*_RES | |
6 | * procedures because we don't use the async procedures. | |
7 | * | |
8 | * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> | |
9 | */ | |
10 | ||
11 | #include <linux/types.h> | |
12 | #include <linux/time.h> | |
1da177e4 LT |
13 | #include <linux/lockd/lockd.h> |
14 | #include <linux/lockd/share.h> | |
5ccb0066 | 15 | #include <linux/sunrpc/svc_xprt.h> |
1da177e4 LT |
16 | |
17 | #define NLMDBG_FACILITY NLMDBG_CLIENT | |
18 | ||
1da177e4 LT |
19 | /* |
20 | * Obtain client and file from arguments | |
21 | */ | |
52921e02 | 22 | static __be32 |
1da177e4 LT |
23 | nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, |
24 | struct nlm_host **hostp, struct nlm_file **filp) | |
25 | { | |
26 | struct nlm_host *host = NULL; | |
27 | struct nlm_file *file = NULL; | |
28 | struct nlm_lock *lock = &argp->lock; | |
52921e02 | 29 | __be32 error = 0; |
1da177e4 LT |
30 | |
31 | /* nfsd callbacks must have been installed for this procedure */ | |
32 | if (!nlmsvc_ops) | |
33 | return nlm_lck_denied_nolocks; | |
34 | ||
35 | /* Obtain host handle */ | |
db4e4c9a | 36 | if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len)) |
977faf39 | 37 | || (argp->monitor && nsm_monitor(host) < 0)) |
1da177e4 LT |
38 | goto no_locks; |
39 | *hostp = host; | |
40 | ||
41 | /* Obtain file pointer. Not used by FREE_ALL call. */ | |
42 | if (filp != NULL) { | |
43 | if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0) | |
44 | goto no_locks; | |
45 | *filp = file; | |
46 | ||
47 | /* Set up the missing parts of the file_lock structure */ | |
48 | lock->fl.fl_file = file->f_file; | |
1da177e4 | 49 | lock->fl.fl_lmops = &nlmsvc_lock_operations; |
89e0edfb BC |
50 | nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid); |
51 | if (!lock->fl.fl_owner) { | |
52 | /* lockowner allocation has failed */ | |
53 | nlmsvc_release_host(host); | |
54 | return nlm_lck_denied_nolocks; | |
55 | } | |
1da177e4 LT |
56 | } |
57 | ||
58 | return 0; | |
59 | ||
60 | no_locks: | |
67216b94 | 61 | nlmsvc_release_host(host); |
1da177e4 LT |
62 | if (error) |
63 | return error; | |
64 | return nlm_lck_denied_nolocks; | |
65 | } | |
66 | ||
67 | /* | |
68 | * NULL: Test for presence of service | |
69 | */ | |
7111c66e | 70 | static __be32 |
a6beb732 | 71 | nlm4svc_proc_null(struct svc_rqst *rqstp) |
1da177e4 LT |
72 | { |
73 | dprintk("lockd: NULL called\n"); | |
74 | return rpc_success; | |
75 | } | |
76 | ||
77 | /* | |
78 | * TEST: Check for conflicting lock | |
79 | */ | |
7111c66e | 80 | static __be32 |
a6beb732 | 81 | __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp) |
1da177e4 | 82 | { |
a6beb732 | 83 | struct nlm_args *argp = rqstp->rq_argp; |
1da177e4 LT |
84 | struct nlm_host *host; |
85 | struct nlm_file *file; | |
317602f3 | 86 | __be32 rc = rpc_success; |
1da177e4 LT |
87 | |
88 | dprintk("lockd: TEST4 called\n"); | |
89 | resp->cookie = argp->cookie; | |
90 | ||
1da177e4 LT |
91 | /* Obtain client and file */ |
92 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | |
d343fce1 | 93 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
1da177e4 LT |
94 | |
95 | /* Now check for conflicting locks */ | |
8f920d5e | 96 | resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie); |
5ea0d750 | 97 | if (resp->status == nlm_drop_reply) |
b7e6b869 OD |
98 | rc = rpc_drop_reply; |
99 | else | |
100 | dprintk("lockd: TEST4 status %d\n", ntohl(resp->status)); | |
1da177e4 | 101 | |
89e0edfb | 102 | nlmsvc_release_lockowner(&argp->lock); |
67216b94 | 103 | nlmsvc_release_host(host); |
1da177e4 | 104 | nlm_release_file(file); |
b7e6b869 | 105 | return rc; |
1da177e4 LT |
106 | } |
107 | ||
7111c66e | 108 | static __be32 |
a6beb732 | 109 | nlm4svc_proc_test(struct svc_rqst *rqstp) |
1da177e4 | 110 | { |
a6beb732 CH |
111 | return __nlm4svc_proc_test(rqstp, rqstp->rq_resp); |
112 | } | |
113 | ||
114 | static __be32 | |
115 | __nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp) | |
116 | { | |
117 | struct nlm_args *argp = rqstp->rq_argp; | |
1da177e4 LT |
118 | struct nlm_host *host; |
119 | struct nlm_file *file; | |
317602f3 | 120 | __be32 rc = rpc_success; |
1da177e4 LT |
121 | |
122 | dprintk("lockd: LOCK called\n"); | |
123 | ||
124 | resp->cookie = argp->cookie; | |
125 | ||
1da177e4 LT |
126 | /* Obtain client and file */ |
127 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | |
d343fce1 | 128 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
1da177e4 LT |
129 | |
130 | #if 0 | |
131 | /* If supplied state doesn't match current state, we assume it's | |
132 | * an old request that time-warped somehow. Any error return would | |
133 | * do in this case because it's irrelevant anyway. | |
134 | * | |
135 | * NB: We don't retrieve the remote host's state yet. | |
136 | */ | |
137 | if (host->h_nsmstate && host->h_nsmstate != argp->state) { | |
138 | resp->status = nlm_lck_denied_nolocks; | |
139 | } else | |
140 | #endif | |
141 | ||
142 | /* Now try to lock the file */ | |
6cde4de8 | 143 | resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock, |
b2b50289 BF |
144 | argp->block, &argp->cookie, |
145 | argp->reclaim); | |
1a8322b2 | 146 | if (resp->status == nlm_drop_reply) |
b7e6b869 OD |
147 | rc = rpc_drop_reply; |
148 | else | |
149 | dprintk("lockd: LOCK status %d\n", ntohl(resp->status)); | |
1da177e4 | 150 | |
89e0edfb | 151 | nlmsvc_release_lockowner(&argp->lock); |
67216b94 | 152 | nlmsvc_release_host(host); |
1da177e4 | 153 | nlm_release_file(file); |
b7e6b869 | 154 | return rc; |
1da177e4 LT |
155 | } |
156 | ||
7111c66e | 157 | static __be32 |
a6beb732 CH |
158 | nlm4svc_proc_lock(struct svc_rqst *rqstp) |
159 | { | |
160 | return __nlm4svc_proc_lock(rqstp, rqstp->rq_resp); | |
161 | } | |
162 | ||
163 | static __be32 | |
164 | __nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_res *resp) | |
1da177e4 | 165 | { |
a6beb732 | 166 | struct nlm_args *argp = rqstp->rq_argp; |
1da177e4 LT |
167 | struct nlm_host *host; |
168 | struct nlm_file *file; | |
169 | ||
170 | dprintk("lockd: CANCEL called\n"); | |
171 | ||
172 | resp->cookie = argp->cookie; | |
173 | ||
174 | /* Don't accept requests during grace period */ | |
5ccb0066 | 175 | if (locks_in_grace(SVC_NET(rqstp))) { |
1da177e4 LT |
176 | resp->status = nlm_lck_denied_grace_period; |
177 | return rpc_success; | |
178 | } | |
179 | ||
180 | /* Obtain client and file */ | |
181 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | |
d343fce1 | 182 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
1da177e4 LT |
183 | |
184 | /* Try to cancel request. */ | |
5ccb0066 | 185 | resp->status = nlmsvc_cancel_blocked(SVC_NET(rqstp), file, &argp->lock); |
1da177e4 LT |
186 | |
187 | dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); | |
89e0edfb | 188 | nlmsvc_release_lockowner(&argp->lock); |
67216b94 | 189 | nlmsvc_release_host(host); |
1da177e4 LT |
190 | nlm_release_file(file); |
191 | return rpc_success; | |
192 | } | |
193 | ||
a6beb732 CH |
194 | static __be32 |
195 | nlm4svc_proc_cancel(struct svc_rqst *rqstp) | |
196 | { | |
197 | return __nlm4svc_proc_cancel(rqstp, rqstp->rq_resp); | |
198 | } | |
199 | ||
1da177e4 LT |
200 | /* |
201 | * UNLOCK: release a lock | |
202 | */ | |
7111c66e | 203 | static __be32 |
a6beb732 | 204 | __nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_res *resp) |
1da177e4 | 205 | { |
a6beb732 | 206 | struct nlm_args *argp = rqstp->rq_argp; |
1da177e4 LT |
207 | struct nlm_host *host; |
208 | struct nlm_file *file; | |
209 | ||
210 | dprintk("lockd: UNLOCK called\n"); | |
211 | ||
212 | resp->cookie = argp->cookie; | |
213 | ||
214 | /* Don't accept new lock requests during grace period */ | |
5ccb0066 | 215 | if (locks_in_grace(SVC_NET(rqstp))) { |
1da177e4 LT |
216 | resp->status = nlm_lck_denied_grace_period; |
217 | return rpc_success; | |
218 | } | |
219 | ||
220 | /* Obtain client and file */ | |
221 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | |
d343fce1 | 222 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
1da177e4 LT |
223 | |
224 | /* Now try to remove the lock */ | |
5ccb0066 | 225 | resp->status = nlmsvc_unlock(SVC_NET(rqstp), file, &argp->lock); |
1da177e4 LT |
226 | |
227 | dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); | |
89e0edfb | 228 | nlmsvc_release_lockowner(&argp->lock); |
67216b94 | 229 | nlmsvc_release_host(host); |
1da177e4 LT |
230 | nlm_release_file(file); |
231 | return rpc_success; | |
232 | } | |
233 | ||
a6beb732 CH |
234 | static __be32 |
235 | nlm4svc_proc_unlock(struct svc_rqst *rqstp) | |
236 | { | |
237 | return __nlm4svc_proc_unlock(rqstp, rqstp->rq_resp); | |
238 | } | |
239 | ||
1da177e4 LT |
240 | /* |
241 | * GRANTED: A server calls us to tell that a process' lock request | |
242 | * was granted | |
243 | */ | |
7111c66e | 244 | static __be32 |
a6beb732 | 245 | __nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_res *resp) |
1da177e4 | 246 | { |
a6beb732 CH |
247 | struct nlm_args *argp = rqstp->rq_argp; |
248 | ||
1da177e4 LT |
249 | resp->cookie = argp->cookie; |
250 | ||
251 | dprintk("lockd: GRANTED called\n"); | |
dcff09f1 | 252 | resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock); |
1da177e4 LT |
253 | dprintk("lockd: GRANTED status %d\n", ntohl(resp->status)); |
254 | return rpc_success; | |
255 | } | |
256 | ||
a6beb732 CH |
257 | static __be32 |
258 | nlm4svc_proc_granted(struct svc_rqst *rqstp) | |
259 | { | |
260 | return __nlm4svc_proc_granted(rqstp, rqstp->rq_resp); | |
261 | } | |
262 | ||
d4716624 TM |
263 | /* |
264 | * This is the generic lockd callback for async RPC calls | |
265 | */ | |
266 | static void nlm4svc_callback_exit(struct rpc_task *task, void *data) | |
267 | { | |
c041b5ff | 268 | dprintk("lockd: %5u callback returned %d\n", task->tk_pid, |
d4716624 TM |
269 | -task->tk_status); |
270 | } | |
271 | ||
272 | static void nlm4svc_callback_release(void *data) | |
273 | { | |
7db836d4 | 274 | nlmsvc_release_call(data); |
d4716624 TM |
275 | } |
276 | ||
277 | static const struct rpc_call_ops nlm4svc_callback_ops = { | |
278 | .rpc_call_done = nlm4svc_callback_exit, | |
279 | .rpc_release = nlm4svc_callback_release, | |
280 | }; | |
281 | ||
1da177e4 LT |
282 | /* |
283 | * `Async' versions of the above service routines. They aren't really, | |
284 | * because we send the callback before the reply proper. I hope this | |
285 | * doesn't break any clients. | |
286 | */ | |
a6beb732 CH |
287 | static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, |
288 | __be32 (*func)(struct svc_rqst *, struct nlm_res *)) | |
1da177e4 | 289 | { |
a6beb732 | 290 | struct nlm_args *argp = rqstp->rq_argp; |
d4716624 TM |
291 | struct nlm_host *host; |
292 | struct nlm_rqst *call; | |
7111c66e | 293 | __be32 stat; |
1da177e4 | 294 | |
db4e4c9a OK |
295 | host = nlmsvc_lookup_host(rqstp, |
296 | argp->lock.caller, | |
297 | argp->lock.len); | |
d4716624 TM |
298 | if (host == NULL) |
299 | return rpc_system_err; | |
300 | ||
301 | call = nlm_alloc_call(host); | |
446945ab | 302 | nlmsvc_release_host(host); |
d4716624 TM |
303 | if (call == NULL) |
304 | return rpc_system_err; | |
305 | ||
a6beb732 | 306 | stat = func(rqstp, &call->a_res); |
d4716624 | 307 | if (stat != 0) { |
7db836d4 | 308 | nlmsvc_release_call(call); |
d4716624 TM |
309 | return stat; |
310 | } | |
1da177e4 | 311 | |
d4716624 TM |
312 | call->a_flags = RPC_TASK_ASYNC; |
313 | if (nlm_async_reply(call, proc, &nlm4svc_callback_ops) < 0) | |
314 | return rpc_system_err; | |
315 | return rpc_success; | |
1da177e4 LT |
316 | } |
317 | ||
a6beb732 | 318 | static __be32 nlm4svc_proc_test_msg(struct svc_rqst *rqstp) |
1da177e4 | 319 | { |
d4716624 | 320 | dprintk("lockd: TEST_MSG called\n"); |
a6beb732 | 321 | return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, __nlm4svc_proc_test); |
d4716624 | 322 | } |
1da177e4 | 323 | |
a6beb732 | 324 | static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp) |
d4716624 | 325 | { |
1da177e4 | 326 | dprintk("lockd: LOCK_MSG called\n"); |
a6beb732 | 327 | return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, __nlm4svc_proc_lock); |
1da177e4 LT |
328 | } |
329 | ||
a6beb732 | 330 | static __be32 nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp) |
1da177e4 | 331 | { |
1da177e4 | 332 | dprintk("lockd: CANCEL_MSG called\n"); |
a6beb732 | 333 | return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, __nlm4svc_proc_cancel); |
1da177e4 LT |
334 | } |
335 | ||
a6beb732 | 336 | static __be32 nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp) |
1da177e4 | 337 | { |
1da177e4 | 338 | dprintk("lockd: UNLOCK_MSG called\n"); |
a6beb732 | 339 | return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, __nlm4svc_proc_unlock); |
1da177e4 LT |
340 | } |
341 | ||
a6beb732 | 342 | static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp) |
1da177e4 | 343 | { |
1da177e4 | 344 | dprintk("lockd: GRANTED_MSG called\n"); |
a6beb732 | 345 | return nlm4svc_callback(rqstp, NLMPROC_GRANTED_RES, __nlm4svc_proc_granted); |
1da177e4 LT |
346 | } |
347 | ||
348 | /* | |
349 | * SHARE: create a DOS share or alter existing share. | |
350 | */ | |
7111c66e | 351 | static __be32 |
a6beb732 | 352 | nlm4svc_proc_share(struct svc_rqst *rqstp) |
1da177e4 | 353 | { |
a6beb732 CH |
354 | struct nlm_args *argp = rqstp->rq_argp; |
355 | struct nlm_res *resp = rqstp->rq_resp; | |
1da177e4 LT |
356 | struct nlm_host *host; |
357 | struct nlm_file *file; | |
358 | ||
359 | dprintk("lockd: SHARE called\n"); | |
360 | ||
361 | resp->cookie = argp->cookie; | |
362 | ||
363 | /* Don't accept new lock requests during grace period */ | |
5ccb0066 | 364 | if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) { |
1da177e4 LT |
365 | resp->status = nlm_lck_denied_grace_period; |
366 | return rpc_success; | |
367 | } | |
368 | ||
369 | /* Obtain client and file */ | |
370 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | |
d343fce1 | 371 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
1da177e4 LT |
372 | |
373 | /* Now try to create the share */ | |
374 | resp->status = nlmsvc_share_file(host, file, argp); | |
375 | ||
376 | dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); | |
89e0edfb | 377 | nlmsvc_release_lockowner(&argp->lock); |
67216b94 | 378 | nlmsvc_release_host(host); |
1da177e4 LT |
379 | nlm_release_file(file); |
380 | return rpc_success; | |
381 | } | |
382 | ||
383 | /* | |
384 | * UNSHARE: Release a DOS share. | |
385 | */ | |
7111c66e | 386 | static __be32 |
a6beb732 | 387 | nlm4svc_proc_unshare(struct svc_rqst *rqstp) |
1da177e4 | 388 | { |
a6beb732 CH |
389 | struct nlm_args *argp = rqstp->rq_argp; |
390 | struct nlm_res *resp = rqstp->rq_resp; | |
1da177e4 LT |
391 | struct nlm_host *host; |
392 | struct nlm_file *file; | |
393 | ||
394 | dprintk("lockd: UNSHARE called\n"); | |
395 | ||
396 | resp->cookie = argp->cookie; | |
397 | ||
398 | /* Don't accept requests during grace period */ | |
5ccb0066 | 399 | if (locks_in_grace(SVC_NET(rqstp))) { |
1da177e4 LT |
400 | resp->status = nlm_lck_denied_grace_period; |
401 | return rpc_success; | |
402 | } | |
403 | ||
404 | /* Obtain client and file */ | |
405 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | |
d343fce1 | 406 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
1da177e4 LT |
407 | |
408 | /* Now try to lock the file */ | |
409 | resp->status = nlmsvc_unshare_file(host, file, argp); | |
410 | ||
411 | dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); | |
89e0edfb | 412 | nlmsvc_release_lockowner(&argp->lock); |
67216b94 | 413 | nlmsvc_release_host(host); |
1da177e4 LT |
414 | nlm_release_file(file); |
415 | return rpc_success; | |
416 | } | |
417 | ||
418 | /* | |
419 | * NM_LOCK: Create an unmonitored lock | |
420 | */ | |
7111c66e | 421 | static __be32 |
a6beb732 | 422 | nlm4svc_proc_nm_lock(struct svc_rqst *rqstp) |
1da177e4 | 423 | { |
a6beb732 CH |
424 | struct nlm_args *argp = rqstp->rq_argp; |
425 | ||
1da177e4 LT |
426 | dprintk("lockd: NM_LOCK called\n"); |
427 | ||
428 | argp->monitor = 0; /* just clean the monitor flag */ | |
a6beb732 | 429 | return nlm4svc_proc_lock(rqstp); |
1da177e4 LT |
430 | } |
431 | ||
432 | /* | |
433 | * FREE_ALL: Release all locks and shares held by client | |
434 | */ | |
7111c66e | 435 | static __be32 |
a6beb732 | 436 | nlm4svc_proc_free_all(struct svc_rqst *rqstp) |
1da177e4 | 437 | { |
a6beb732 | 438 | struct nlm_args *argp = rqstp->rq_argp; |
1da177e4 LT |
439 | struct nlm_host *host; |
440 | ||
441 | /* Obtain client */ | |
442 | if (nlm4svc_retrieve_args(rqstp, argp, &host, NULL)) | |
443 | return rpc_success; | |
444 | ||
445 | nlmsvc_free_host_resources(host); | |
67216b94 | 446 | nlmsvc_release_host(host); |
1da177e4 LT |
447 | return rpc_success; |
448 | } | |
449 | ||
450 | /* | |
451 | * SM_NOTIFY: private callback from statd (not part of official NLM proto) | |
452 | */ | |
7111c66e | 453 | static __be32 |
a6beb732 | 454 | nlm4svc_proc_sm_notify(struct svc_rqst *rqstp) |
1da177e4 | 455 | { |
a6beb732 CH |
456 | struct nlm_reboot *argp = rqstp->rq_argp; |
457 | ||
1da177e4 | 458 | dprintk("lockd: SM_NOTIFY called\n"); |
b85e4676 CL |
459 | |
460 | if (!nlm_privileged_requester(rqstp)) { | |
ad06e4bd CL |
461 | char buf[RPC_MAX_ADDRBUFLEN]; |
462 | printk(KERN_WARNING "lockd: rejected NSM callback from %s\n", | |
463 | svc_print_addr(rqstp, buf, sizeof(buf))); | |
1da177e4 LT |
464 | return rpc_system_err; |
465 | } | |
466 | ||
0ad95472 | 467 | nlm_host_rebooted(SVC_NET(rqstp), argp); |
1da177e4 LT |
468 | return rpc_success; |
469 | } | |
470 | ||
471 | /* | |
472 | * client sent a GRANTED_RES, let's remove the associated block | |
473 | */ | |
7111c66e | 474 | static __be32 |
a6beb732 | 475 | nlm4svc_proc_granted_res(struct svc_rqst *rqstp) |
1da177e4 | 476 | { |
a6beb732 CH |
477 | struct nlm_res *argp = rqstp->rq_argp; |
478 | ||
1da177e4 LT |
479 | if (!nlmsvc_ops) |
480 | return rpc_success; | |
481 | ||
482 | dprintk("lockd: GRANTED_RES called\n"); | |
483 | ||
39be4502 | 484 | nlmsvc_grant_reply(&argp->cookie, argp->status); |
1da177e4 LT |
485 | return rpc_success; |
486 | } | |
487 | ||
488 | ||
1da177e4 LT |
489 | /* |
490 | * NLM Server procedures. | |
491 | */ | |
492 | ||
493 | #define nlm4svc_encode_norep nlm4svc_encode_void | |
494 | #define nlm4svc_decode_norep nlm4svc_decode_void | |
495 | #define nlm4svc_decode_testres nlm4svc_decode_void | |
496 | #define nlm4svc_decode_lockres nlm4svc_decode_void | |
497 | #define nlm4svc_decode_unlockres nlm4svc_decode_void | |
498 | #define nlm4svc_decode_cancelres nlm4svc_decode_void | |
499 | #define nlm4svc_decode_grantedres nlm4svc_decode_void | |
500 | ||
501 | #define nlm4svc_proc_none nlm4svc_proc_null | |
502 | #define nlm4svc_proc_test_res nlm4svc_proc_null | |
503 | #define nlm4svc_proc_lock_res nlm4svc_proc_null | |
504 | #define nlm4svc_proc_cancel_res nlm4svc_proc_null | |
505 | #define nlm4svc_proc_unlock_res nlm4svc_proc_null | |
506 | ||
507 | struct nlm_void { int dummy; }; | |
508 | ||
509 | #define PROC(name, xargt, xrest, argt, rest, respsize) \ | |
a6beb732 | 510 | { .pc_func = nlm4svc_proc_##name, \ |
026fec7e | 511 | .pc_decode = nlm4svc_decode_##xargt, \ |
63f8de37 | 512 | .pc_encode = nlm4svc_encode_##xrest, \ |
1da177e4 LT |
513 | .pc_release = NULL, \ |
514 | .pc_argsize = sizeof(struct nlm_##argt), \ | |
515 | .pc_ressize = sizeof(struct nlm_##rest), \ | |
516 | .pc_xdrressize = respsize, \ | |
517 | } | |
518 | #define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN)) /* cookie */ | |
519 | #define No (1+1024/4) /* netobj */ | |
520 | #define St 1 /* status */ | |
521 | #define Rg 4 /* range (offset + length) */ | |
860bda29 | 522 | const struct svc_procedure nlmsvc_procedures4[] = { |
1da177e4 LT |
523 | PROC(null, void, void, void, void, 1), |
524 | PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), | |
525 | PROC(lock, lockargs, res, args, res, Ck+St), | |
526 | PROC(cancel, cancargs, res, args, res, Ck+St), | |
527 | PROC(unlock, unlockargs, res, args, res, Ck+St), | |
528 | PROC(granted, testargs, res, args, res, Ck+St), | |
529 | PROC(test_msg, testargs, norep, args, void, 1), | |
530 | PROC(lock_msg, lockargs, norep, args, void, 1), | |
531 | PROC(cancel_msg, cancargs, norep, args, void, 1), | |
532 | PROC(unlock_msg, unlockargs, norep, args, void, 1), | |
533 | PROC(granted_msg, testargs, norep, args, void, 1), | |
534 | PROC(test_res, testres, norep, res, void, 1), | |
535 | PROC(lock_res, lockres, norep, res, void, 1), | |
536 | PROC(cancel_res, cancelres, norep, res, void, 1), | |
537 | PROC(unlock_res, unlockres, norep, res, void, 1), | |
538 | PROC(granted_res, res, norep, res, void, 1), | |
539 | /* statd callback */ | |
540 | PROC(sm_notify, reboot, void, reboot, void, 1), | |
541 | PROC(none, void, void, void, void, 0), | |
542 | PROC(none, void, void, void, void, 0), | |
543 | PROC(none, void, void, void, void, 0), | |
544 | PROC(share, shareargs, shareres, args, res, Ck+St+1), | |
545 | PROC(unshare, shareargs, shareres, args, res, Ck+St+1), | |
546 | PROC(nm_lock, lockargs, res, args, res, Ck+St), | |
547 | PROC(free_all, notify, void, args, void, 1), | |
548 | ||
549 | }; |