Skip to content

Commit

Permalink
fs: do not continue on EINTR in file_read_to_end and file_write_all
Browse files Browse the repository at this point in the history
In case of EINTR, we should return and handle the interrupt. Otherwise,
file_read and file_write will be immediately interrupted again because
of the same pending signal.
  • Loading branch information
mosmeh committed Nov 9, 2024
1 parent 10dbc9d commit 4ca986e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions kernel/fs/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ ssize_t file_read_to_end(struct file* file, void* buffer, size_t count) {
while (cursor < count) {
ssize_t nread =
file_read(file, (unsigned char*)buffer + cursor, count - cursor);
if (nread == -EINTR)
continue;
if (IS_ERR(nread))
return nread;
if (nread == 0)
Expand Down Expand Up @@ -234,10 +232,8 @@ ssize_t file_pwrite(struct file* file, const void* buffer, size_t count,
ssize_t file_write_all(struct file* file, const void* buffer, size_t count) {
size_t cursor = 0;
while (cursor < count) {
ssize_t nwritten =
file_write(file, (unsigned char*)buffer + cursor, count - cursor);
if (nwritten == -EINTR)
continue;
ssize_t nwritten = file_write(
file, (const unsigned char*)buffer + cursor, count - cursor);
if (IS_ERR(nwritten))
return nwritten;
if (nwritten == 0)
Expand Down

0 comments on commit 4ca986e

Please sign in to comment.