diff options
Diffstat (limited to 'usr/klibc/stdio/fileno.c')
-rw-r--r-- | usr/klibc/stdio/fileno.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr/klibc/stdio/fileno.c b/usr/klibc/stdio/fileno.c index b5a101618684e..d6e4e9b527ab9 100644 --- a/usr/klibc/stdio/fileno.c +++ b/usr/klibc/stdio/fileno.c @@ -1,7 +1,12 @@ -#define __NO_STDIO_INLINES #include "stdioint.h" -int fileno(FILE *__f) +int fileno(FILE *file) { - return __f->_IO_fileno; + struct _IO_file_pvt *f = stdio_pvt(file); + + if (f->isfile) + return (int)(intptr_t)f->cookie; + + errno = EBADF; + return -1; } |