From f0d3a4bedccca7cce48296757bc1c8bd59b80828 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Thu, 14 Jan 2010 12:23:15 -0500 Subject: nfs-utils: Collect socket address helpers into one location Introduce generic helpers for managing socket addresses. These are general enough that they are useful for pretty much any component of nfs-utils. We also include the definition of nfs_sockaddr here, so it can be shared. See: https://bugzilla.redhat.com/show_bug.cgi?id=448743 Signed-off-by: Chuck Lever --- utils/mount/network.c | 13 +++++-------- utils/mount/stropts.c | 7 +------ 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'utils/mount') diff --git a/utils/mount/network.c b/utils/mount/network.c index 906e20c..92bba2d 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -42,6 +42,7 @@ #include #include +#include "sockaddr.h" #include "xcommon.h" #include "mount.h" #include "nls.h" @@ -56,10 +57,6 @@ #define CONNECT_TIMEOUT (20) #define MOUNT_TIMEOUT (30) -#if SIZEOF_SOCKLEN_T - 0 == 0 -#define socklen_t unsigned int -#endif - extern int nfs_mount_data_version; extern char *progname; extern int verbose; @@ -540,8 +537,8 @@ static int nfs_probe_port(const struct sockaddr *sap, const socklen_t salen, struct pmap *pmap, const unsigned long *versions, const unsigned int *protos) { - struct sockaddr_storage address; - struct sockaddr *saddr = (struct sockaddr *)&address; + union nfs_sockaddr address; + struct sockaddr *saddr = &address.sa; const unsigned long prog = pmap->pm_prog, *p_vers; const unsigned int prot = (u_int)pmap->pm_prot, *p_prot; const u_short port = (u_short) pmap->pm_port; @@ -831,8 +828,8 @@ int start_statd(void) int nfs_advise_umount(const struct sockaddr *sap, const socklen_t salen, const struct pmap *pmap, const dirpath *argp) { - struct sockaddr_storage address; - struct sockaddr *saddr = (struct sockaddr *)&address; + union nfs_sockaddr address; + struct sockaddr *saddr = &address.sa; struct pmap mnt_pmap = *pmap; struct timeval timeout = { .tv_sec = MOUNT_TIMEOUT >> 3, diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index 9a13509..57a4b32 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -35,6 +35,7 @@ #include #include +#include "sockaddr.h" #include "xcommon.h" #include "mount.h" #include "nls.h" @@ -77,12 +78,6 @@ extern char *progname; extern int verbose; extern int sloppy; -union nfs_sockaddr { - struct sockaddr sa; - struct sockaddr_in s4; - struct sockaddr_in6 s6; -}; - struct nfsmount_info { const char *spec, /* server:/path */ *node, /* mounted-on dir */ -- cgit