Changes from redhat srpm. --- util-linux-2.12-bfields/mount/mount.c | 2 util-linux-2.12-bfields/mount/nfs4mount.c | 20 +++++++++ util-linux-2.12-bfields/mount/nfsmount.c | 61 +++++++++++++++++++++++++----- 3 files changed, 72 insertions(+), 11 deletions(-) diff -puN mount/mount.c~redhat-nfs-mount mount/mount.c --- util-linux-2.12/mount/mount.c~redhat-nfs-mount 2004-12-13 12:34:18.000000000 -0500 +++ util-linux-2.12-bfields/mount/mount.c 2004-12-13 12:34:18.000000000 -0500 @@ -829,6 +829,7 @@ retry_nfs: mnt_err = nfs4mount(spec, node, &flags, &extra_opts, &mount_opts, bg); if (mnt_err) return mnt_err; + goto nosigblock; #else die (EX_SOFTWARE, _("mount: this version was compiled " "without support for the type `nfs4'")); @@ -836,6 +837,7 @@ retry_nfs: } block_signals (SIG_BLOCK); +nosigblock: if (!fake) mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS, diff -puN mount/nfs4mount.c~redhat-nfs-mount mount/nfs4mount.c --- util-linux-2.12/mount/nfs4mount.c~redhat-nfs-mount 2004-12-13 12:34:18.000000000 -0500 +++ util-linux-2.12-bfields/mount/nfs4mount.c 2004-12-13 12:34:18.000000000 -0500 @@ -37,6 +37,12 @@ #include #include #include +#ifdef HAVE_rpcsvc_nfs_prot_h +#include +#else +#include +#define nfsstat nfs_stat +#endif #include "sundries.h" @@ -49,6 +55,9 @@ #define NFS_PORT 2049 #endif +extern int clnt_ping(struct sockaddr_in *, const u_long, const u_long, const u_int); +extern void rpc_strerror(void); + struct { char *flavour; int fnum; @@ -225,7 +234,7 @@ int nfs4mount(const char *spec, const ch bg = 0; soft = 0; - intr = 0; + intr = NFS4_MOUNT_INTR; nocto = 0; noac = 0; retry = 10000; /* 10000 minutes ~ 1 week */ @@ -374,10 +383,19 @@ int nfs4mount(const char *spec, const ch data.version = NFS4_MOUNT_VERSION; + clnt_ping(&server_addr, NFS_PROGRAM, 4, data.proto); + if (rpc_createerr.cf_stat) { + fprintf(stderr, "mount to NFS server '%s' failed.\n", data.hostname.data); + goto fail; + } + *mount_opts = (char *) &data; /* clean up */ return 0; fail: + if (verbose) { + rpc_strerror(); + } return retval; } diff -puN mount/nfsmount.c~redhat-nfs-mount mount/nfsmount.c --- util-linux-2.12/mount/nfsmount.c~redhat-nfs-mount 2004-12-13 12:34:18.000000000 -0500 +++ util-linux-2.12-bfields/mount/nfsmount.c 2004-12-13 12:34:18.000000000 -0500 @@ -111,6 +111,25 @@ static const struct timeval RETRY_TIMEOU static int nfs_call_umount(clnt_addr_t *mnt_server, dirpath *argp); +int clnt_ping(struct sockaddr_in *, const u_long, const u_long, const u_int); + +/* Convert RPC errors into strings */ +void rpc_strerror(void) +{ + int cf_stat = rpc_createerr.cf_stat; + int cf_errno = rpc_createerr.cf_error.re_errno; + char *ptr, *estr = clnt_sperrno(cf_stat); + + if (estr) { + if ((ptr = index(estr, ':'))) + estr = ++ptr; + + fprintf(stderr, "RPC Error: %d (%s )\n", cf_stat, estr); + if (cf_stat == RPC_SYSTEMERROR) + fprintf(stderr, "System Error: %d (%s)\n", cf_errno, strerror(cf_errno)); + } +} + /* Define the order in which to probe for UDP/TCP services */ static const u_int * proto_probelist(const int use_tcp) @@ -252,14 +271,15 @@ nfs_gethostbyname(const char *hostname, * we're requesting, we open and RPC client, and fire off a NULL * RPC call. */ -static int +int clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, const u_int prot) { - CLIENT *clnt; + CLIENT *clnt=NULL; int sock, stat; static char clnt_res; + rpc_createerr.cf_stat = stat = 0; sock = RPC_ANYSOCK; switch(prot) { case IPPROTO_UDP: @@ -285,6 +305,7 @@ clnt_ping(struct sockaddr_in *saddr, con close(sock); if (stat != RPC_PROGVERSMISMATCH) return 1; + out_bad: return 0; } @@ -308,9 +329,9 @@ probe_port(clnt_addr_t *server, *p_prot; const u_short port = (u_short) pmap->pm_port; u_short p_port; - p_prot = prot ? &prot : protos; p_vers = vers ? &vers : versions; + rpc_createerr.cf_stat = 0; for (;;) { saddr->sin_port = htons(PMAPPORT); p_port = pmap_getport(saddr, prog, *p_vers, *p_prot); @@ -338,6 +359,7 @@ probe_port(clnt_addr_t *server, pmap->pm_prot = *p_prot; if (!port) pmap->pm_port = p_port; + rpc_createerr.cf_stat = 0; return 1; } @@ -394,6 +416,8 @@ probe_bothports(clnt_addr_t *mnt_server, return 1; memcpy(mnt_pmap, &save_mnt, sizeof(*mnt_pmap)); } + if (rpc_createerr.cf_stat != RPC_PROGNOTREGISTERED) + break; memcpy(nfs_pmap, &save_nfs, sizeof(*nfs_pmap)); } out_bad: @@ -477,11 +501,23 @@ nfs_call_mount(clnt_addr_t *mnt_server, enum clnt_stat stat; int msock; - if (!probe_bothports(mnt_server, nfs_server)) { - if (report_errs) - fprintf(stderr,_("mount: failed to probe ports on NFS server %s\n"), + if (report_errs) { + fprintf(stderr, "mount to NFS server '%s' failed", *nfs_server->hostname); + if (rpc_createerr.cf_stat != RPC_PROGNOTREGISTERED) { + fprintf(stderr, ": server is down.\n"); + } else if (nfs_server->pmap.pm_prot) { + fprintf(stderr, ": possible invalid protocol.\n"); + } else if (nfs_server->pmap.pm_port) { + fprintf(stderr, ": possible invalid port.\n"); + } else { + fprintf(stderr, ".\n"); + } + if (verbose) { + rpc_strerror(); + } + } goto out_bad; } @@ -743,15 +779,19 @@ parse_options(char *old_opts, struct nfs static inline int nfsmnt_check_compat(const struct pmap *nfs_pmap, const struct pmap *mnt_pmap) { - if (nfs_pmap->pm_vers > MAX_NFSPROT) { + if (nfs_pmap->pm_vers && + (nfs_pmap->pm_vers > MAX_NFSPROT || nfs_pmap->pm_vers < 2)) { if (nfs_pmap->pm_vers == 4) - fprintf(stderr, _("'vers=4' is not supported. Use '-t nfs4' instead.\n")); + fprintf(stderr, _("'vers=4' is not supported. " + "Use '-t nfs4' instead.\n")); else - fprintf(stderr, _("NFSv%ld not supported!\n"), nfs_pmap->pm_vers); + fprintf(stderr, _("NFS version %ld is not supported.\n"), + nfs_pmap->pm_vers); goto out_bad; } if (mnt_pmap->pm_vers > MAX_MNTPROT) { - fprintf(stderr, _("NFS mount v%ld not supported!\n"), mnt_pmap->pm_vers); + fprintf(stderr, _("NFS mount version %ld s not supported.\n"), + mnt_pmap->pm_vers); goto out_bad; } return 1; @@ -1144,6 +1184,7 @@ nfs_call_umount(clnt_addr_t *mnt_server, res = nfs2_umount(argp, clnt); break; default: + break; } mnt_closeclnt(clnt, msock); if (res == RPC_SUCCESS) _