Return EOF once after the buffer is consumed#112
Merged
Conversation
LCOV of commit
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the Linux nat20 character device read semantics to return a single EOF (0) once after the response buffer has been fully consumed, then revert to -EAGAIN until a new request is written.
Changes:
- Add per-file-descriptor
eofstate to track “EOF already returned once” behavior. - Clear
eofon write, and seteofwhen the response buffer becomes fully consumed. - Update read path to return
0once after consumption before returning-EAGAINon subsequent reads.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
226
to
229
| /* Update offset */ | ||
| *f_pos += bytes_to_read; | ||
|
|
||
| /* Response fully consumed — free it so subsequent reads | ||
| * return -EAGAIN until the next write/dispatch cycle. */ | ||
| if (*f_pos >= file_priv->response.size) { | ||
| kfree(file_priv->response.data); | ||
| file_priv->response.data = NULL; | ||
| file_priv->response.size = 0; | ||
| } | ||
|
|
||
| ret = bytes_to_read; |
Contributor
Author
There was a problem hiding this comment.
So would a user space process, that doesn't or partially reads the response. Closing the file descriptor will also free the buffer.
mjain02
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The nat20 device now returns 0 on the first read after the entire response has been consumed to indicate EOF. Subsequent reads still return EAGAIN to indicate that a new request need to be issued before a new request can be read. The EOF state is cleared by a subsequent write even if the response was not or only partially read.