move the defines to the resource header and include that where necessary.
[AROS.git] / compiler / posixc / fstat.c
blob22acac2a075f2090fbbd27b683885e2ee185fe8e
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX.1-2008 function fstat().
6 */
8 #include <errno.h>
10 #include "__stat.h"
11 #include "__fdesc.h"
13 /*****************************************************************************
15 NAME */
17 #include <sys/stat.h>
19 int fstat(
21 /* SYNOPSIS */
22 int fd,
23 struct stat *sb)
25 /* FUNCTION
26 Returns information about a file specified by an open file descriptor.
27 Information is stored in stat structure. Consult stat() documentation
28 for detailed description of that structure.
30 INPUTS
31 filedes - File descriptor of the file
32 sb - Pointer to stat structure that will be filled by the fstat()
33 call.
35 RESULT
36 0 on success and -1 on error. If an error occurred, the global
37 variable errno is set.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 stat()
48 INTERNALS
49 Consult stat() documentation for details.
51 ******************************************************************************/
53 fdesc *desc = __getfdesc(fd);
55 if (!desc)
57 errno = EBADF;
59 return -1;
62 return __stat(desc->fcb->handle, sb, (desc->fcb->privflags & _FCB_ISDIR) ? FALSE : TRUE);