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(aostdio): return fread bytes read from weavedrive_read #1086

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dev-cli/container/src/aolibc/aostdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ FILE* fopen(const char* filename, const char* mode) {
}

size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream) {
AO_LOG( "AO: fread called\n");
int fd = fileno(stream);
weavedrive_read(fd, ptr, size * nmemb);
return nmemb;
int bytes_read = weavedrive_read(fd, ptr, size * nmemb);
AO_LOG( "AO: weavedrive_read returned %d bytes\n", bytes_read);
if ((bytes_read % size) != 0) {
// TODO: Handle this case?
AO_LOG( "AO: fread: bytes_read is not a multiple of size\n");
}
return bytes_read / size;
}

int fclose(FILE* stream) {
Expand Down
Loading