Browse Source

Refactor the workflow of ext4_link to prepare for METADATA_CSUM.

pull/11/head
ngkaho1234 9 years ago
parent
commit
2365ef6f64
  1. 30
      lwext4/ext4.c

30
lwext4/ext4.c

@ -198,6 +198,21 @@ static int ext4_link(struct ext4_mountpoint *mp, struct ext4_inode_ref *parent,
if (ext4_inode_is_type(&mp->fs.sb, child->inode,
EXT4_INODE_MODE_DIRECTORY) &&
!rename) {
#if CONFIG_DIR_INDEX_ENABLE
/* Initialize directory index if supported */
if (ext4_sb_has_feature_compatible(
&mp->fs.sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) {
rc = ext4_dir_dx_init(child);
if (rc != EOK)
return rc;
ext4_inode_set_flag(child->inode,
EXT4_INODE_FLAG_INDEX);
child->dirty = true;
} else
#endif
{
rc = ext4_dir_add_entry(child, ".", strlen("."), child);
if (rc != EOK) {
ext4_dir_remove_entry(parent, name, strlen(name));
@ -210,24 +225,11 @@ static int ext4_link(struct ext4_mountpoint *mp, struct ext4_inode_ref *parent,
ext4_dir_remove_entry(child, ".", strlen("."));
return rc;
}
}
/*New empty directory. Two links (. and ..) */
ext4_inode_set_links_count(child->inode, 2);
#if CONFIG_DIR_INDEX_ENABLE
/* Initialize directory index if supported */
if (ext4_sb_has_feature_compatible(
&mp->fs.sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) {
rc = ext4_dir_dx_init(child);
if (rc != EOK)
return rc;
ext4_inode_set_flag(child->inode,
EXT4_INODE_FLAG_INDEX);
child->dirty = true;
}
#endif
ext4_fs_inode_links_count_inc(parent);
child->dirty = true;
parent->dirty = true;

Loading…
Cancel
Save