diff options
Diffstat (limited to 'fs/ext2/namei.c')
-rw-r--r-- | fs/ext2/namei.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 80c97fd8c571..2a747252ec12 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -60,7 +60,7 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str | |||
60 | if (dentry->d_name.len > EXT2_NAME_LEN) | 60 | if (dentry->d_name.len > EXT2_NAME_LEN) |
61 | return ERR_PTR(-ENAMETOOLONG); | 61 | return ERR_PTR(-ENAMETOOLONG); |
62 | 62 | ||
63 | ino = ext2_inode_by_name(dir, dentry); | 63 | ino = ext2_inode_by_name(dir, &dentry->d_name); |
64 | inode = NULL; | 64 | inode = NULL; |
65 | if (ino) { | 65 | if (ino) { |
66 | inode = ext2_iget(dir->i_sb, ino); | 66 | inode = ext2_iget(dir->i_sb, ino); |
@@ -72,27 +72,11 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str | |||
72 | 72 | ||
73 | struct dentry *ext2_get_parent(struct dentry *child) | 73 | struct dentry *ext2_get_parent(struct dentry *child) |
74 | { | 74 | { |
75 | unsigned long ino; | 75 | struct qstr dotdot = {.name = "..", .len = 2}; |
76 | struct dentry *parent; | 76 | unsigned long ino = ext2_inode_by_name(child->d_inode, &dotdot); |
77 | struct inode *inode; | ||
78 | struct dentry dotdot; | ||
79 | |||
80 | dotdot.d_name.name = ".."; | ||
81 | dotdot.d_name.len = 2; | ||
82 | |||
83 | ino = ext2_inode_by_name(child->d_inode, &dotdot); | ||
84 | if (!ino) | 77 | if (!ino) |
85 | return ERR_PTR(-ENOENT); | 78 | return ERR_PTR(-ENOENT); |
86 | inode = ext2_iget(child->d_inode->i_sb, ino); | 79 | return d_obtain_alias(ext2_iget(child->d_inode->i_sb, ino)); |
87 | |||
88 | if (IS_ERR(inode)) | ||
89 | return ERR_CAST(inode); | ||
90 | parent = d_alloc_anon(inode); | ||
91 | if (!parent) { | ||
92 | iput(inode); | ||
93 | parent = ERR_PTR(-ENOMEM); | ||
94 | } | ||
95 | return parent; | ||
96 | } | 80 | } |
97 | 81 | ||
98 | /* | 82 | /* |
@@ -257,7 +241,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry) | |||
257 | struct page * page; | 241 | struct page * page; |
258 | int err = -ENOENT; | 242 | int err = -ENOENT; |
259 | 243 | ||
260 | de = ext2_find_entry (dir, dentry, &page); | 244 | de = ext2_find_entry (dir, &dentry->d_name, &page); |
261 | if (!de) | 245 | if (!de) |
262 | goto out; | 246 | goto out; |
263 | 247 | ||
@@ -299,7 +283,7 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry, | |||
299 | struct ext2_dir_entry_2 * old_de; | 283 | struct ext2_dir_entry_2 * old_de; |
300 | int err = -ENOENT; | 284 | int err = -ENOENT; |
301 | 285 | ||
302 | old_de = ext2_find_entry (old_dir, old_dentry, &old_page); | 286 | old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page); |
303 | if (!old_de) | 287 | if (!old_de) |
304 | goto out; | 288 | goto out; |
305 | 289 | ||
@@ -319,7 +303,7 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry, | |||
319 | goto out_dir; | 303 | goto out_dir; |
320 | 304 | ||
321 | err = -ENOENT; | 305 | err = -ENOENT; |
322 | new_de = ext2_find_entry (new_dir, new_dentry, &new_page); | 306 | new_de = ext2_find_entry (new_dir, &new_dentry->d_name, &new_page); |
323 | if (!new_de) | 307 | if (!new_de) |
324 | goto out_dir; | 308 | goto out_dir; |
325 | inode_inc_link_count(old_inode); | 309 | inode_inc_link_count(old_inode); |