summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/fileno.c
blob: bdf9332328daf8f64a2cfc8089ae03aeb51a231c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <errno.h>
#include <stdio.h>

// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fileno.html
// The fileno() function shall return the integer file descriptor associated
// with the stream pointed to by stream.
int fileno(FILE *stream) {
  if (-1 == stream->fd) {
    errno = EBADF;
    return -1;
  }
  return stream->fd;
}