libc: io: implement file io buffering and internal locking for concurrency

This commit is contained in:
2026-04-01 18:51:13 +01:00
parent f2e650d368
commit 548387c43a
23 changed files with 948 additions and 73 deletions
+6 -1
View File
@@ -7,7 +7,9 @@ char *fgets(
int count,
struct __opaque_file *restrict stream)
{
__libc_file_lock(stream);
if (stream->f_flags & (FILE_EOF | FILE_ERR)) {
__libc_file_unlock(stream);
return NULL;
}
@@ -28,13 +30,16 @@ char *fgets(
}
}
if (ferr(stream)) {
if (ferror(stream)) {
__libc_file_unlock(stream);
return NULL;
}
if (feof(stream) && i == 0) {
__libc_file_unlock(stream);
return NULL;
}
__libc_file_unlock(stream);
return str;
}