aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/dir.c14
-rw-r--r--fs/ext2/ext2.h4
-rw-r--r--fs/ext2/namei.c17
3 files changed, 15 insertions, 20 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 11a49ce84392..9a0fc400f91c 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -354,11 +354,11 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
354 * (as a parameter - res_dir). Page is returned mapped and unlocked. 354 * (as a parameter - res_dir). Page is returned mapped and unlocked.
355 * Entry is guaranteed to be valid. 355 * Entry is guaranteed to be valid.
356 */ 356 */
357struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir, 357struct ext2_dir_entry_2 *ext2_find_entry (struct inode * dir,
358 struct dentry *dentry, struct page ** res_page) 358 struct qstr *child, struct page ** res_page)
359{ 359{
360 const char *name = dentry->d_name.name; 360 const char *name = child->name;
361 int namelen = dentry->d_name.len; 361 int namelen = child->len;
362 unsigned reclen = EXT2_DIR_REC_LEN(namelen); 362 unsigned reclen = EXT2_DIR_REC_LEN(namelen);
363 unsigned long start, n; 363 unsigned long start, n;
364 unsigned long npages = dir_pages(dir); 364 unsigned long npages = dir_pages(dir);
@@ -431,13 +431,13 @@ struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
431 return de; 431 return de;
432} 432}
433 433
434ino_t ext2_inode_by_name(struct inode * dir, struct dentry *dentry) 434ino_t ext2_inode_by_name(struct inode *dir, struct qstr *child)
435{ 435{
436 ino_t res = 0; 436 ino_t res = 0;
437 struct ext2_dir_entry_2 * de; 437 struct ext2_dir_entry_2 *de;
438 struct page *page; 438 struct page *page;
439 439
440 de = ext2_find_entry (dir, dentry, &page); 440 de = ext2_find_entry (dir, child, &page);
441 if (de) { 441 if (de) {
442 res = le32_to_cpu(de->inode); 442 res = le32_to_cpu(de->inode);
443 ext2_put_page(page); 443 ext2_put_page(page);
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index bae998c1e44e..3203042b36ef 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -105,9 +105,9 @@ extern void ext2_rsv_window_add(struct super_block *sb, struct ext2_reserve_wind
105 105
106/* dir.c */ 106/* dir.c */
107extern int ext2_add_link (struct dentry *, struct inode *); 107extern int ext2_add_link (struct dentry *, struct inode *);
108extern ino_t ext2_inode_by_name(struct inode *, struct dentry *); 108extern ino_t ext2_inode_by_name(struct inode *, struct qstr *);
109extern int ext2_make_empty(struct inode *, struct inode *); 109extern int ext2_make_empty(struct inode *, struct inode *);
110extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct dentry *, struct page **); 110extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct qstr *, struct page **);
111extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *); 111extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
112extern int ext2_empty_dir (struct inode *); 112extern int ext2_empty_dir (struct inode *);
113extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **); 113extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index a1b328ab1e55..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,13 +72,8 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
72 72
73struct dentry *ext2_get_parent(struct dentry *child) 73struct dentry *ext2_get_parent(struct dentry *child)
74{ 74{
75 unsigned long ino; 75 struct qstr dotdot = {.name = "..", .len = 2};
76 struct dentry dotdot; 76 unsigned long ino = ext2_inode_by_name(child->d_inode, &dotdot);
77
78 dotdot.d_name.name = "..";
79 dotdot.d_name.len = 2;
80
81 ino = ext2_inode_by_name(child->d_inode, &dotdot);
82 if (!ino) 77 if (!ino)
83 return ERR_PTR(-ENOENT); 78 return ERR_PTR(-ENOENT);
84 return d_obtain_alias(ext2_iget(child->d_inode->i_sb, ino)); 79 return d_obtain_alias(ext2_iget(child->d_inode->i_sb, ino));
@@ -246,7 +241,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
246 struct page * page; 241 struct page * page;
247 int err = -ENOENT; 242 int err = -ENOENT;
248 243
249 de = ext2_find_entry (dir, dentry, &page); 244 de = ext2_find_entry (dir, &dentry->d_name, &page);
250 if (!de) 245 if (!de)
251 goto out; 246 goto out;
252 247
@@ -288,7 +283,7 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
288 struct ext2_dir_entry_2 * old_de; 283 struct ext2_dir_entry_2 * old_de;
289 int err = -ENOENT; 284 int err = -ENOENT;
290 285
291 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);
292 if (!old_de) 287 if (!old_de)
293 goto out; 288 goto out;
294 289
@@ -308,7 +303,7 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
308 goto out_dir; 303 goto out_dir;
309 304
310 err = -ENOENT; 305 err = -ENOENT;
311 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);
312 if (!new_de) 307 if (!new_de)
313 goto out_dir; 308 goto out_dir;
314 inode_inc_link_count(old_inode); 309 inode_inc_link_count(old_inode);