10 #include <linux/types.h>
11 #include <linux/time.h>
16 #define NLMDBG_FACILITY NLMDBG_CLIENT
18 #ifdef CONFIG_LOCKD_V4
42 #define cast_status(status) (cast_to_nlm(status, rqstp->rq_vers))
44 #define cast_status(status) (status)
52 struct nlm_host **hostp,
struct nlm_file **filp)
77 lock->
fl.fl_file = file->f_file;
97 dprintk(
"lockd: NULL called\n");
108 struct nlm_host *
host;
109 struct nlm_file *
file;
112 dprintk(
"lockd: TEST called\n");
116 if ((resp->
status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
124 dprintk(
"lockd: TEST status %d vers %d\n",
136 struct nlm_host *host;
137 struct nlm_file *
file;
140 dprintk(
"lockd: LOCK called\n");
145 if ((resp->
status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
155 if (host->h_nsmstate && host->h_nsmstate != argp->
state) {
178 struct nlm_host *host;
179 struct nlm_file *
file;
182 dprintk(
"lockd: CANCEL called\n");
193 if ((resp->
status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
212 struct nlm_host *host;
213 struct nlm_file *
file;
214 struct net *net =
SVC_NET(rqstp);
216 dprintk(
"lockd: UNLOCK called\n");
227 if ((resp->
status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
249 dprintk(
"lockd: GRANTED called\n");
260 dprintk(
"lockd: %5u callback returned %d\n", task->tk_pid,
272 static void nlmsvc_callback_release(
void *
data)
277 static const struct rpc_call_ops nlmsvc_callback_ops = {
278 .rpc_call_done = nlmsvc_callback_exit,
279 .rpc_release = nlmsvc_callback_release,
290 struct nlm_host *host;
291 struct nlm_rqst *call;
298 return rpc_system_err;
303 return rpc_system_err;
305 stat =
func(rqstp, argp, &call->a_res);
313 return rpc_system_err;
320 dprintk(
"lockd: TEST_MSG called\n");
327 dprintk(
"lockd: LOCK_MSG called\n");
334 dprintk(
"lockd: CANCEL_MSG called\n");
342 dprintk(
"lockd: UNLOCK_MSG called\n");
350 dprintk(
"lockd: GRANTED_MSG called\n");
361 struct nlm_host *host;
362 struct nlm_file *
file;
364 dprintk(
"lockd: SHARE called\n");
375 if ((resp->
status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
394 struct nlm_host *host;
395 struct nlm_file *
file;
397 dprintk(
"lockd: UNSHARE called\n");
408 if ((resp->
status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
427 dprintk(
"lockd: NM_LOCK called\n");
430 return nlmsvc_proc_lock(rqstp, argp, resp);
440 struct nlm_host *host;
443 if (nlmsvc_retrieve_args(rqstp, argp, &host,
NULL))
458 dprintk(
"lockd: SM_NOTIFY called\n");
460 if (!nlm_privileged_requester(rqstp)) {
464 return rpc_system_err;
481 dprintk(
"lockd: GRANTED_RES called\n");
491 #define nlmsvc_encode_norep nlmsvc_encode_void
492 #define nlmsvc_decode_norep nlmsvc_decode_void
493 #define nlmsvc_decode_testres nlmsvc_decode_void
494 #define nlmsvc_decode_lockres nlmsvc_decode_void
495 #define nlmsvc_decode_unlockres nlmsvc_decode_void
496 #define nlmsvc_decode_cancelres nlmsvc_decode_void
497 #define nlmsvc_decode_grantedres nlmsvc_decode_void
499 #define nlmsvc_proc_none nlmsvc_proc_null
500 #define nlmsvc_proc_test_res nlmsvc_proc_null
501 #define nlmsvc_proc_lock_res nlmsvc_proc_null
502 #define nlmsvc_proc_cancel_res nlmsvc_proc_null
503 #define nlmsvc_proc_unlock_res nlmsvc_proc_null
507 #define PROC(name, xargt, xrest, argt, rest, respsize) \
508 { .pc_func = (svc_procfunc) nlmsvc_proc_##name, \
509 .pc_decode = (kxdrproc_t) nlmsvc_decode_##xargt, \
510 .pc_encode = (kxdrproc_t) nlmsvc_encode_##xrest, \
511 .pc_release = NULL, \
512 .pc_argsize = sizeof(struct nlm_##argt), \
513 .pc_ressize = sizeof(struct nlm_##rest), \
514 .pc_xdrressize = respsize, \
517 #define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN))
519 #define No (1+1024/4)
523 PROC(null,
void,
void,
void,
void, 1),
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),
540 PROC(sm_notify, reboot,
void, reboot,
void, 1),
541 PROC(
none,
void,
void,
void,
void, 1),
542 PROC(
none,
void,
void,
void,
void, 1),
543 PROC(
none,
void,
void,
void,
void, 1),