patch-2.1.79 linux/include/asm-sparc64/namei.h

Next file: linux/include/asm-sparc64/ns87303.h
Previous file: linux/include/asm-sparc64/mmu_context.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.78/linux/include/asm-sparc64/namei.h linux/include/asm-sparc64/namei.h
@@ -1,4 +1,4 @@
-/* $Id: namei.h,v 1.8 1997/09/06 02:25:27 davem Exp $
+/* $Id: namei.h,v 1.10 1997/09/24 16:20:41 jj Exp $
  * linux/include/asm-sparc64/namei.h
  *
  * Routines to handle famous /usr/gnemul/s*.
@@ -10,40 +10,55 @@
 
 #define SPARC_BSD_EMUL "usr/gnemul/sunos/"
 #define SPARC_SOL_EMUL "usr/gnemul/solaris/"
+#define SPARC_LIN_EMUL "usr/gnemul/linux32/"
 
 static inline struct dentry *
 __sparc64_lookup_dentry(const char *name, int follow_link)
 {
 	struct dentry *base;
+	char *emul;
 
 	switch (current->personality) {
 	case PER_BSD:
+		emul = SPARC_BSD_EMUL; break;
 	case PER_SVR4:
-		break;
+		emul = SPARC_SOL_EMUL; break;
+	case PER_LINUX32:
+		emul = SPARC_LIN_EMUL; break;
 	default:
-		return ERR_PTR(-ENOENT);
+		return NULL;
 	}
 
-	base = lookup_dentry ((current->personality == PER_BSD) ?
-			SPARC_BSD_EMUL : SPARC_SOL_EMUL,
-			dget (current->fs->root), 1);
+	base = lookup_dentry (emul, dget (current->fs->root), 1);
 			
-	if (IS_ERR (base)) return base;
+	if (IS_ERR (base)) return NULL;
 	
 	base = lookup_dentry (name, base, follow_link);
 	
-	if (IS_ERR (base)) return base;
+	if (IS_ERR (base)) return NULL;
 	
 	if (!base->d_inode) {
-		dput(base);
-		return ERR_PTR(-ENOENT);
+		struct dentry *fromroot;
+		
+		fromroot = lookup_dentry (name, dget (current->fs->root), follow_link);
+		
+		if (IS_ERR (fromroot)) return base;
+		
+		if (fromroot->d_inode) {
+			dput(base);
+			return fromroot;
+		}
+		
+		dput(fromroot);
 	}
 	
 	return base;
 }
 
 #define __prefix_lookup_dentry(name, follow_link)				\
-	dentry = __sparc64_lookup_dentry (name, follow_link);			\
-	if (!IS_ERR (dentry)) return dentry;
+	if (current->personality) {						\
+		dentry = __sparc64_lookup_dentry (name, follow_link);		\
+		if (dentry) return dentry;					\
+	}
 
 #endif /* __SPARC64_NAMEI_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov