History

ext4_link: create . and .. entries regardless of dir index

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

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit 2f394fe1 parent b2577811 file · +10 −12Browse files

Unified · Split

src/ext4.c+10−12
@@ -237,19 +237,17 @@ static int ext4_link(struct ext4_mountpoint *mp, struct ext4_inode_ref *parent, · 236 unmodified lines
237237 ch->dirty = true;
238238 } else
239239 #endif
240− {
241− r = ext4_dir_add_entry(ch, ".", strlen("."), ch);
242− if (r != EOK) {
243− ext4_dir_remove_entry(parent, n, strlen(n));
244− return r;
245− }
240+ r = ext4_dir_add_entry(ch, ".", strlen("."), ch);
241+ if (r != EOK) {
242+ ext4_dir_remove_entry(parent, n, strlen(n));
243+ return r;
244+ }
246245
247− r = ext4_dir_add_entry(ch, "..", strlen(".."), parent);
248− if (r != EOK) {
249− ext4_dir_remove_entry(parent, n, strlen(n));
250− ext4_dir_remove_entry(ch, ".", strlen("."));
251− return r;
252− }
246+ r = ext4_dir_add_entry(ch, "..", strlen(".."), parent);
247+ if (r != EOK) {
248+ ext4_dir_remove_entry(parent, n, strlen(n));
249+ ext4_dir_remove_entry(ch, ".", strlen("."));
250+ return r;
253251 }
254252
255253 /*New empty directory. Two links (. and ..) */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t