[RFC,PATCH 2/4] Dynamic Pseudo Root

Steve Dickson SteveD at redhat.com
Fri Dec 7 14:28:14 EST 2007


commit c75fcc88ef65446a6672b88aa17cdde43641b1b5
Author: Steve Dickson <steved at redhat.com>
Date:   Fri Nov 30 15:03:53 2007 -0500

    If '/' is exported without a defined pseudo root, that export
    will be used as the pseudo root regardless of the fsid setting.
    
    Signed-off-by: Steve Dickson <steved at redhat.com>

---
 support/export/xtab.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/support/export/xtab.c b/support/export/xtab.c
index fee6ad2..bdc76c9 100644
--- a/support/export/xtab.c
+++ b/support/export/xtab.c
@@ -31,7 +31,7 @@ xtab_read(char *xtab, int is_export)
      * is_export == 2  => reading /var/lib/nfs/xtab - these things might be known to kernel
      */
 	struct exportent	*xp;
-	nfs_export		*exp;
+	nfs_export		*exp, *root_exp = NULL;
 	int			lockid;
 
 	if ((lockid = xflock(xtab, "r")) < 0)
@@ -53,12 +53,28 @@ xtab_read(char *xtab, int is_export)
 			exp->m_mayexport = 1;
 			if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0)
 				need_v4root = 0;
+			if (strcmp(xp->e_path, "/") == 0)
+				root_exp = exp;
 			break;
 		case 2:
 			exp->m_exported = -1;/* may be exported */
 			break;
 		}
 	}
+	/*
+	 * If '/' has been exported without defining a separate
+	 * pseudo root, that export becomes the pseudo root.
+	 */
+	if (root_exp && need_v4root) {
+		if (root_exp->m_export.e_flags & NFSEXP_FSID) {
+			if (root_exp->m_export.e_fsid) 
+				xlog(L_WARNING,"Overwriting fsid on '/' export to "
+					"become the v4 pseudo root");
+		}
+		root_exp->m_export.e_flags |= NFSEXP_FSID;
+		root_exp->m_export.e_fsid = 0;
+		need_v4root = 0;
+	}
 	endexportent();
 	xfunlock(lockid);
 


More information about the NFSv4 mailing list