On Sat, 2019-05-11 at 09:54 -0400, J. Bruce Fields wrote: > On Fri, May 10, 2019 at 05:54:45PM -0400, Jeff Layton wrote: > > From: Jeff Layton <jlayton@xxxxxxxxxx> > > > > I occasionally see people that expect valid info when running showmount > > against a server that may export some or all filesystems via NFSv4. > > Let's make it clear that it only works by talking to the remote MNT > > service, and that that may not be available from a v4-only server. > > Looks fine. > > I wonder if it'd also be helpful for showmount to detect this case and > say something. E.g. the following (not even compileable, but you get > the idea). > > We've also talked about trying to cobble together an export list by > scanning the root filesystem over NFSv4, but that's likely to be > complicated and wouldn't give all the same results without further > protocol extensions anyway, so I think that idea's dead. > Agreed. > --b. > > diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c > index 394f5284a219..de9a6d38783a 100644 > --- a/utils/showmount/showmount.c > +++ b/utils/showmount/showmount.c > @@ -115,6 +115,22 @@ static CLIENT *nfs_get_mount_client(const char *hostname, rpcvers_t vers) > exit(1); > } > > +void warn_if_v4_only(char *hostname) > +{ > + struct sockaddr_in server_addr, client_addr; > + > + if (fill_ipv4_sockaddr(hostname, &serveraddr)) > + return; > + server_addr.sin_port = htnos(NFS_PORT); > + client_addr.sin_family = 0; > + client_addr.sin_addr.s_addr = 0; > + clnt_ping(&server_addr, NFS_PROGRAM, 4, "tcp", &client_addr); > + > + if (rpc.createerr == RPC_SUCCESS) > + printf("Server responding to NFSv4 but not MNT; try mounting " > + "%s:/ instead of showmount", hostname); > +} > + > int main(int argc, char **argv) > { > char hostname_buf[MAXHOSTLEN]; > @@ -199,6 +215,7 @@ int main(int argc, char **argv) > fprintf(stderr, "%s: unable to create RPC auth handle.\n", > program_name); > clnt_destroy(mclient); > + warn_if_v4_only(hostname); > exit(1); > } > total_timeout.tv_sec = TOTAL_TIMEOUT; Yeah, that certainly wouldn't hurt. I'd suggest we add that in a separate patch though. We will need to spell this out in the manpage either way. At least with ganesha, you can export some filesystems via v3 and others via v4 only, and the MNT service there will only report the v3 ones. In that case, you have a reachable service, but the v4-only filesystems will be missing from showmount's output. -- Jeff Layton <jlayton@xxxxxxxxxx>