From b551b1fd0052de9b8c674b30c39d9f2a1e9d79cc Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 27 Sep 2010 10:09:10 -0400 Subject: [PATCH 1/1] mountd: Support TI-RPC mountd listener If TI-RPC is available, use it to create mountd's svc listener. If not, use the old function, rpc_init(), to create mountd's listener. IPv6 can be supported if TI-RPC is available. In this case, /etc/netconfig is searched to determine which transports to advertise. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson --- utils/mountd/mountd.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index 753fd37..a4fdcc8 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -86,6 +86,11 @@ static int version3(void) return nfs_version & NFSVERSBIT(3); } +static int version23(void) +{ + return nfs_version & (NFSVERSBIT(2) | NFSVERSBIT(3)); +} + static int version_any(void) { return nfs_version & NFSVERSBIT_ALL; @@ -95,11 +100,11 @@ static void unregister_services (void) { if (version2()) { - pmap_unset (MOUNTPROG, MOUNTVERS); - pmap_unset (MOUNTPROG, MOUNTVERS_POSIX); + nfs_svc_unregister(MOUNTPROG, MOUNTVERS); + nfs_svc_unregister(MOUNTPROG, MOUNTVERS_POSIX); } if (version3()) - pmap_unset (MOUNTPROG, MOUNTVERS_NFSV3); + nfs_svc_unregister(MOUNTPROG, MOUNTVERS_NFSV3); } static void @@ -687,6 +692,7 @@ main(int argc, char **argv) { char *export_file = _PATH_EXPORTS; char *state_dir = NFS_STATEDIR; + unsigned int listeners = 0; int foreground = 0; int port = 0; int descriptors = 0; @@ -830,14 +836,16 @@ main(int argc, char **argv) cache_open(); if (version2()) { - rpc_init("mountd", MOUNTPROG, MOUNTVERS, - mount_dispatch, port); - rpc_init("mountd", MOUNTPROG, MOUNTVERS_POSIX, - mount_dispatch, port); + listeners += nfs_svc_create("mountd", MOUNTPROG, + MOUNTVERS, mount_dispatch, port); + listeners += nfs_svc_create("mountd", MOUNTPROG, + MOUNTVERS_POSIX, mount_dispatch, port); } if (version3()) - rpc_init("mountd", MOUNTPROG, MOUNTVERS_NFSV3, - mount_dispatch, port); + listeners += nfs_svc_create("mountd", MOUNTPROG, + MOUNTVERS_NFSV3, mount_dispatch, port); + if (version23() && listeners == 0) + xlog(L_FATAL, "mountd: could not create listeners\n"); sa.sa_handler = killer; sigaction(SIGINT, &sa, NULL); -- 2.39.2