Skip to content
Snippets Groups Projects
Commit e270ce11 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub
Browse files

Merge pull request #30 from ids1024/free

Avoid corrupting free node
parents 1e9cec60 0996d844
No related branches found
No related tags found
No related merge requests found
...@@ -185,7 +185,12 @@ impl FileSystem { ...@@ -185,7 +185,12 @@ impl FileSystem {
Ok(()) Ok(())
} else { } else {
if parent.1.next == 0 { if parent.1.next == 0 {
parent.1.next = self.allocate(1)?; let next = self.allocate(1)?;
// Could be mutated by self.allocate if free block
if parent.0 == self.header.1.free {
self.read_at(parent.0, &mut parent.1)?;
}
parent.1.next = next;
self.write_at(parent.0, &parent.1)?; self.write_at(parent.0, &parent.1)?;
self.write_at(parent.1.next, &Node::default())?; self.write_at(parent.1.next, &Node::default())?;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment