Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in fat16.c in function fat16_read #14

Open
JaihsonK opened this issue Jan 1, 2023 · 1 comment
Open

Error in fat16.c in function fat16_read #14

JaihsonK opened this issue Jan 1, 2023 · 1 comment

Comments

@JaihsonK
Copy link

JaihsonK commented Jan 1, 2023

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

@nibblebits
Copy link
Owner

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

@nibblebits nibblebits reopened this Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants