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
237 ch->dirty = true;237 ch->dirty = true;
238 } else238 } else
239#endif239#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 ..) */

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