Not doing so would result in the following operation creating the last directory in the chain without a correct checksum (would require running fsck.ext4 on Linux): mkdir -p /n/ext4/1/2/3
Unified · Split
| @@ -237,19 +237,17 @@ static int ext4_link(struct ext4_mountpoint *mp, struct ext4_inode_ref *parent, · 236 unmodified lines | |||
| 237 | ch->dirty = true; | 237 | ch->dirty = true; |
| 238 | } else | 238 | } else |
| 239 | #endif | 239 | #endif |
| 240 | { | 240 | r = ext4_dir_add_entry(ch, ".", strlen("."), ch); |
| 241 | r = ext4_dir_add_entry(ch, ".", strlen("."), ch); | 241 | if (r != EOK) { |
| 242 | if (r != EOK) { | 242 | ext4_dir_remove_entry(parent, n, strlen(n)); |
| 243 | ext4_dir_remove_entry(parent, n, strlen(n)); | 243 | return r; |
| 244 | return r; | 244 | } |
| 245 | } | ||
| 246 | 245 | ||
| 247 | r = ext4_dir_add_entry(ch, "..", strlen(".."), parent); | 246 | r = ext4_dir_add_entry(ch, "..", strlen(".."), parent); |
| 248 | if (r != EOK) { | 247 | if (r != EOK) { |
| 249 | ext4_dir_remove_entry(parent, n, strlen(n)); | 248 | ext4_dir_remove_entry(parent, n, strlen(n)); |
| 250 | ext4_dir_remove_entry(ch, ".", strlen(".")); | 249 | ext4_dir_remove_entry(ch, ".", strlen(".")); |
| 251 | return r; | 250 | return r; |
| 252 | } | ||
| 253 | } | 251 | } |
| 254 | 252 | ||
| 255 | /*New empty directory. Two links (. and ..) */ | 253 | /*New empty directory. Two links (. and ..) */ |