libc: Implement fileno()

This commit is contained in:
apio 2022-10-15 10:28:52 +02:00
parent d0d6557e99
commit c77e752a82
2 changed files with 8 additions and 0 deletions

View File

@ -40,6 +40,9 @@ extern "C"
/* Returns a new file associated with the file descriptor fd. */
FILE* fdopen(int fd, const char* mode);
/* Returns the file descriptor associated with the file stream. */
int fileno(FILE* stream);
/* Writes formatted output according to the string format to the file stream. */
int fprintf(FILE* stream, const char* format, ...);

View File

@ -53,6 +53,11 @@ extern "C"
return stream;
}
int fileno(FILE* stream)
{
return stream->f_fd;
}
size_t fread(void* buf, size_t size, size_t nmemb, FILE* stream)
{
ssize_t status = read(stream->f_fd, buf, size * nmemb);