walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
bbc1dcf
commit c641800eb0fcaa819199e58e5c4c8d1c2a9dab5d
bbc1dcf
Author: Chuck Lever <chuck.lever@oracle.com>
bbc1dcf
Date:   Fri Jun 6 15:06:21 2008 -0400
bbc1dcf
bbc1dcf
    Clean up: instead of passing so many arguments to all the helpers, have
bbc1dcf
    nfsmount_string build a data structure that contains all the arguments, and
bbc1dcf
    pass a pointer to that instead.
bbc1dcf
    
bbc1dcf
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
bbc1dcf
    Signed-off-by: Steve Dickson <steved@redhat.com>
bbc1dcf
bbc1dcf
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
bbc1dcf
index ad5bdee..3564f15 100644
bbc1dcf
--- a/utils/mount/stropts.c
bbc1dcf
+++ b/utils/mount/stropts.c
bbc1dcf
@@ -77,12 +77,26 @@ extern int nfs_mount_data_version;
bbc1dcf
 extern char *progname;
bbc1dcf
 extern int verbose;
bbc1dcf
 
bbc1dcf
-static int parse_devname(const char *spec, char **hostname)
bbc1dcf
+struct nfsmount_info {
bbc1dcf
+	const char		*spec,		/* server:/path */
bbc1dcf
+				*node,		/* mounted-on dir */
bbc1dcf
+				*type;		/* "nfs" or "nfs4" */
bbc1dcf
+	char			*hostname;	/* server's hostname */
bbc1dcf
+
bbc1dcf
+	struct mount_options	*options;	/* parsed mount options */
bbc1dcf
+	char			**extra_opts;	/* string for /etc/mtab */
bbc1dcf
+
bbc1dcf
+	int			flags,		/* MS_ flags */
bbc1dcf
+				fake,		/* actually do the mount? */
bbc1dcf
+				child;		/* forked bg child? */
bbc1dcf
+};
bbc1dcf
+
bbc1dcf
+static int nfs_parse_devname(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
 	int ret = 0;
bbc1dcf
 	char *dev, *pathname, *s;
bbc1dcf
 
bbc1dcf
-	dev = xstrdup(spec);
bbc1dcf
+	dev = xstrdup(mi->spec);
bbc1dcf
 
bbc1dcf
 	if (!(pathname = strchr(dev, ':'))) {
bbc1dcf
 		nfs_error(_("%s: remote share not in 'host:dir' format"),
bbc1dcf
@@ -113,11 +127,12 @@ static int parse_devname(const char *spec, char **hostname)
bbc1dcf
 		nfs_error(_("%s: ignoring hostnames that follow the first one"),
bbc1dcf
 				progname);
bbc1dcf
 	}
bbc1dcf
-	*hostname = xstrdup(dev);
bbc1dcf
-	if (strlen(*hostname) > NFS_MAXHOSTNAME) {
bbc1dcf
+	mi->hostname = xstrdup(dev);
bbc1dcf
+	if (strlen(mi->hostname) > NFS_MAXHOSTNAME) {
bbc1dcf
 		nfs_error(_("%s: server hostname is too long"),
bbc1dcf
 				progname);
bbc1dcf
-		free(*hostname);
bbc1dcf
+		free(mi->hostname);
bbc1dcf
+		mi->hostname = NULL;
bbc1dcf
 		goto out;
bbc1dcf
 	}
bbc1dcf
 
bbc1dcf
@@ -273,28 +288,30 @@ static int verify_lock_option(struct mount_options *options)
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /*
bbc1dcf
- * Set up mandatory mount options.
bbc1dcf
+ * Set up mandatory NFS mount options.
bbc1dcf
  *
bbc1dcf
  * Returns 1 if successful; otherwise zero.
bbc1dcf
  */
bbc1dcf
-static int validate_options(const char *type,
bbc1dcf
-			    struct sockaddr_in *saddr,
bbc1dcf
-			    struct mount_options *options,
bbc1dcf
-			    int fake)
bbc1dcf
+static int nfs_validate_options(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
-	if (!append_addr_option(saddr, options))
bbc1dcf
+	struct sockaddr_in saddr;
bbc1dcf
+
bbc1dcf
+	if (!fill_ipv4_sockaddr(mi->hostname, &saddr))
bbc1dcf
 		return 0;
bbc1dcf
 
bbc1dcf
-	if (strncmp(type, "nfs4", 4) == 0) {
bbc1dcf
-		if (!append_clientaddr_option(saddr, options))
bbc1dcf
+	if (strncmp(mi->type, "nfs4", 4) == 0) {
bbc1dcf
+		if (!append_clientaddr_option(&saddr, mi->options))
bbc1dcf
 			return 0;
bbc1dcf
 	} else {
bbc1dcf
-		if (!fix_mounthost_option(options))
bbc1dcf
+		if (!fix_mounthost_option(mi->options))
bbc1dcf
 			return 0;
bbc1dcf
-		if (!fake && !verify_lock_option(options))
bbc1dcf
+		if (!mi->fake && !verify_lock_option(mi->options))
bbc1dcf
 			return 0;
bbc1dcf
 	}
bbc1dcf
 
bbc1dcf
+	if (!append_addr_option(&saddr, mi->options))
bbc1dcf
+		return 0;
bbc1dcf
+
bbc1dcf
 	return 1;
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
@@ -443,6 +460,27 @@ err:
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /*
bbc1dcf
+ * Do the mount(2) system call.
bbc1dcf
+ *
bbc1dcf
+ * Returns 1 if successful, otherwise zero.
bbc1dcf
+ * "errno" is set to reflect the individual error.
bbc1dcf
+ */
bbc1dcf
+static int nfs_sys_mount(const struct nfsmount_info *mi, const char *type,
bbc1dcf
+			 const char *options)
bbc1dcf
+{
bbc1dcf
+	int result;
bbc1dcf
+
bbc1dcf
+	result = mount(mi->spec, mi->node, type,
bbc1dcf
+				mi->flags & ~(MS_USER|MS_USERS), options);
bbc1dcf
+	if (verbose && result) {
bbc1dcf
+		int save = errno;
bbc1dcf
+		nfs_error(_("%s: mount(2): %s"), progname, strerror(save));
bbc1dcf
+		errno = save;
bbc1dcf
+	}
bbc1dcf
+	return !result;
bbc1dcf
+}
bbc1dcf
+
bbc1dcf
+/*
bbc1dcf
  * Retry an NFS mount that failed because the requested service isn't
bbc1dcf
  * available on the server.
bbc1dcf
  *
bbc1dcf
@@ -453,12 +491,11 @@ err:
bbc1dcf
  * 'extra_opts' are updated to reflect the mount options that worked.
bbc1dcf
  * If the retry fails, 'options' and 'extra_opts' are left unchanged.
bbc1dcf
  */
bbc1dcf
-static int retry_nfsmount(const char *spec, const char *node,
bbc1dcf
-			int flags, struct mount_options *options,
bbc1dcf
-			int fake, char **extra_opts)
bbc1dcf
+static int nfs_retry_nfs23mount(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
 	struct mount_options *retry_options;
bbc1dcf
 	char *retry_str = NULL;
bbc1dcf
+	char **extra_opts = mi->extra_opts;
bbc1dcf
 
bbc1dcf
 	retry_options = rewrite_mount_options(*extra_opts);
bbc1dcf
 	if (!retry_options) {
bbc1dcf
@@ -476,17 +513,16 @@ static int retry_nfsmount(const char *spec, const char *node,
bbc1dcf
 		printf(_("%s: text-based options (retry): '%s'\n"),
bbc1dcf
 			progname, retry_str);
bbc1dcf
 
bbc1dcf
-	if (!mount(spec, node, "nfs",
bbc1dcf
-				flags & ~(MS_USER|MS_USERS), retry_str)) {
bbc1dcf
-		free(*extra_opts);
bbc1dcf
-		*extra_opts = retry_str;
bbc1dcf
-		po_replace(options, retry_options);
bbc1dcf
-		return 1;
bbc1dcf
+	if (!nfs_sys_mount(mi, "nfs", retry_str)) {
bbc1dcf
+		po_destroy(retry_options);
bbc1dcf
+		free(retry_str);
bbc1dcf
+		return 0;
bbc1dcf
 	}
bbc1dcf
 
bbc1dcf
-	po_destroy(retry_options);
bbc1dcf
-	free(retry_str);
bbc1dcf
-	return 0;
bbc1dcf
+	free(*extra_opts);
bbc1dcf
+	*extra_opts = retry_str;
bbc1dcf
+	po_replace(mi->options, retry_options);
bbc1dcf
+	return 1;
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /*
bbc1dcf
@@ -502,11 +538,11 @@ static int retry_nfsmount(const char *spec, const char *node,
bbc1dcf
  * 'extra_opts' are updated to reflect the mount options that worked.
bbc1dcf
  * If the retry fails, 'options' and 'extra_opts' are left unchanged.
bbc1dcf
  */
bbc1dcf
-static int try_nfs23mount(const char *spec, const char *node,
bbc1dcf
-			  int flags, struct mount_options *options,
bbc1dcf
-			  int fake, char **extra_opts)
bbc1dcf
+static int nfs_try_nfs23mount(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
-	if (po_join(options, extra_opts) == PO_FAILED) {
bbc1dcf
+	char **extra_opts = mi->extra_opts;
bbc1dcf
+
bbc1dcf
+	if (po_join(mi->options, extra_opts) == PO_FAILED) {
bbc1dcf
 		errno = EIO;
bbc1dcf
 		return 0;
bbc1dcf
 	}
bbc1dcf
@@ -515,11 +551,10 @@ static int try_nfs23mount(const char *spec, const char *node,
bbc1dcf
 		printf(_("%s: text-based options: '%s'\n"),
bbc1dcf
 			progname, *extra_opts);
bbc1dcf
 
bbc1dcf
-	if (fake)
bbc1dcf
+	if (mi->fake)
bbc1dcf
 		return 1;
bbc1dcf
 
bbc1dcf
-	if (!mount(spec, node, "nfs",
bbc1dcf
-				flags & ~(MS_USER|MS_USERS), *extra_opts))
bbc1dcf
+	if (nfs_sys_mount(mi, "nfs", *extra_opts))
bbc1dcf
 		return 1;
bbc1dcf
 
bbc1dcf
 	/*
bbc1dcf
@@ -529,7 +564,7 @@ static int try_nfs23mount(const char *spec, const char *node,
bbc1dcf
 	if (errno != EOPNOTSUPP && errno != EPROTONOSUPPORT)
bbc1dcf
 		return 0;
bbc1dcf
 
bbc1dcf
-	return retry_nfsmount(spec, node, flags, options, fake, extra_opts);
bbc1dcf
+	return nfs_retry_nfs23mount(mi);
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /*
bbc1dcf
@@ -538,11 +573,11 @@ static int try_nfs23mount(const char *spec, const char *node,
bbc1dcf
  * Returns 1 if successful.  Otherwise, returns zero.
bbc1dcf
  * "errno" is set to reflect the individual error.
bbc1dcf
  */
bbc1dcf
-static int try_nfs4mount(const char *spec, const char *node,
bbc1dcf
-			 int flags, struct mount_options *options,
bbc1dcf
-			 int fake, char **extra_opts)
bbc1dcf
+static int nfs_try_nfs4mount(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
-	if (po_join(options, extra_opts) == PO_FAILED) {
bbc1dcf
+	char **extra_opts = mi->extra_opts;
bbc1dcf
+
bbc1dcf
+	if (po_join(mi->options, extra_opts) == PO_FAILED) {
bbc1dcf
 		errno = EIO;
bbc1dcf
 		return 0;
bbc1dcf
 	}
bbc1dcf
@@ -551,31 +586,24 @@ static int try_nfs4mount(const char *spec, const char *node,
bbc1dcf
 		printf(_("%s: text-based options: '%s'\n"),
bbc1dcf
 			progname, *extra_opts);
bbc1dcf
 
bbc1dcf
-	if (fake)
bbc1dcf
+	if (mi->fake)
bbc1dcf
 		return 1;
bbc1dcf
 
bbc1dcf
-	if (!mount(spec, node, "nfs4",
bbc1dcf
-				flags & ~(MS_USER|MS_USERS), *extra_opts))
bbc1dcf
-		return 1;
bbc1dcf
-	return 0;
bbc1dcf
+	return nfs_sys_mount(mi, "nfs4", *extra_opts);
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /*
bbc1dcf
- * Try the mount(2) system call.
bbc1dcf
+ * Perform either an NFSv2/3 mount, or an NFSv4 mount system call.
bbc1dcf
  *
bbc1dcf
  * Returns 1 if successful.  Otherwise, returns zero.
bbc1dcf
  * "errno" is set to reflect the individual error.
bbc1dcf
  */
bbc1dcf
-static int try_mount(const char *spec, const char *node, const char *type,
bbc1dcf
-		     int flags, struct mount_options *options, int fake,
bbc1dcf
-		     char **extra_opts)
bbc1dcf
+static int nfs_try_mount(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
-	if (strncmp(type, "nfs4", 4) == 0)
bbc1dcf
-		return try_nfs4mount(spec, node, flags,
bbc1dcf
-					options, fake, extra_opts);
bbc1dcf
+	if (strncmp(mi->type, "nfs4", 4) == 0)
bbc1dcf
+		return nfs_try_nfs4mount(mi);
bbc1dcf
 	else
bbc1dcf
-		return try_nfs23mount(spec, node, flags,
bbc1dcf
-					options, fake, extra_opts);
bbc1dcf
+		return nfs_try_nfs23mount(mi);
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /*
bbc1dcf
@@ -585,22 +613,19 @@ static int try_mount(const char *spec, const char *node, const char *type,
bbc1dcf
  *
bbc1dcf
  * Returns a valid mount command exit code.
bbc1dcf
  */
bbc1dcf
-static int nfsmount_fg(const char *spec, const char *node,
bbc1dcf
-		       const char *type, int flags,
bbc1dcf
-		       struct mount_options *options, int fake,
bbc1dcf
-		       char **extra_opts)
bbc1dcf
+static int nfsmount_fg(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
 	unsigned int secs = 1;
bbc1dcf
 	time_t timeout;
bbc1dcf
 
bbc1dcf
-	timeout = nfs_parse_retry_option(options, NFS_DEF_FG_TIMEOUT_MINUTES);
bbc1dcf
+	timeout = nfs_parse_retry_option(mi->options,
bbc1dcf
+					 NFS_DEF_FG_TIMEOUT_MINUTES);
bbc1dcf
 	if (verbose)
bbc1dcf
 		printf(_("%s: timeout set for %s"),
bbc1dcf
 			progname, ctime(&timeout));
bbc1dcf
 
bbc1dcf
 	for (;;) {
bbc1dcf
-		if (try_mount(spec, node, type, flags,
bbc1dcf
-					options, fake, extra_opts))
bbc1dcf
+		if (nfs_try_mount(mi))
bbc1dcf
 			return EX_SUCCESS;
bbc1dcf
 
bbc1dcf
 		if (is_permanent_error(errno))
bbc1dcf
@@ -620,7 +645,7 @@ static int nfsmount_fg(const char *spec, const char *node,
bbc1dcf
 		}
bbc1dcf
 	};
bbc1dcf
 
bbc1dcf
-	mount_error(spec, node, errno);
bbc1dcf
+	mount_error(mi->spec, mi->node, errno);
bbc1dcf
 	return EX_FAIL;
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
@@ -631,21 +656,17 @@ static int nfsmount_fg(const char *spec, const char *node,
bbc1dcf
  *
bbc1dcf
  * EX_BG should cause the caller to fork and invoke nfsmount_child.
bbc1dcf
  */
bbc1dcf
-static int nfsmount_parent(const char *spec, const char *node,
bbc1dcf
-			   const char *type, char *hostname, int flags,
bbc1dcf
-			   struct mount_options *options,
bbc1dcf
-			   int fake, char **extra_opts)
bbc1dcf
+static int nfsmount_parent(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
-	if (try_mount(spec, node, type, flags, options,
bbc1dcf
-					fake, extra_opts))
bbc1dcf
+	if (nfs_try_mount(mi))
bbc1dcf
 		return EX_SUCCESS;
bbc1dcf
 
bbc1dcf
 	if (is_permanent_error(errno)) {
bbc1dcf
-		mount_error(spec, node, errno);
bbc1dcf
+		mount_error(mi->spec, mi->node, errno);
bbc1dcf
 		return EX_FAIL;
bbc1dcf
 	}
bbc1dcf
 
bbc1dcf
-	sys_mount_errors(hostname, errno, 1, 1);
bbc1dcf
+	sys_mount_errors(mi->hostname, errno, 1, 1);
bbc1dcf
 	return EX_BG;
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
@@ -657,15 +678,13 @@ static int nfsmount_parent(const char *spec, const char *node,
bbc1dcf
  * error return, though, so we use sys_mount_errors to log the
bbc1dcf
  * failure.
bbc1dcf
  */
bbc1dcf
-static int nfsmount_child(const char *spec, const char *node,
bbc1dcf
-			  const char *type, char *hostname, int flags,
bbc1dcf
-			  struct mount_options *options,
bbc1dcf
-			  int fake, char **extra_opts)
bbc1dcf
+static int nfsmount_child(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
 	unsigned int secs = 1;
bbc1dcf
 	time_t timeout;
bbc1dcf
 
bbc1dcf
-	timeout = nfs_parse_retry_option(options, NFS_DEF_BG_TIMEOUT_MINUTES);
bbc1dcf
+	timeout = nfs_parse_retry_option(mi->options,
bbc1dcf
+					 NFS_DEF_BG_TIMEOUT_MINUTES);
bbc1dcf
 
bbc1dcf
 	for (;;) {
bbc1dcf
 		if (sleep(secs))
bbc1dcf
@@ -674,8 +693,7 @@ static int nfsmount_child(const char *spec, const char *node,
bbc1dcf
 		if (secs > 120)
bbc1dcf
 			secs = 120;
bbc1dcf
 
bbc1dcf
-		if (try_mount(spec, node, type, flags, options,
bbc1dcf
-							fake, extra_opts))
bbc1dcf
+		if (nfs_try_mount(mi))
bbc1dcf
 			return EX_SUCCESS;
bbc1dcf
 
bbc1dcf
 		if (is_permanent_error(errno))
bbc1dcf
@@ -684,10 +702,10 @@ static int nfsmount_child(const char *spec, const char *node,
bbc1dcf
 		if (time(NULL) > timeout)
bbc1dcf
 			break;
bbc1dcf
 
bbc1dcf
-		sys_mount_errors(hostname, errno, 1, 1);
bbc1dcf
+		sys_mount_errors(mi->hostname, errno, 1, 1);
bbc1dcf
 	};
bbc1dcf
 
bbc1dcf
-	sys_mount_errors(hostname, errno, 1, 0);
bbc1dcf
+	sys_mount_errors(mi->hostname, errno, 1, 0);
bbc1dcf
 	return EX_FAIL;
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
@@ -696,17 +714,28 @@ static int nfsmount_child(const char *spec, const char *node,
bbc1dcf
  *
bbc1dcf
  * Returns a valid mount command exit code.
bbc1dcf
  */
bbc1dcf
-static int nfsmount_bg(const char *spec, const char *node,
bbc1dcf
-			  const char *type, char *hostname, int flags,
bbc1dcf
-			  struct mount_options *options,
bbc1dcf
-			  int fake, int child, char **extra_opts)
bbc1dcf
+static int nfsmount_bg(struct nfsmount_info *mi)
bbc1dcf
 {
bbc1dcf
-	if (!child)
bbc1dcf
-		return nfsmount_parent(spec, node, type, hostname, flags,
bbc1dcf
-					options, fake, extra_opts);
bbc1dcf
+	if (!mi->child)
bbc1dcf
+		return nfsmount_parent(mi);
bbc1dcf
+	else
bbc1dcf
+		return nfsmount_child(mi);
bbc1dcf
+}
bbc1dcf
+
bbc1dcf
+/*
bbc1dcf
+ * Process mount options and try a mount system call.
bbc1dcf
+ *
bbc1dcf
+ * Returns a valid mount command exit code.
bbc1dcf
+ */
bbc1dcf
+static int nfsmount_start(struct nfsmount_info *mi)
bbc1dcf
+{
bbc1dcf
+	if (!nfs_validate_options(mi))
bbc1dcf
+		return EX_FAIL;
bbc1dcf
+
bbc1dcf
+	if (po_rightmost(mi->options, "bg", "fg") == PO_KEY1_RIGHTMOST)
bbc1dcf
+		return nfsmount_bg(mi);
bbc1dcf
 	else
bbc1dcf
-		return nfsmount_child(spec, node, type, hostname, flags,
bbc1dcf
-					options, fake, extra_opts);
bbc1dcf
+		return nfsmount_fg(mi);
bbc1dcf
 }
bbc1dcf
 
bbc1dcf
 /**
bbc1dcf
@@ -723,35 +752,27 @@ static int nfsmount_bg(const char *spec, const char *node,
bbc1dcf
 int nfsmount_string(const char *spec, const char *node, const char *type,
bbc1dcf
 		    int flags, char **extra_opts, int fake, int child)
bbc1dcf
 {
bbc1dcf
-	struct mount_options *options = NULL;
bbc1dcf
-	struct sockaddr_in saddr;
bbc1dcf
-	char *hostname;
bbc1dcf
+	struct nfsmount_info mi = {
bbc1dcf
+		.spec		= spec,
bbc1dcf
+		.node		= node,
bbc1dcf
+		.type		= type,
bbc1dcf
+		.extra_opts	= extra_opts,
bbc1dcf
+		.flags		= flags,
bbc1dcf
+		.fake		= fake,
bbc1dcf
+		.child		= child,
bbc1dcf
+	};
bbc1dcf
 	int retval = EX_FAIL;
bbc1dcf
 
bbc1dcf
-	if (!parse_devname(spec, &hostname))
bbc1dcf
+	if (!nfs_parse_devname(&mi))
bbc1dcf
 		return retval;
bbc1dcf
-	if (!fill_ipv4_sockaddr(hostname, &saddr))
bbc1dcf
-		goto fail;
bbc1dcf
 
bbc1dcf
-	options = po_split(*extra_opts);
bbc1dcf
-	if (!options) {
bbc1dcf
+	mi.options = po_split(*extra_opts);
bbc1dcf
+	if (mi.options) {
bbc1dcf
+		retval = nfsmount_start(&mi);
bbc1dcf
+		po_destroy(mi.options);
bbc1dcf
+	} else
bbc1dcf
 		nfs_error(_("%s: internal option parsing error"), progname);
bbc1dcf
-		goto fail;
bbc1dcf
-	}
bbc1dcf
 
bbc1dcf
-	if (!validate_options(type, &saddr, options, fake))
bbc1dcf
-		goto out;
bbc1dcf
-
bbc1dcf
-	if (po_rightmost(options, "bg", "fg") == PO_KEY1_RIGHTMOST)
bbc1dcf
-		retval = nfsmount_bg(spec, node, type, hostname, flags,
bbc1dcf
-					options, fake, child, extra_opts);
bbc1dcf
-	else
bbc1dcf
-		retval = nfsmount_fg(spec, node, type, flags, options,
bbc1dcf
-							fake, extra_opts);
bbc1dcf
-
bbc1dcf
-out:
bbc1dcf
-	po_destroy(options);
bbc1dcf
-fail:
bbc1dcf
-	free(hostname);
bbc1dcf
+	free(mi.hostname);
bbc1dcf
 	return retval;
bbc1dcf
 }