Skip to contentSkip to conversation

exportfs: drop unused is_export parameter from xtab_read() and xtab_write()

PATCH In review Jeff Layton 2 participants 3 messages May 14 – May 15

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH 1/1 exportfs: drop unused is_export parameter from xtab_read() and xtab_write()

The is_export parameter is always passed as 1. Remove it and simplify both functions by eliminating the dead is_export == 0 code paths.

---
 support/export/xtab.c | 39 +++++++++++++--------------------------
 1 file changed, 13 insertions(+), 26 deletions(-)
support/export/xtab.c +13 -26
index 282f15bc79cd..0a9660512b26 100644
@@ -33,11 +33,8 @@ int v4root_needed;
 static void cond_rename(char *newfile, char *oldfile);
 
 static int
-xtab_read(char *xtab, char *lockfn, int is_export)
+xtab_read(char *xtab, char *lockfn)
 {
-    /* is_export == 0  => reading /proc/fs/nfs/exports - we know these things are exported to kernel
-     * is_export == 1  => reading /var/lib/nfs/etab - these things are allowed to be exported
-     */
 	struct exportent	*xp;
 	nfs_export		*exp;
 	int			lockid;
@@ -45,11 +42,10 @@ xtab_read(char *xtab, char *lockfn, int is_export)
 	if ((lockid = xflock(lockfn, "r")) < 0)
 		return 0;
 	setexportent(xtab, "r");
-	if (is_export == 1)
-		v4root_needed = 1;
-	while ((xp = getexportent(is_export==0)) != NULL) {
-		if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) &&
-		    !(exp = export_create(xp, is_export!=1))) {
+	v4root_needed = 1;
+	while ((xp = getexportent(0)) != NULL) {
+		if (!(exp = export_lookup(xp->e_hostname, xp->e_path, 0)) &&
+		    !(exp = export_create(xp, 0))) {
                         if(xp->e_hostname) {
                             free(xp->e_hostname);
                             xp->e_hostname=NULL;
@@ -60,17 +56,10 @@ xtab_read(char *xtab, char *lockfn, int is_export)
                         }
 			continue;
 		}
-		switch (is_export) {
-		case 0:
-			exp->m_exported = 1;
-			break;
-		case 1:
-			exp->m_xtabent = 1;
-			exp->m_mayexport = 1;
-			if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0)
-				v4root_needed = 0;
-			break;
-		}  
+		exp->m_xtabent = 1;
+		exp->m_mayexport = 1;
+		if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0)
+			v4root_needed = 0;
                 if(xp->e_hostname) {
                     free(xp->e_hostname);
                     xp->e_hostname=NULL;
@@ -90,7 +79,7 @@ xtab_read(char *xtab, char *lockfn, int is_export)
 int
 xtab_export_read(void)
 {
-	return xtab_read(etab.statefn, etab.lockfn, 1);
+	return xtab_read(etab.statefn, etab.lockfn);
 }
 
 /*
@@ -100,7 +89,7 @@ xtab_export_read(void)
  * fix the auth_reload logic as well...
  */
 static int
-xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
+xtab_write(char *xtab, char *xtabtmp, char *lockfn)
 {
 	struct exportent	xe;
 	nfs_export		*exp;
@@ -114,9 +103,7 @@ xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
 
 	for (i = 0; i < MCL_MAXTYPES; i++) {
 		for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
-			if (is_export && !exp->m_xtabent)
-				continue;
-			if (!is_export && ! exp->m_exported)
+			if (!exp->m_xtabent)
 				continue;
 
 			/* write out the export entry using the FQDN */
@@ -137,7 +124,7 @@ xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
 int
 xtab_export_write(void)
 {
-	return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn, 1);
+	return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn);
 }
 
 /*

---
base-commit: cbbf618b31b64198de06a350c4f5744c76e51ecb
change-id: 20260514-exportd-ceb123e6fff2

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#1 lore raw

Oops, I meant to make this '[nfs-utils PATCH]'. Ahh well, anyway, it's just a bit of cleanup...

-- Jeff

Quoted 107 lines · Jeff Layton

The is_export parameter is always passed as 1. Remove it and simplify both functions by eliminating the dead is_export == 0 code paths.

---
 support/export/xtab.c | 39 +++++++++++++--------------------------
 1 file changed, 13 insertions(+), 26 deletions(-)
support/export/xtab.c +13 -27
index 282f15bc79cd..0a9660512b26 100644
@@ -33,11 +33,8 @@ int v4root_needed;
 static void cond_rename(char *newfile, char *oldfile);
 
 static int
-xtab_read(char *xtab, char *lockfn, int is_export)
+xtab_read(char *xtab, char *lockfn)
 {
-    /* is_export == 0  => reading /proc/fs/nfs/exports - we know these things are exported to kernel
-     * is_export == 1  => reading /var/lib/nfs/etab - these things are allowed to be exported
-     */
 	struct exportent	*xp;
 	nfs_export		*exp;
 	int			lockid;
@@ -45,11 +42,10 @@ xtab_read(char *xtab, char *lockfn, int is_export)
 	if ((lockid = xflock(lockfn, "r")) < 0)
 		return 0;
 	setexportent(xtab, "r");
-	if (is_export == 1)
-		v4root_needed = 1;
-	while ((xp = getexportent(is_export==0)) != NULL) {
-		if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) &&
-		    !(exp = export_create(xp, is_export!=1))) {
+	v4root_needed = 1;
+	while ((xp = getexportent(0)) != NULL) {
+		if (!(exp = export_lookup(xp->e_hostname, xp->e_path, 0)) &&
+		    !(exp = export_create(xp, 0))) {
                         if(xp->e_hostname) {
                             free(xp->e_hostname);
                             xp->e_hostname=NULL;
@@ -60,17 +56,10 @@ xtab_read(char *xtab, char *lockfn, int is_export)
                         }
 			continue;
 		}
-		switch (is_export) {
-		case 0:
-			exp->m_exported = 1;
-			break;
-		case 1:
-			exp->m_xtabent = 1;
-			exp->m_mayexport = 1;
-			if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0)
-				v4root_needed = 0;
-			break;
-		}  
+		exp->m_xtabent = 1;
+		exp->m_mayexport = 1;
+		if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0)
+			v4root_needed = 0;
                 if(xp->e_hostname) {
                     free(xp->e_hostname);
                     xp->e_hostname=NULL;
@@ -90,7 +79,7 @@ xtab_read(char *xtab, char *lockfn, int is_export)
 int
 xtab_export_read(void)
 {
-	return xtab_read(etab.statefn, etab.lockfn, 1);
+	return xtab_read(etab.statefn, etab.lockfn);
 }
 
 /*
@@ -100,7 +89,7 @@ xtab_export_read(void)
  * fix the auth_reload logic as well...
  */
 static int
-xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
+xtab_write(char *xtab, char *xtabtmp, char *lockfn)
 {
 	struct exportent	xe;
 	nfs_export		*exp;
@@ -114,9 +103,7 @@ xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
 
 	for (i = 0; i < MCL_MAXTYPES; i++) {
 		for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
-			if (is_export && !exp->m_xtabent)
-				continue;
-			if (!is_export && ! exp->m_exported)
+			if (!exp->m_xtabent)
 				continue;
 
 			/* write out the export entry using the FQDN */
@@ -137,7 +124,7 @@ xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
 int
 xtab_export_write(void)
 {
-	return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn, 1);
+	return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn);
 }
 
 /*
 
---

base-commit: cbbf618b31b64198de06a350c4f5744c76e51ecb
change-id: 20260514-exportd-ceb123e6fff2

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
#2 lore raw
In reply to Jeff Layton
Quoted 4 lines · Jeff Layton

The is_export parameter is always passed as 1. Remove it and simplify both functions by eliminating the dead is_export == 0 code paths.

Committed (tag: nfs-utils-2-9-2-rc3)

steved

Quoted 103 lines
---
  support/export/xtab.c | 39 +++++++++++++--------------------------
  1 file changed, 13 insertions(+), 26 deletions(-)
support/export/xtab.c +13 -27
index 282f15bc79cd..0a9660512b26 100644
@@ -33,11 +33,8 @@ int v4root_needed;
  static void cond_rename(char *newfile, char *oldfile);
 
  static int
-xtab_read(char *xtab, char *lockfn, int is_export)
+xtab_read(char *xtab, char *lockfn)
  {
-    /* is_export == 0  => reading /proc/fs/nfs/exports - we know these things are exported to kernel
-     * is_export == 1  => reading /var/lib/nfs/etab - these things are allowed to be exported
-     */
  	struct exportent	*xp;
  	nfs_export		*exp;
  	int			lockid;
@@ -45,11 +42,10 @@ xtab_read(char *xtab, char *lockfn, int is_export)
  	if ((lockid = xflock(lockfn, "r")) < 0)
  		return 0;
  	setexportent(xtab, "r");
-	if (is_export == 1)
-		v4root_needed = 1;
-	while ((xp = getexportent(is_export==0)) != NULL) {
-		if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) &&
-		    !(exp = export_create(xp, is_export!=1))) {
+	v4root_needed = 1;
+	while ((xp = getexportent(0)) != NULL) {
+		if (!(exp = export_lookup(xp->e_hostname, xp->e_path, 0)) &&
+		    !(exp = export_create(xp, 0))) {
                          if(xp->e_hostname) {
                              free(xp->e_hostname);
                              xp->e_hostname=NULL;
@@ -60,17 +56,10 @@ xtab_read(char *xtab, char *lockfn, int is_export)
                          }
  			continue;
  		}
-		switch (is_export) {
-		case 0:
-			exp->m_exported = 1;
-			break;
-		case 1:
-			exp->m_xtabent = 1;
-			exp->m_mayexport = 1;
-			if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0)
-				v4root_needed = 0;
-			break;
-		}
+		exp->m_xtabent = 1;
+		exp->m_mayexport = 1;
+		if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0)
+			v4root_needed = 0;
                  if(xp->e_hostname) {
                      free(xp->e_hostname);
                      xp->e_hostname=NULL;
@@ -90,7 +79,7 @@ xtab_read(char *xtab, char *lockfn, int is_export)
  int
  xtab_export_read(void)
  {
-	return xtab_read(etab.statefn, etab.lockfn, 1);
+	return xtab_read(etab.statefn, etab.lockfn);
  }
 
  /*
@@ -100,7 +89,7 @@ xtab_export_read(void)
   * fix the auth_reload logic as well...
   */
  static int
-xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
+xtab_write(char *xtab, char *xtabtmp, char *lockfn)
  {
  	struct exportent	xe;
  	nfs_export		*exp;
@@ -114,9 +103,7 @@ xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
 
  	for (i = 0; i < MCL_MAXTYPES; i++) {
  		for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
-			if (is_export && !exp->m_xtabent)
-				continue;
-			if (!is_export && ! exp->m_exported)
+			if (!exp->m_xtabent)
  				continue;
 
  			/* write out the export entry using the FQDN */
@@ -137,7 +124,7 @@ xtab_write(char *xtab, char *xtabtmp, char *lockfn, int is_export)
  int
  xtab_export_write(void)
  {
-	return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn, 1);
+	return xtab_write(etab.statefn, etab.tmpfn, etab.lockfn);
  }
 
  /*
 
---

base-commit: cbbf618b31b64198de06a350c4f5744c76e51ecb
change-id: 20260514-exportd-ceb123e6fff2

Best regards,