gint-slim/src/fs/read.c
Lephe 6903bd58d5
fs: cast BFile support into generic file descriptors
This paves the way for standard streams, USB streams, and some more.
2021-12-13 18:38:47 +01:00

19 lines
337 B
C

#include <unistd.h>
#include <gint/fs.h>
#include <errno.h>
ssize_t read(int fd, void *buf, size_t size)
{
fs_descriptor_t const *d = fs_get_descriptor(fd);
if(!d) {
errno = EBADF;
return (ssize_t)-1;
}
if(d->type->read)
return d->type->read(d->data, buf, size);
/* No read function: we can't read anything */
return 0;
}