Skip to content

Commit

Permalink
Fix fat file search
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgian committed Jun 30, 2023
1 parent c084655 commit 9de643b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions kernel/src/filesystem/fat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,8 @@ impl FatDriver {
}

//search by filename, returns found root entry
pub fn search_file(&self, name: &[char]) -> Entry {
let mut result = NULL_ENTRY;

for entry in self.entries {
pub fn search_file(&self, name: &[char]) -> &Entry {
for entry in self.entries.iter() {
let mut found = true;
let mut i = 0;

Expand All @@ -263,10 +261,10 @@ impl FatDriver {
}

if found {
result = entry;
return entry;
}
}

result
&NULL_ENTRY
}
}
2 changes: 1 addition & 1 deletion kernel/src/shell/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl Shell {
let entry = FAT.search_file(&self.arg);

if entry.name[0] != 0 {
FAT.read_file_to_buffer(&entry);
FAT.read_file_to_buffer(entry);

for c in FAT.buffer {
if c != 0 {
Expand Down

0 comments on commit 9de643b

Please sign in to comment.