nibblebits / PeachOS

Simple kernel designed for a online course
GNU General Public License v2.0
133 stars 55 forks source link

Arithmetic error in fat16.c - fat16_get_fat_entry function #2

Closed RyanStan closed 1 year ago

RyanStan commented 2 years ago

Inside the method static int fat16_get_fat_entry(struct disk *disk, int cluster) in fat16.c, there's the following line: res = diskstreamer_seek(stream, fat_table_position * (cluster * PEACHOS_FAT16_FAT_ENTRY_SIZE));

However, and Daniel confirmed this as well, it should be res = diskstreamer_seek(stream, fat_table_position + (cluster * PEACHOS_FAT16_FAT_ENTRY_SIZE));

The FAT table is just a contiguous area of memory, with each entry two bytes in size. So the nth entry in the table should be n entry_size bytes from the beginning of the table. I.e. ```fat_table_position + (cluster PEACHOS_FAT16_FAT_ENTRY_SIZE)```