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

Fix syscall_read to handle partial reads and errors #257

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

visitorckw
Copy link
Collaborator

In the original syscall_read function, an assertion error could occur when the number of bytes read didn't match the number of bytes requested. This was because the function didn't handle partial reads and errors properly.

The modified syscall_read function now handles partial reads by breaking the loop when a read operation doesn't fill the entire buffer. Additionally, it checks for errors during the read operation and sets the return value to -1 if an error occurs.

Close: #214

In the original syscall_read function, an assertion error could occur
when the number of bytes read didn't match the number of bytes
requested. This was because the function didn't handle partial reads
and errors properly.

The modified syscall_read function now handles partial reads by
breaking the loop when a read operation doesn't fill the entire buffer.
Additionally, it checks for errors during the read operation and sets
the return value to -1 if an error occurs.
@jserv jserv requested a review from qwe661234 November 5, 2023 18:01
Copy link
Collaborator

@qwe661234 qwe661234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I truly observed that the count is 1024, but the total_read is 444 when running quake, and this patch sloved it.

@jserv jserv merged commit 6685e93 into sysprog21:master Nov 6, 2023
15 checks passed
@jserv
Copy link
Contributor

jserv commented Nov 6, 2023

Thank @visitorckw for contributing!

@visitorckw visitorckw deleted the fix-syscall-read-issue branch November 6, 2023 17:05
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

Successfully merging this pull request may close these issues.

Assertion failed: (total_read == rv_get_reg(rv, rv_reg_a2)), function syscall_read
3 participants