patch-2.3.23 linux/include/asm-arm/namei.h

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

diff -u --recursive --new-file v2.3.22/linux/include/asm-arm/namei.h linux/include/asm-arm/namei.h
@@ -1,18 +1,62 @@
 /* 
  * linux/include/asm-arm/namei.h
  *
+ * Routines to handle famous /usr/gnemul
+ * Derived from the Sparc version of this file
+ *
  * Included from linux/fs/namei.c
  */
 
 #ifndef __ASMARM_NAMEI_H
 #define __ASMARM_NAMEI_H
 
-/* This dummy routine maybe changed to something useful
- * for /usr/gnemul/ emulation stuff.
- * Look at asm-sparc/namei.h for details.
- */
+#define ARM_BSD_EMUL "usr/gnemul/bsd/"
+
+static inline struct dentry *
+__arm_lookup_dentry(const char *name, int lookup_flags)
+{
+	struct dentry *base;
+	char *emul;
+
+	switch (current->personality) {
+	case PER_BSD:
+		emul = ARM_BSD_EMUL; break;
+	default:
+		return NULL;
+	}
+
+	base = lookup_dentry (emul, dget (current->fs->root),
+		      (LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_SLASHOK));
+			
+	if (IS_ERR (base)) return NULL;
+	
+	base = lookup_dentry (name, base, lookup_flags);
+	
+	if (IS_ERR (base)) return NULL;
+	
+	if (!base->d_inode) {
+		struct dentry *fromroot;
+		
+		fromroot = lookup_dentry (name, dget (current->fs->root), 
+					  lookup_flags);
+		
+		if (IS_ERR (fromroot)) return base;
+		
+		if (fromroot->d_inode) {
+			dput(base);
+			return fromroot;
+		}
+		
+		dput(fromroot);
+	}
+	
+	return base;
+}
 
-#define __prefix_lookup_dentry(name, lookup_flags) \
-        do {} while (0)
+#define __prefix_lookup_dentry(name, lookup_flags)			\
+	if (current->personality) {					\
+		dentry = __arm_lookup_dentry (name, lookup_flags);	\
+		if (dentry) return dentry;				\
+	}
 
 #endif /* __ASMARM_NAMEI_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)