define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / compiler / clib / fstat.c
blobca72ff4f06ae705c04a9f45d12c958de3ba5911e
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function fstat().
6 */
8 #include <errno.h>
10 #include "__stat.h"
11 #include "__open.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->fh, sb);