diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/fat.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/kernel/fat.c b/src/kernel/fat.c index 362539c..befc1d8 100644 --- a/src/kernel/fat.c +++ b/src/kernel/fat.c @@ -174,7 +174,7 @@ static bool try_locate_entry(const uint8_t *fat_name) { } //puts first path component's fat name into fat_name_buffer, -//returns rest of path +//returns rest of path, or zero on error static const char *split_path(const char *path, uint8_t *fat_name_buffer) { uint8_t pi = 0, fi = 0; while (1) { @@ -190,9 +190,9 @@ static const char *split_path(const char *path, uint8_t *fat_name_buffer) { ++pi; } else - PANIC("Bad path in FAT16 driver."); + return 0; else if (((fi == 8) && (path[pi - 1] != EXT_SEP_CHAR)) || (fi == 11)) - PANIC("Bad path in FAT16 driver."); + return 0; else { fat_name_buffer[fi++] = (uint8_t)path[pi++]; } @@ -206,15 +206,13 @@ static bool try_load_from_path(const struct drive *d, const char *path) { cur_fdi = &infos[cur_id]; uint8_t fat_name[11]; - path = split_path(path, fat_name); - if (!try_locate_root_entry(fat_name)) + if (!(path = split_path(path, fat_name)) || + !try_locate_root_entry(fat_name)) return false; - while (*path) { - path = split_path(path, fat_name); - if (!try_locate_entry(fat_name)) + while (*path) + if (!(path = split_path(path, fat_name)) || + !try_locate_entry(fat_name)) return false; - } - return true; } |