/*
* Given a directory entry, enter it into the fname rb tree.
*/
-void ext3_htree_store_dirent(struct file *dir_file, __u32 hash,
+int ext3_htree_store_dirent(struct file *dir_file, __u32 hash,
__u32 minor_hash,
struct ext3_dir_entry_2 *dirent)
{
/* Create and allocate the fname structure */
len = sizeof(struct fname) + dirent->name_len + 1;
new_fn = kmalloc(len, GFP_KERNEL);
+ if (!new_fn)
+ return -ENOMEM;
memset(new_fn, 0, len);
new_fn->hash = hash;
new_fn->minor_hash = minor_hash;
(new_fn->minor_hash == fname->minor_hash)) {
new_fn->next = fname->next;
fname->next = new_fn;
- return;
+ return 0;
}
if (new_fn->hash < fname->hash)
rb_link_node(&new_fn->rb_hash, parent, p);
rb_insert_color(&new_fn->rb_hash, &info->root);
+ return 0;
}
/* Add '.' and '..' from the htree header */
if (!start_hash && !start_minor_hash) {
de = (struct ext3_dir_entry_2 *) frames[0].bh->b_data;
- ext3_htree_store_dirent(dir_file, 0, 0, de);
+ if ((err = ext3_htree_store_dirent(dir_file, 0, 0, de)) != 0)
+ goto errout;
de = ext3_next_entry(de);
- ext3_htree_store_dirent(dir_file, 0, 0, de);
+ if ((err = ext3_htree_store_dirent(dir_file, 0, 0, de)) != 0)
+ goto errout;
count += 2;
}
((hinfo.hash == start_hash) &&
(hinfo.minor_hash < start_minor_hash)))
continue;
- ext3_htree_store_dirent(dir_file, hinfo.hash,
- hinfo.minor_hash, de);
+ if ((err = ext3_htree_store_dirent(dir_file,
+ hinfo.hash, hinfo.minor_hash, de)) != 0)
+ goto errout;
count++;
}
brelse (bh);
extern int ext3_check_dir_entry(const char *, struct inode *,
struct ext3_dir_entry_2 *,
struct buffer_head *, unsigned long);
-extern void ext3_htree_store_dirent(struct file *dir_file, __u32 hash,
+extern int ext3_htree_store_dirent(struct file *dir_file, __u32 hash,
__u32 minor_hash,
struct ext3_dir_entry_2 *dirent);
extern void ext3_htree_free_dir_info(struct dir_private_info *p);