summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-11-25 08:39:47 -0500
committerSteve Dickson <steved@redhat.com>2008-11-25 08:39:47 -0500
commitf7020bd5d3ffca280690c6beba5fecdeb4d305f7 (patch)
tree4e553d321e74711f568712a8fa8fd3adfddbe31c
parent1c96846ba3adeb59a61e0cf33cf4c94c0678853f (diff)
downloadnfs-utils-f7020bd5d3ffca280690c6beba5fecdeb4d305f7.tar.gz
nfs-utils-f7020bd5d3ffca280690c6beba5fecdeb4d305f7.tar.xz
nfs-utils-f7020bd5d3ffca280690c6beba5fecdeb4d305f7.zip
showmount command: support querying IPv6 servers
Introduce a version of nfs_get_mount_client() that supports AF_INET6 and AF_INET server addresses. If the TI-RPC library is not available when the showmount command is built, fall back to the legacy RPC user-space API. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--utils/showmount/showmount.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c
index 7f5ad3a..17f7d87 100644
--- a/utils/showmount/showmount.c
+++ b/utils/showmount/showmount.c
@@ -50,6 +50,13 @@ static int aflag = 0;
static int dflag = 0;
static int eflag = 0;
+static const char *nfs_sm_pgmtbl[] = {
+ "showmount",
+ "mount",
+ "mountd",
+ NULL,
+};
+
static struct option longopts[] =
{
{ "all", 0, 0, 'a' },
@@ -78,6 +85,33 @@ static void usage(FILE *fp, int n)
exit(n);
}
+#ifdef HAVE_CLNT_CREATE
+
+/*
+ * 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];