adfs_lookup: do not fail with ENOENT on negatives, use d_splice_alias()
[muen/linux.git] / fs / adfs / dir.c
index 77a2d6ca3c6066aa70fb578a63b555af9578f4e1..e18eff854e1a44009baca3b373ac5b2a765d78be 100644 (file)
@@ -252,17 +252,17 @@ adfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
 
        error = adfs_dir_lookup_byname(dir, &dentry->d_name, &obj);
        if (error == 0) {
-               error = -EACCES;
                /*
                 * This only returns NULL if get_empty_inode
                 * fails.
                 */
                inode = adfs_iget(dir->i_sb, &obj);
-               if (inode)
-                       error = 0;
+               if (!inode)
+                       inode = ERR_PTR(-EACCES);
+       } else if (error != -ENOENT) {
+               inode = ERR_PTR(error);
        }
-       d_add(dentry, inode);
-       return ERR_PTR(error);
+       return d_splice_alias(inode, dentry);
 }
 
 /*