summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-04-01 05:30:04 +0000
committerpeter <peter@FreeBSD.org>1996-04-01 05:30:04 +0000
commitf794c0568b6180eca6dd2792d3a5d4315aee4f47 (patch)
tree7048db188c5679e34b709bb5c2a878e6084b96c6 /usr.sbin
parent4673aad9a1e182c91c3ca8f8d864e5d821284dac (diff)
downloadFreeBSD-src-f794c0568b6180eca6dd2792d3a5d4315aee4f47.zip
FreeBSD-src-f794c0568b6180eca6dd2792d3a5d4315aee4f47.tar.gz
Tweaks for the stub lockd.
- Use rpcgen to generate the unmodified boilerplate code rather than having it in the repository. - Eliminate the conflicting function names by changing them to their "natural" rpcgen generated names
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rpc.lockd/Makefile18
-rw-r--r--usr.sbin/rpc.lockd/handles.c2
-rw-r--r--usr.sbin/rpc.lockd/lockd.c224
-rw-r--r--usr.sbin/rpc.lockd/lockd.h2
-rw-r--r--usr.sbin/rpc.lockd/procs.c38
-rw-r--r--usr.sbin/rpc.lockd/test.c4
6 files changed, 46 insertions, 242 deletions
diff --git a/usr.sbin/rpc.lockd/Makefile b/usr.sbin/rpc.lockd/Makefile
index d54358a..e734f58 100644
--- a/usr.sbin/rpc.lockd/Makefile
+++ b/usr.sbin/rpc.lockd/Makefile
@@ -1,14 +1,26 @@
-# $Id$
+# $Id: Makefile,v 1.1.1.1 1996/02/17 15:11:28 peter Exp $
PROG = rpc.lockd
-SRCS = lockd.c procs.c
+SRCS = nlm_prot_svc.c lockd.c procs.c
MAN8 = rpc.lockd.8
DPADD= ${LIBRPCSVC}
LDADD= -lrpcsvc
-.include <bsd.prog.mk>
+CFLAGS+= -I.
+
+CLEANFILES= nlm_prot_svc.c nlm_prot.h
+
+RPCSRC= ${.DESTDIR}/usr/include/rpcsvc/nlm_prot.x
+RPCGEN= rpcgen -L -C
+
+nlm_prot_svc.c: ${RPCSRC} nlm_prot.h
+ ${RPCGEN} -m -o ${.TARGET} ${RPCSRC}
+
+nlm_prot.h: ${RPCSRC}
+ ${RPCGEN} -h -o ${.TARGET} ${RPCSRC}
test: test.c
cc -o test test.c -lrpcsvc
+.include <bsd.prog.mk>
diff --git a/usr.sbin/rpc.lockd/handles.c b/usr.sbin/rpc.lockd/handles.c
index dfb9ad4..047f6d2 100644
--- a/usr.sbin/rpc.lockd/handles.c
+++ b/usr.sbin/rpc.lockd/handles.c
@@ -33,7 +33,7 @@
-#include "lockd.h"
+#include "nlm_prot.h"
/* ------------------------------------------------------------------------- */
/*
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c
index bb8af5b..d68b056 100644
--- a/usr.sbin/rpc.lockd/lockd.c
+++ b/usr.sbin/rpc.lockd/lockd.c
@@ -1,4 +1,3 @@
-
/*
* Copyright (c) 1995
* A.R. Gordon (andrew.gordon@net-tel.co.uk). All rights reserved.
@@ -39,13 +38,12 @@
#include "lockd.h"
+extern void nlm_prog_1 __P((struct svc_req, register SVCXPRT));
+extern void nlm_prog_3 __P((struct svc_req, register SVCXPRT));
int debug_level = 0; /* Zero means no debugging syslog() calls */
-static void nlm_prog_1();
-static void nlm_prog_3();
-
main(int argc, char **argv)
{
SVCXPRT *transp;
@@ -102,8 +100,10 @@ main(int argc, char **argv)
/* Note that it is NOT sensible to run this program from inetd - the */
/* protocol assumes that it will run immediately at boot time. */
- daemon(0, 0);
-
+ if (daemon(0,0)) {
+ perror("cannot fork");
+ exit(1);
+ }
openlog("rpc.lockd", 0, LOG_DAEMON);
if (debug_level) syslog(LOG_INFO, "Starting, debug level %d", debug_level);
else syslog(LOG_INFO, "Starting");
@@ -111,215 +111,3 @@ main(int argc, char **argv)
svc_run(); /* Should never return */
exit(1);
}
-
-static void
-nlm_prog_1(struct svc_req *rqstp, SVCXPRT *transp)
-{
- union
- {
- struct nlm_testargs nlm_test_1_arg;
- struct nlm_lockargs nlm_lock_1_arg;
- struct nlm_cancargs nlm_cancel_1_arg;
- struct nlm_unlockargs nlm_unlock_1_arg;
- struct nlm_testargs nlm_granted_1_arg;
- struct nlm_testargs nlm_test_msg_1_arg;
- struct nlm_lockargs nlm_lock_msg_1_arg;
- struct nlm_cancargs nlm_cancel_msg_1_arg;
- struct nlm_unlockargs nlm_unlock_msg_1_arg;
- struct nlm_testargs nlm_granted_msg_1_arg;
- nlm_testres nlm_test_res_1_arg;
- nlm_res nlm_lock_res_1_arg;
- nlm_res nlm_cancel_res_1_arg;
- nlm_res nlm_unlock_res_1_arg;
- nlm_res nlm_granted_res_1_arg;
- } argument;
- char *result;
- bool_t (*xdr_argument)(), (*xdr_result)();
- char *(*local)();
-
- switch (rqstp->rq_proc)
- {
- case NULLPROC:
- (void)svc_sendreply(transp, xdr_void, (char *)NULL);
- return;
-
- case NLM_TEST:
- xdr_argument = xdr_nlm_testargs;
- xdr_result = xdr_nlm_testres;
- local = (char *(*)()) nlm_test_1;
- break;
-
- case NLM_LOCK:
- xdr_argument = xdr_nlm_lockargs;
- xdr_result = xdr_nlm_res;
- local = (char *(*)()) nlm_lock_1;
- break;
-
- case NLM_CANCEL:
- xdr_argument = xdr_nlm_cancargs;
- xdr_result = xdr_nlm_res;
- local = (char *(*)()) nlm_cancel_1;
- break;
-
- case NLM_UNLOCK:
- xdr_argument = xdr_nlm_unlockargs;
- xdr_result = xdr_nlm_res;
- local = (char *(*)()) nlm_unlock_1;
- break;
-
- case NLM_GRANTED:
- xdr_argument = xdr_nlm_testargs;
- xdr_result = xdr_nlm_res;
- local = (char *(*)()) nlm_granted_1;
- break;
-
- case NLM_TEST_MSG:
- xdr_argument = xdr_nlm_testargs;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_test_msg_1;
- break;
-
- case NLM_LOCK_MSG:
- xdr_argument = xdr_nlm_lockargs;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_lock_msg_1;
- break;
-
- case NLM_CANCEL_MSG:
- xdr_argument = xdr_nlm_cancargs;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_cancel_msg_1;
- break;
-
- case NLM_UNLOCK_MSG:
- xdr_argument = xdr_nlm_unlockargs;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_unlock_msg_1;
- break;
-
- case NLM_GRANTED_MSG:
- xdr_argument = xdr_nlm_testargs;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_granted_msg_1;
- break;
-
- case NLM_TEST_RES:
- xdr_argument = xdr_nlm_testres;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_test_res_1;
- break;
-
- case NLM_LOCK_RES:
- xdr_argument = xdr_nlm_res;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_lock_res_1;
- break;
-
- case NLM_CANCEL_RES:
- xdr_argument = xdr_nlm_res;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_cancel_res_1;
- break;
-
- case NLM_UNLOCK_RES:
- xdr_argument = xdr_nlm_res;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_unlock_res_1;
- break;
-
- case NLM_GRANTED_RES:
- xdr_argument = xdr_nlm_res;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_granted_res_1;
- break;
-
- default:
- svcerr_noproc(transp);
- return;
- }
- bzero((char *)&argument, sizeof(argument));
- if (!svc_getargs(transp, xdr_argument, (caddr_t)&argument))
- {
- syslog(LOG_ERR, "RPC received with invalid arguments");
- svcerr_decode(transp);
- return;
- }
- result = (*local)(&argument, rqstp);
- if (result != NULL && !svc_sendreply(transp, xdr_result, result))
- {
- svcerr_systemerr(transp);
- }
- if (!svc_freeargs(transp, xdr_argument, (caddr_t)&argument))
- {
- syslog(LOG_ERR, "unable to free arguments");
- }
-
-}
-
-
-static void
-nlm_prog_3(struct svc_req *rqstp, SVCXPRT *transp)
-{
- union
- {
- nlm_shareargs nlm_share_3_arg;
- nlm_shareargs nlm_unshare_3_arg;
- nlm_lockargs nlm_nm_lock_3_arg;
- nlm_notify nlm_free_all_3_arg;
- } argument;
- char *result;
- bool_t (*xdr_argument)(), (*xdr_result)();
- char *(*local)();
-
- switch (rqstp->rq_proc)
- {
- case NULLPROC:
- (void)svc_sendreply(transp, xdr_void, (char *)NULL);
- return;
-
- case NLM_SHARE:
- xdr_argument = xdr_nlm_shareargs;
- xdr_result = xdr_nlm_shareres;
- local = (char *(*)()) nlm_share_3;
- break;
-
- case NLM_UNSHARE:
- xdr_argument = xdr_nlm_shareargs;
- xdr_result = xdr_nlm_shareres;
- local = (char *(*)()) nlm_unshare_3;
- break;
-
- case NLM_NM_LOCK:
- xdr_argument = xdr_nlm_lockargs;
- xdr_result = xdr_nlm_res;
- local = (char *(*)()) nlm_nm_lock_3;
- break;
-
- case NLM_FREE_ALL:
- xdr_argument = xdr_nlm_notify;
- xdr_result = xdr_void;
- local = (char *(*)()) nlm_free_all_3;
- break;
-
- default:
- svcerr_noproc(transp);
- return;
- }
- bzero((char *)&argument, sizeof(argument));
- if (!svc_getargs(transp, xdr_argument, (caddr_t)&argument))
- {
- syslog(LOG_ERR, "RPC received with invalid arguments");
- svcerr_decode(transp);
- return;
- }
- result = (*local)(&argument, rqstp);
- if (result != NULL && !svc_sendreply(transp, xdr_result, result))
- {
- svcerr_systemerr(transp);
- }
- if (!svc_freeargs(transp, xdr_argument, (caddr_t)&argument))
- {
- syslog(LOG_ERR, "unable to free arguments");
- }
-}
-
diff --git a/usr.sbin/rpc.lockd/lockd.h b/usr.sbin/rpc.lockd/lockd.h
index 28bc1ae..39586bf 100644
--- a/usr.sbin/rpc.lockd/lockd.h
+++ b/usr.sbin/rpc.lockd/lockd.h
@@ -37,7 +37,7 @@
#include <rpc/rpc.h>
#include <syslog.h>
#include <rpcsvc/sm_inter.h> /* protocol to talk to rpc.statd */
-#include <rpcsvc/nlm_prot.h> /* The protocol we are implementing */
+#include "nlm_prot.h" /* The protocol we are implementing */
/* global variables ------------------------------------------------------- */
diff --git a/usr.sbin/rpc.lockd/procs.c b/usr.sbin/rpc.lockd/procs.c
index 5e0c9ea..54e5f81 100644
--- a/usr.sbin/rpc.lockd/procs.c
+++ b/usr.sbin/rpc.lockd/procs.c
@@ -252,7 +252,7 @@ static void transmit_result(int opcode, nlm_res *result, struct svc_req *req)
Notes:
*/
-nlm_testres *nlm_test_1(nlm_testargs *arg, struct svc_req *rqstp)
+nlm_testres *nlm_test_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
static nlm_testres res;
if (debug_level) log_from_addr("nlm_test", rqstp);
@@ -267,7 +267,7 @@ nlm_testres *nlm_test_1(nlm_testargs *arg, struct svc_req *rqstp)
return (&res);
}
-void *nlm_test_msg_1(nlm_testargs *arg, struct svc_req *rqstp)
+void *nlm_test_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
nlm_testres res;
static char dummy;
@@ -304,7 +304,7 @@ void *nlm_test_msg_1(nlm_testargs *arg, struct svc_req *rqstp)
Notes: *** grace period support missing
*/
-nlm_res *nlm_lock_1(nlm_lockargs *arg, struct svc_req *rqstp)
+nlm_res *nlm_lock_1_svc(nlm_lockargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
if (debug_level) log_from_addr("nlm_lock", rqstp);
@@ -316,7 +316,7 @@ nlm_res *nlm_lock_1(nlm_lockargs *arg, struct svc_req *rqstp)
return (&res);
}
-void *nlm_lock_msg_1(nlm_lockargs *arg, struct svc_req *rqstp)
+void *nlm_lock_msg_1_svc(nlm_lockargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
@@ -336,7 +336,7 @@ void *nlm_lock_msg_1(nlm_lockargs *arg, struct svc_req *rqstp)
Notes:
*/
-nlm_res *nlm_cancel_1(nlm_cancargs *arg, struct svc_req *rqstp)
+nlm_res *nlm_cancel_1_svc(nlm_cancargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
if (debug_level) log_from_addr("nlm_cancel", rqstp);
@@ -350,7 +350,7 @@ nlm_res *nlm_cancel_1(nlm_cancargs *arg, struct svc_req *rqstp)
return (&res);
}
-void *nlm_cancel_msg_1(nlm_cancargs *arg, struct svc_req *rqstp)
+void *nlm_cancel_msg_1_svc(nlm_cancargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
if (debug_level) log_from_addr("nlm_cancel_msg", rqstp);
@@ -372,7 +372,7 @@ void *nlm_cancel_msg_1(nlm_cancargs *arg, struct svc_req *rqstp)
re-try an unlock that has already succeeded.
*/
-nlm_res *nlm_unlock_1(nlm_unlockargs *arg, struct svc_req *rqstp)
+nlm_res *nlm_unlock_1_svc(nlm_unlockargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
if (debug_level) log_from_addr("nlm_unlock", rqstp);
@@ -383,7 +383,7 @@ nlm_res *nlm_unlock_1(nlm_unlockargs *arg, struct svc_req *rqstp)
return (&res);
}
-void *nlm_unlock_msg_1(nlm_unlockargs *arg, struct svc_req *rqstp)
+void *nlm_unlock_msg_1_svc(nlm_unlockargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
if (debug_level) log_from_addr("nlm_unlock_msg", rqstp);
@@ -414,7 +414,7 @@ void *nlm_unlock_msg_1(nlm_unlockargs *arg, struct svc_req *rqstp)
Notes:
*/
-nlm_res *nlm_granted_1(nlm_testargs *arg, struct svc_req *rqstp)
+nlm_res *nlm_granted_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
if (debug_level) log_from_addr("nlm_granted", rqstp);
@@ -426,7 +426,7 @@ nlm_res *nlm_granted_1(nlm_testargs *arg, struct svc_req *rqstp)
return (&res);
}
-void *nlm_granted_msg_1(nlm_testargs *arg, struct svc_req *rqstp)
+void *nlm_granted_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
nlm_res res;
if (debug_level) log_from_addr("nlm_granted_msg", rqstp);
@@ -443,7 +443,7 @@ void *nlm_granted_msg_1(nlm_testargs *arg, struct svc_req *rqstp)
Returns: Nothing
*/
-void *nlm_test_res_1(nlm_testres *arg, struct svc_req *rqstp)
+void *nlm_test_res_1_svc(nlm_testres *arg, struct svc_req *rqstp)
{
if (debug_level) log_from_addr("nlm_test_res", rqstp);
return (NULL);
@@ -455,7 +455,7 @@ void *nlm_test_res_1(nlm_testres *arg, struct svc_req *rqstp)
Returns: Nothing
*/
-void *nlm_lock_res_1(nlm_res *arg, struct svc_req *rqstp)
+void *nlm_lock_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
{
if (debug_level) log_from_addr("nlm_lock_res", rqstp);
@@ -468,7 +468,7 @@ void *nlm_lock_res_1(nlm_res *arg, struct svc_req *rqstp)
Returns: Nothing
*/
-void *nlm_cancel_res_1(nlm_res *arg, struct svc_req *rqstp)
+void *nlm_cancel_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
{
if (debug_level) log_from_addr("nlm_cancel_res", rqstp);
return (NULL);
@@ -480,7 +480,7 @@ void *nlm_cancel_res_1(nlm_res *arg, struct svc_req *rqstp)
Returns: Nothing
*/
-void *nlm_unlock_res_1(nlm_res *arg, struct svc_req *rqstp)
+void *nlm_unlock_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
{
if (debug_level) log_from_addr("nlm_unlock_res", rqstp);
return (NULL);
@@ -492,7 +492,7 @@ void *nlm_unlock_res_1(nlm_res *arg, struct svc_req *rqstp)
Returns: Nothing
*/
-void *nlm_granted_res_1(nlm_res *arg, struct svc_req *rqstp)
+void *nlm_granted_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
{
if (debug_level) log_from_addr("nlm_granted_res", rqstp);
return (NULL);
@@ -515,7 +515,7 @@ void *nlm_granted_res_1(nlm_res *arg, struct svc_req *rqstp)
to retry if required.
*/
-nlm_shareres *nlm_share_3(nlm_shareargs *arg, struct svc_req *rqstp)
+nlm_shareres *nlm_share_3_svc(nlm_shareargs *arg, struct svc_req *rqstp)
{
static nlm_shareres res;
if (debug_level) log_from_addr("nlm_share", rqstp);
@@ -533,7 +533,7 @@ nlm_shareres *nlm_share_3(nlm_shareargs *arg, struct svc_req *rqstp)
Notes:
*/
-nlm_shareres *nlm_unshare_3(nlm_shareargs *arg, struct svc_req *rqstp)
+nlm_shareres *nlm_unshare_3_svc(nlm_shareargs *arg, struct svc_req *rqstp)
{
static nlm_shareres res;
if (debug_level) log_from_addr("nlm_unshare", rqstp);
@@ -555,7 +555,7 @@ nlm_shareres *nlm_unshare_3(nlm_shareargs *arg, struct svc_req *rqstp)
respond to the statd protocol.
*/
-nlm_res *nlm_nm_lock_3(nlm_lockargs *arg, struct svc_req *rqstp)
+nlm_res *nlm_nm_lock_3_svc(nlm_lockargs *arg, struct svc_req *rqstp)
{
static nlm_res res;
if (debug_level) log_from_addr("nlm_nm_lock", rqstp);
@@ -577,7 +577,7 @@ nlm_res *nlm_nm_lock_3(nlm_lockargs *arg, struct svc_req *rqstp)
using monitored locks.
*/
-void *nlm_free_all_3(nlm_notify *arg, struct svc_req *rqstp)
+void *nlm_free_all_3_svc(nlm_notify *arg, struct svc_req *rqstp)
{
static char dummy;
diff --git a/usr.sbin/rpc.lockd/test.c b/usr.sbin/rpc.lockd/test.c
index 5b33a6a..2f1eb5a 100644
--- a/usr.sbin/rpc.lockd/test.c
+++ b/usr.sbin/rpc.lockd/test.c
@@ -314,11 +314,15 @@ int main(int argc, char **argv)
exit(1);
}
+
clnt_control(cli, CLGET_TIMEOUT, &tim);
printf("Default timeout was %d.%d\n", tim.tv_sec, tim.tv_usec);
tim.tv_usec = -1;
tim.tv_sec = -1;
clnt_control(cli, CLSET_TIMEOUT, &tim);
+ clnt_control(cli, CLGET_TIMEOUT, &tim);
+ printf("timeout now %d.%d\n", tim.tv_sec, tim.tv_usec);
+
arg.cookie.n_len = 4;
arg.cookie.n_bytes = "hello";
OpenPOWER on IntegriCloud