From: Chuck Lever Date: Sat, 28 Jul 2007 21:49:43 +0000 (-0400) Subject: umount.nfs: move nfs_call_umount to network.c X-Git-Tag: nfs-utils-1-1-1~126 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=commitdiff_plain;h=a4b10d48a730fbc6ff62197facddccdf7e204610 umount.nfs: move nfs_call_umount to network.c nfs_call_umount() is shared by nfsmount.c and nfsumount.c, and manages a network function (building the RPC umount call to the server's MNT daemon). So move it to network.c with other network-related functions. Signed-off-by: Chuck Lever Signed-off-by: Neil Brown --- diff --git a/utils/mount/network.c b/utils/mount/network.c index ab8cfb7..b04491c 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -245,7 +245,7 @@ out_ok: return 1; } -int probe_nfsport(clnt_addr_t *nfs_server) +static int probe_nfsport(clnt_addr_t *nfs_server) { struct pmap *pmap = &nfs_server->pmap; @@ -258,7 +258,7 @@ int probe_nfsport(clnt_addr_t *nfs_server) return probe_port(nfs_server, probe_nfs2_only, probe_udp_only); } -int probe_mntport(clnt_addr_t *mnt_server) +static int probe_mntport(clnt_addr_t *mnt_server) { struct pmap *pmap = &mnt_server->pmap; @@ -362,3 +362,34 @@ int start_statd(void) return 0; } + +int nfs_call_umount(clnt_addr_t *mnt_server, dirpath *argp) +{ + CLIENT *clnt; + enum clnt_stat res = 0; + int msock; + + switch (mnt_server->pmap.pm_vers) { + case 3: + case 2: + case 1: + if (!probe_mntport(mnt_server)) + goto out_bad; + clnt = mnt_openclnt(mnt_server, &msock); + if (!clnt) + goto out_bad; + res = clnt_call(clnt, MOUNTPROC_UMNT, + (xdrproc_t) xdr_dirpath, (caddr_t)argp, + (xdrproc_t) xdr_void, NULL, + TIMEOUT); + mnt_closeclnt(clnt, msock); + if (res == RPC_SUCCESS) + return 1; + break; + default: + res = 1; + break; + } + out_bad: + return res; +} diff --git a/utils/mount/network.h b/utils/mount/network.h index bb5b4da..83375f0 100644 --- a/utils/mount/network.h +++ b/utils/mount/network.h @@ -22,11 +22,10 @@ */ #include "conn.h" +#include "mount.h" -int nfs_gethostbyname(const char *, struct sockaddr_in *); - -int probe_mntport(clnt_addr_t *); -int probe_nfsport(clnt_addr_t *); int probe_bothports(clnt_addr_t *, clnt_addr_t *); +int nfs_gethostbyname(const char *, struct sockaddr_in *); +int nfs_call_umount(clnt_addr_t *, dirpath *); int start_statd(void); diff --git a/utils/mount/nfsumount.c b/utils/mount/nfsumount.c index 3d387c1..9b7c44d 100644 --- a/utils/mount/nfsumount.c +++ b/utils/mount/nfsumount.c @@ -53,43 +53,6 @@ int force; int lazy; int remount; -static inline enum clnt_stat -nfs_umount(dirpath *argp, CLIENT *clnt) -{ - return clnt_call(clnt, MOUNTPROC_UMNT, - (xdrproc_t) xdr_dirpath, (caddr_t)argp, - (xdrproc_t) xdr_void, NULL, - TIMEOUT); -} - -int nfs_call_umount(clnt_addr_t *mnt_server, dirpath *argp) -{ - CLIENT *clnt; - enum clnt_stat res = 0; - int msock; - - switch (mnt_server->pmap.pm_vers) { - case 3: - case 2: - case 1: - if (!probe_mntport(mnt_server)) - goto out_bad; - clnt = mnt_openclnt(mnt_server, &msock); - if (!clnt) - goto out_bad; - res = nfs_umount(argp, clnt); - mnt_closeclnt(clnt, msock); - if (res == RPC_SUCCESS) - return 1; - break; - default: - res = 1; - break; - } - out_bad: - return res; -} - int del_mtab(const char *spec, const char *node) { int umnt_err, res; diff --git a/utils/mount/nfsumount.h b/utils/mount/nfsumount.h index 191118d..0d67d27 100644 --- a/utils/mount/nfsumount.h +++ b/utils/mount/nfsumount.h @@ -5,6 +5,5 @@ #include "mount.h" int nfsumount(int, char **); -int nfs_call_umount(clnt_addr_t *, dirpath *); #endif