Open JaihsonK opened 1 year ago
Hi Jaihson, That is a good spot, you are correct. Whilst we ensure the whole buffer you request is loaded via incrementing the offset variable, we fail to reset the position to the new offset.
Thanks for sharing, I will close the issue when a new lecture is made fixing it
Hey Dan! Correct me if i am wrong, but I believe there is an error in fat16_read. We never advance fat_desc->pos, thus in a situation such that we would read from a file multiple times, we would read and re-read the same data in the file. The following program when inserted into the function kernel_main will demonstrate the problem:
int fd = fopen("0:/hello.txt", "r"); for(int i = 0; i < 5; i++) { char buf [11]; fread(buf, 10, 1, fd); print(buf); } while(1);
my solution is to insert into fat16_read at line 716 in the PeachOS master:
fat_desc->pos = offset;
thanks!
Jaihson