walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
f5b3ef3
commit 124b74413e943ab9c02cdff2832d1d81dc9fda87
f5b3ef3
Author: J. Bruce Fields <bfields@citi.umich.edu>
f5b3ef3
Date:   Thu Aug 28 11:17:34 2008 -0400
f5b3ef3
f5b3ef3
    Remove redundant m_path field
f5b3ef3
    
f5b3ef3
    Contrary to the comment above its definition, the field m_path always
f5b3ef3
    has the same value as e_path: the *only* modifications of m_path are all
f5b3ef3
    of the form:
f5b3ef3
    
f5b3ef3
    	strncpy(exp->m_export.m_path, exp->m_export.e_path,
f5b3ef3
    		sizeof (exp->m_export.m_path) - 1);
f5b3ef3
    	exp->m_export.m_path[sizeof (exp->m_export.m_path) - 1] = '\0';
f5b3ef3
    
f5b3ef3
    So m_path is always just a copy of e_path.  In places where we need to
f5b3ef3
    store a path to a submount of a CROSSMNT-exported filesystem, as in
f5b3ef3
    cache.c, we just use a local variable.
f5b3ef3
    
f5b3ef3
    Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
f5b3ef3
    Signed-off-by: Steve Dickson <steved@redhat.com>
f5b3ef3
f5b3ef3
diff --git a/support/export/export.c b/support/export/export.c
f5b3ef3
index 93c58b6..14af112 100644
f5b3ef3
--- a/support/export/export.c
f5b3ef3
+++ b/support/export/export.c
f5b3ef3
@@ -255,15 +255,3 @@ export_freeall(void)
f5b3ef3
 	}
f5b3ef3
 	client_freeall();
f5b3ef3
 }
f5b3ef3
-
f5b3ef3
-void
f5b3ef3
-export_reset(nfs_export *exp)
f5b3ef3
-{
f5b3ef3
-	if (!exp)
f5b3ef3
-		return;
f5b3ef3
-
f5b3ef3
-	/* Restore m_path. */
f5b3ef3
-	strncpy(exp->m_export.m_path, exp->m_export.e_path,
f5b3ef3
-		sizeof (exp->m_export.m_path) - 1);
f5b3ef3
-	exp->m_export.m_path[sizeof (exp->m_export.m_path) - 1] = '\0';
f5b3ef3
-}
f5b3ef3
diff --git a/support/export/nfsctl.c b/support/export/nfsctl.c
f5b3ef3
index 32d92bd..e2877b9 100644
f5b3ef3
--- a/support/export/nfsctl.c
f5b3ef3
+++ b/support/export/nfsctl.c
f5b3ef3
@@ -89,11 +89,11 @@ expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport)
f5b3ef3
 	nfs_client		*clp = exp->m_client;
f5b3ef3
 	struct stat		stb;
f5b3ef3
 
f5b3ef3
-	if (stat(exp->m_export.m_path, &stb) < 0)
f5b3ef3
+	if (stat(exp->m_export.e_path, &stb) < 0)
f5b3ef3
 		return 0;
f5b3ef3
 
f5b3ef3
 	memset(exparg, 0, sizeof(*exparg));
f5b3ef3
-	strncpy(exparg->ex_path, exp->m_export.m_path,
f5b3ef3
+	strncpy(exparg->ex_path, exp->m_export.e_path,
f5b3ef3
 		sizeof (exparg->ex_path) - 1);
f5b3ef3
 	strncpy(exparg->ex_client, clp->m_hostname,
f5b3ef3
 		sizeof (exparg->ex_client) - 1);
f5b3ef3
diff --git a/support/include/nfslib.h b/support/include/nfslib.h
f5b3ef3
index 422b012..a51d79d 100644
f5b3ef3
--- a/support/include/nfslib.h
f5b3ef3
+++ b/support/include/nfslib.h
f5b3ef3
@@ -67,11 +67,6 @@ struct sec_entry {
f5b3ef3
 struct exportent {
f5b3ef3
 	char *		e_hostname;
f5b3ef3
 	char		e_path[NFS_MAXPATHLEN+1];
f5b3ef3
-	/* The mount path may be different from the exported path due
f5b3ef3
-	   to submount. It may change for every mount. The idea is we
f5b3ef3
-	   set m_path every time when we process a mount. We should not
f5b3ef3
-	   use it for anything else. */
f5b3ef3
-	char		m_path[NFS_MAXPATHLEN+1];
f5b3ef3
 	int		e_flags;
f5b3ef3
 	int		e_anonuid;
f5b3ef3
 	int		e_anongid;
f5b3ef3
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
f5b3ef3
index 334c08e..1aaebf4 100644
f5b3ef3
--- a/support/nfs/exports.c
f5b3ef3
+++ b/support/nfs/exports.c
f5b3ef3
@@ -127,8 +127,6 @@ getexportent(int fromkernel, int fromexports)
f5b3ef3
 		if (ok <= 0)
f5b3ef3
 			return NULL;
f5b3ef3
 
f5b3ef3
-		strncpy (def_ee.m_path, def_ee.e_path, sizeof (def_ee.m_path) - 1);
f5b3ef3
-		def_ee.m_path [sizeof (def_ee.m_path) - 1] = '\0';
f5b3ef3
 		ok = getexport(exp, sizeof(exp));
f5b3ef3
 	}
f5b3ef3
 	if (ok < 0) {
f5b3ef3
@@ -187,8 +185,6 @@ getexportent(int fromkernel, int fromexports)
f5b3ef3
 		rpath[sizeof (rpath) - 1] = '\0';
f5b3ef3
 		strncpy(ee.e_path, rpath, sizeof (ee.e_path) - 1);
f5b3ef3
 		ee.e_path[sizeof (ee.e_path) - 1] = '\0';
f5b3ef3
-		strncpy (ee.m_path, ee.e_path, sizeof (ee.m_path) - 1);
f5b3ef3
-		ee.m_path [sizeof (ee.m_path) - 1] = '\0';
f5b3ef3
 	}
f5b3ef3
 
f5b3ef3
 	return ⅇ
f5b3ef3
@@ -360,8 +356,6 @@ mkexportent(char *hname, char *path, char *options)
f5b3ef3
 	}
f5b3ef3
 	strncpy(ee.e_path, path, sizeof (ee.e_path));
f5b3ef3
 	ee.e_path[sizeof (ee.e_path) - 1] = '\0';
f5b3ef3
-	strncpy (ee.m_path, ee.e_path, sizeof (ee.m_path) - 1);
f5b3ef3
-	ee.m_path [sizeof (ee.m_path) - 1] = '\0';
f5b3ef3
 	if (parseopts(options, &ee, 0, NULL) < 0)
f5b3ef3
 		return NULL;
f5b3ef3
 	return ⅇ
f5b3ef3
diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c
f5b3ef3
index 8137f7f..0facf89 100644
f5b3ef3
--- a/utils/mountd/mountd.c
f5b3ef3
+++ b/utils/mountd/mountd.c
f5b3ef3
@@ -230,9 +230,6 @@ mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *resp)
f5b3ef3
 		return 1;
f5b3ef3
 	}
f5b3ef3
 
f5b3ef3
-	if (!new_cache)
f5b3ef3
-		export_reset (exp);
f5b3ef3
-
f5b3ef3
 	mountlist_del(inet_ntoa(sin->sin_addr), p);
f5b3ef3
 	return 1;
f5b3ef3
 }
f5b3ef3
@@ -312,7 +309,6 @@ mount_pathconf_2_svc(struct svc_req *rqstp, dirpath *path, ppathcnf *res)
f5b3ef3
 	} else if (stat(p, &stb) < 0) {
f5b3ef3
 		xlog(L_WARNING, "can't stat exported dir %s: %s",
f5b3ef3
 				p, strerror(errno));
f5b3ef3
-		export_reset (exp);
f5b3ef3
 		return 1;
f5b3ef3
 	}
f5b3ef3
 
f5b3ef3
@@ -328,8 +324,6 @@ mount_pathconf_2_svc(struct svc_req *rqstp, dirpath *path, ppathcnf *res)
f5b3ef3
 	res->pc_mask[0]   = 0;
f5b3ef3
 	res->pc_mask[1]   = 0;
f5b3ef3
 
f5b3ef3
-	export_reset (exp);
f5b3ef3
-
f5b3ef3
 	return 1;
f5b3ef3
 }
f5b3ef3
 
f5b3ef3
@@ -457,13 +451,11 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, mountstat3 *error, int v3)
f5b3ef3
 		if (fh != NULL) {
f5b3ef3
 			mountlist_add(inet_ntoa(sin->sin_addr), p);
f5b3ef3
 			*error = NFS_OK;
f5b3ef3
-			export_reset (exp);
f5b3ef3
 			return fh;
f5b3ef3
 		}
f5b3ef3
 		xlog(L_WARNING, "getfh failed: %s", strerror(errno));
f5b3ef3
 		*error = NFSERR_ACCES;
f5b3ef3
 	}
f5b3ef3
-	export_reset (exp);
f5b3ef3
 	return NULL;
f5b3ef3
 }
f5b3ef3
 
f5b3ef3
@@ -499,14 +491,14 @@ get_exportlist(void)
f5b3ef3
 	for (i = 0; i < MCL_MAXTYPES; i++) {
f5b3ef3
 		for (exp = exportlist[i]; exp; exp = exp->m_next) {
f5b3ef3
 			for (e = elist; e != NULL; e = e->ex_next) {
f5b3ef3
-				if (!strcmp(exp->m_export.m_path, e->ex_dir))
f5b3ef3
+				if (!strcmp(exp->m_export.e_path, e->ex_dir))
f5b3ef3
 					break;
f5b3ef3
 			}
f5b3ef3
 			if (!e) {
f5b3ef3
 				e = (struct exportnode *) xmalloc(sizeof(*e));
f5b3ef3
 				e->ex_next = elist;
f5b3ef3
 				e->ex_groups = NULL;
f5b3ef3
-				e->ex_dir = xstrdup(exp->m_export.m_path);
f5b3ef3
+				e->ex_dir = xstrdup(exp->m_export.e_path);
f5b3ef3
 				elist = e;
f5b3ef3
 			}
f5b3ef3
 
f5b3ef3
diff --git a/utils/mountd/rmtab.c b/utils/mountd/rmtab.c
f5b3ef3
index e8aff5a..5787ed6 100644
f5b3ef3
--- a/utils/mountd/rmtab.c
f5b3ef3
+++ b/utils/mountd/rmtab.c
f5b3ef3
@@ -162,10 +162,8 @@ mountlist_del_all(struct sockaddr_in *sin)
f5b3ef3
 	}
f5b3ef3
 	while ((rep = getrmtabent(1, NULL)) != NULL) {
f5b3ef3
 		if (strcmp(rep->r_client, hp->h_name) == 0 &&
f5b3ef3
-		    (exp = auth_authenticate("umountall", sin, rep->r_path))) {
f5b3ef3
-			export_reset(exp);
f5b3ef3
+		    (exp = auth_authenticate("umountall", sin, rep->r_path)))
f5b3ef3
 			continue;
f5b3ef3
-		}
f5b3ef3
 		fputrmtabent(fp, rep, NULL);
f5b3ef3
 	}
f5b3ef3
 	if (slink_safe_rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {