PeachOS icon indicating copy to clipboard operation
PeachOS copied to clipboard

Arithmetic error in fat16.c - fat16_get_fat_entry function

Open RyanStan opened this issue 4 years ago • 0 comments

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)

RyanStan avatar Oct 28 '21 01:10 RyanStan