X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fshowmount%2Fshowmount.c;h=2695c510652910aca30601c25e27dea1d3359257;hp=7f5ad3aa54fc79138f0c7cf92c0ea6d4c52fa72b;hb=29ac873f9024c8fcbca38ab09ba54cda3765b746;hpb=1c96846ba3adeb59a61e0cf33cf4c94c0678853f diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c index 7f5ad3a..2695c51 100644 --- a/utils/showmount/showmount.c +++ b/utils/showmount/showmount.c @@ -78,6 +78,40 @@ static void usage(FILE *fp, int n) exit(n); } +#ifdef HAVE_CLNT_CREATE + +static const char *nfs_sm_pgmtbl[] = { + "showmount", + "mount", + "mountd", + NULL, +}; + +/* + * Generate an RPC client handle connected to the mountd service + * at @hostname, or die trying. + * + * Supports both AF_INET and AF_INET6 server addresses. + */ +static CLIENT *nfs_get_mount_client(const char *hostname) +{ + rpcprog_t program = nfs_getrpcbyname(MOUNTPROG, nfs_sm_pgmtbl); + CLIENT *client; + + client = clnt_create(hostname, program, MOUNTVERS, "tcp"); + if (client) + return client; + + client = clnt_create(hostname, program, MOUNTVERS, "udp"); + if (client) + return client; + + clnt_pcreateerror("clnt_create"); + exit(1); +} + +#else /* HAVE_CLNT_CREATE */ + /* * Perform a non-blocking connect on the socket fd. * @@ -213,6 +247,8 @@ static CLIENT *nfs_get_mount_client(const char *hostname) return mclient; } +#endif /* HAVE_CLNT_CREATE */ + int main(int argc, char **argv) { char hostname_buf[MAXHOSTLEN];