2008-08-05 18:13:43

by Chuck Lever

[permalink] [raw]
Subject: [PATCH 5/8] showmount command: call nfs_getport instead of local getport

Have the showmount command invoke the shared nfs_getport() function
instead of its own local version. This gives the showmount command
immediate support for querying via rpcbindv3/v4 in addition to
portmapper, and sets the stage for AF_INET6 support in showmount.

Signed-off-by: Chuck Lever <[email protected]>
---

utils/showmount/showmount.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c
index 6acd7e6..360f2fa 100644
--- a/utils/showmount/showmount.c
+++ b/utils/showmount/showmount.c
@@ -37,6 +37,8 @@
#include <mount.h>
#include <unistd.h>

+#include "nfsrpc.h"
+
#define TIMEOUT_UDP 3
#define TIMEOUT_TCP 10
#define TOTAL_TIMEOUT 20
@@ -352,9 +354,9 @@ int main(int argc, char **argv)
mclient = NULL;
msock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (msock != -1) {
- server_addr.sin_port = getport(&server_addr,
- MOUNTPROG, MOUNTVERS, IPPROTO_TCP);
- if (server_addr.sin_port) {
+ if (nfs_getport_ping((struct sockaddr *)&server_addr,
+ sizeof(server_addr), MOUNTPROG,
+ MOUNTVERS, IPPROTO_TCP)) {
ret = connect_nb(msock, &server_addr, 0);
if (ret == 0) /* success */
mclient = clnttcp_create(&server_addr,
@@ -367,9 +369,9 @@ int main(int argc, char **argv)
}

if (!mclient) {
- server_addr.sin_port = getport(&server_addr,
- MOUNTPROG, MOUNTVERS, IPPROTO_UDP);
- if (!server_addr.sin_port) {
+ if (nfs_getport_ping((struct sockaddr *)&server_addr,
+ sizeof(server_addr), MOUNTPROG,
+ MOUNTVERS, IPPROTO_UDP)) {
clnt_pcreateerror("showmount");
exit(1);
}