Skip to content
Snippets Groups Projects
Commit 55376a1f authored by Avi Kivity's avatar Avi Kivity
Browse files

fd: implement read()

parent a533b4bc
No related branches found
No related tags found
No related merge requests found
...@@ -94,6 +94,19 @@ ssize_t write(int fd, const void* buffer, size_t len) ...@@ -94,6 +94,19 @@ ssize_t write(int fd, const void* buffer, size_t len)
return 0; return 0;
} }
ssize_t read(int fd, void *buf, size_t count)
{
auto desc = get_fd(fd);
auto size = desc->file()->size();
if (desc->pos() >= size) {
return 0;
}
count = std::min(count, size - desc->pos());
desc->file()->read(buf, desc->pos(), count);
desc->seek(desc->pos() + count);
return count;
}
namespace { namespace {
int do_stat1(fileref f, struct stat* buf) int do_stat1(fileref f, struct stat* buf)
......
...@@ -372,11 +372,6 @@ ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset) ...@@ -372,11 +372,6 @@ ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
UNIMPLEMENTED("pwritev"); UNIMPLEMENTED("pwritev");
} }
ssize_t read(int fd, void *buf, size_t count)
{
UNIMPLEMENTED("read");
}
int fclose(FILE *fp) int fclose(FILE *fp)
{ {
UNIMPLEMENTED("fclose"); UNIMPLEMENTED("fclose");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment