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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.3 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.rtems.org/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <sys/stat.h>
17#include <unistd.h>
18#include <string.h>
19
20#include <rtems/libio_.h>
21#include <rtems/seterr.h>
22
23int fstat(
24  int          fd,
25  struct stat *sbuf
26)
27{
28  rtems_libio_t *iop;
29
30  /*
31   *  Check to see if we were passed a valid pointer.
32   */
33  if ( !sbuf )
34    rtems_set_errno_and_return_minus_one( EFAULT );
35
36  /*
37   *  Now process the stat() request.
38   */
39  iop = rtems_libio_iop( fd );
40  rtems_libio_check_fd( fd );
41  rtems_libio_check_is_open(iop);
42
43  /*
44   *  Zero out the stat structure so the various support
45   *  versions of stat don't have to.
46   */
47  memset( sbuf, 0, sizeof(struct stat) );
48
49  return (*iop->pathinfo.handlers->fstat_h)( &iop->pathinfo, sbuf );
50}
51
52/*
53 *  _fstat_r
54 *
55 *  This is the Newlib dependent reentrant version of fstat().
56 */
57
58#if defined(RTEMS_NEWLIB) && !defined(HAVE_FSTAT_R)
59
60#include <reent.h>
61
62int _fstat_r(
63  struct _reent *ptr __attribute__((unused)),
64  int            fd,
65  struct stat   *buf
66)
67{
68  return fstat( fd, buf );
69}
70#endif
Note: See TracBrowser for help on using the repository browser.