diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-07-28 17:50:40 -0400 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2007-07-30 16:12:53 +1000 |
commit | 56a4a153c8559efe6e090e99eaf190d530299de2 (patch) | |
tree | b1a71e6af79a8dfb9d8b7ee3a045c4f0e798a964 /support/nfs/conn.c | |
parent | b6e4ddd10b3c67ef210e572dec956cb35ce96440 (diff) | |
download | nfs-utils-56a4a153c8559efe6e090e99eaf190d530299de2.tar.gz nfs-utils-56a4a153c8559efe6e090e99eaf190d530299de2.tar.xz nfs-utils-56a4a153c8559efe6e090e99eaf190d530299de2.zip |
libnfs.a: move clnt_ping() to utils/mount
Continue clean up of mount functionality in libnfs.a by moving clnt_ping()
to utils/mount/network.c. Note that socklen_t is an unsigned int... the
i386 gcc compiler threw a signedness warning about the 3rd argument of
getsockname().
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'support/nfs/conn.c')
-rw-r--r-- | support/nfs/conn.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/support/nfs/conn.c b/support/nfs/conn.c index 970abfe..d153aa2 100644 --- a/support/nfs/conn.c +++ b/support/nfs/conn.c @@ -97,78 +97,3 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp, int conn) } return so; } - -/* - * Sigh... getport() doesn't actually check the version number. - * In order to make sure that the server actually supports the service - * we're requesting, we open and RPC client, and fire off a NULL - * RPC call. - */ -int -clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, - const u_int prot, struct sockaddr_in *caddr) -{ - CLIENT *clnt=NULL; - int sock, stat; - static char clnt_res; - struct sockaddr dissolve; - - rpc_createerr.cf_stat = stat = errno = 0; - sock = get_socket(saddr, prot, FALSE, TRUE); - if (sock == RPC_ANYSOCK) { - if (errno == ETIMEDOUT) { - /* - * TCP timeout. Bubble up the error to see - * how it should be handled. - */ - rpc_createerr.cf_stat = RPC_TIMEDOUT; - } - return 0; - } - - if (caddr) { - /* Get the address of our end of this connection */ - socklen_t len = sizeof(*caddr); - if (getsockname(sock, caddr, &len) != 0) - caddr->sin_family = 0; - } - - switch(prot) { - case IPPROTO_UDP: - /* The socket is connected (so we could getsockname successfully), - * but some servers on multi-homed hosts reply from - * the wrong address, so if we stay connected, we lose the reply. - */ - dissolve.sa_family = AF_UNSPEC; - connect(sock, &dissolve, sizeof(dissolve)); - - clnt = clntudp_bufcreate(saddr, prog, vers, - RETRY_TIMEOUT, &sock, - RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - break; - case IPPROTO_TCP: - clnt = clnttcp_create(saddr, prog, vers, &sock, - RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - break; - } - if (!clnt) { - close(sock); - return 0; - } - memset(&clnt_res, 0, sizeof(clnt_res)); - stat = clnt_call(clnt, NULLPROC, - (xdrproc_t)xdr_void, (caddr_t)NULL, - (xdrproc_t)xdr_void, (caddr_t)&clnt_res, - TIMEOUT); - if (stat) { - clnt_geterr(clnt, &rpc_createerr.cf_error); - rpc_createerr.cf_stat = stat; - } - clnt_destroy(clnt); - close(sock); - - if (stat == RPC_SUCCESS) - return 1; - else - return 0; -} |