source: rtems/cpukit/libcsupport/src/fstat.c @ d6c20ff3

4.104.114.84.95
Last change on this file since d6c20ff3 was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/01 at 18:26:44

2001-01-08 Ralf Corsepius <corsepiu@…>

  • configure.in: Add libc/config.h
  • libc/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • libc/.cvsignore: Add config.h and stamp-h
  • libc/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  fstat() - POSIX 1003.1b 5.6.2 - Get File Status
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <sys/stat.h>
19#include <unistd.h>
20#include <string.h>
21
22#include <rtems/libio_.h>
23
24int fstat(
25  int          fd,
26  struct stat *sbuf
27)
28{
29  rtems_libio_t *iop;
30
31  /*
32   *  Check to see if we were passed a valid pointer.
33   */
34
35  if ( !sbuf )
36    set_errno_and_return_minus_one( EFAULT );
37
38  /*
39   *  Now process the stat() request.
40   */
41
42  iop = rtems_libio_iop( fd );
43  rtems_libio_check_fd( fd );
44  rtems_libio_check_is_open(iop);
45
46  if ( !iop->handlers )
47    set_errno_and_return_minus_one( EBADF );
48
49  if ( !iop->handlers->fstat_h )
50    set_errno_and_return_minus_one( ENOTSUP );
51
52  /*
53   *  Zero out the stat structure so the various support
54   *  versions of stat don't have to.
55   */
56  memset( sbuf, 0, sizeof(struct stat) );
57
58  return (*iop->handlers->fstat_h)( &iop->pathinfo, sbuf );
59}
60
61/*
62 *  _fstat_r
63 *
64 *  This is the Newlib dependent reentrant version of fstat().
65 */
66
67#if defined(RTEMS_NEWLIB)
68
69#include <reent.h>
70
71int _fstat_r(
72  struct _reent *ptr,
73  int            fd,
74  struct stat   *buf
75)
76{
77  return fstat( fd, buf );
78}
79#endif
Note: See TracBrowser for help on using the repository browser.