patch-2.1.127 linux/fs/namei.c

Next file: linux/fs/ncpfs/sock.c
Previous file: linux/fs/lockd/svc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.126/linux/fs/namei.c linux/fs/namei.c
@@ -28,10 +28,23 @@
 #include <asm/unaligned.h>
 #include <asm/semaphore.h>
 #include <asm/spinlock.h>
-#include <asm/namei.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 
+/*
+ * The bitmask for a lookup event:
+ *  - follow links at the end
+ *  - require a directory
+ *  - ending slashes ok even for nonexistent files
+ *  - internal "there are more path compnents" flag
+ */
+#define LOOKUP_FOLLOW		(1)
+#define LOOKUP_DIRECTORY	(2)
+#define LOOKUP_SLASHOK		(4)
+#define LOOKUP_CONTINUE		(8)
+
+#include <asm/namei.h>
+
 /* This can be removed after the beta phase. */
 #define CACHE_SUPERVISE	/* debug the correctness of dcache entries */
 #undef DEBUG		/* some other debugging */
@@ -282,18 +295,6 @@
 	return result;
 }
 
-/*
- * The bitmask for a lookup event:
- *  - follow links at the end
- *  - require a directory
- *  - ending slashes ok even for nonexistent files
- *  - internal "there are more path compnents" flag
- */
-#define LOOKUP_FOLLOW		(1)
-#define LOOKUP_DIRECTORY	(2)
-#define LOOKUP_SLASHOK		(4)
-#define LOOKUP_CONTINUE		(8)
-
 static struct dentry * do_follow_link(struct dentry *base, struct dentry *dentry, unsigned int follow)
 {
 	struct inode * inode = dentry->d_inode;
@@ -342,10 +343,10 @@
 	if (*name == '/') {
 		if (base)
 			dput(base);
-		base = dget(current->fs->root);
 		do {
 			name++;
 		} while (*name == '/');
+		base = dget(current->fs->root);
 	} else if (!base) {
 		base = dget(current->fs->pwd);
 	}
@@ -626,7 +627,7 @@
 	if (!inode)
 		goto exit;
 
-	error = -EACCES;
+	error = -ELOOP;
 	if (S_ISLNK(inode->i_mode))
 		goto exit;
 	
@@ -1195,7 +1196,7 @@
 
 	error = -ENOENT;
 	if (!old_dentry->d_inode)
-		goto exit;
+		goto exit_old;
 
 	{
 		unsigned int flags = 0;

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