source: rtems/c/src/exec/libcsupport/src/fstat.c @ c7016198

4.104.114.84.95
Last change on this file since c7016198 was 73f6236, checked in by Joel Sherrill <joel.sherrill@…>, on 03/01/99 at 22:40:08

Patch from Eric Norum <eric@…> to eliminate external
IO handlers scheme that was implemented originally just to support
sockets. The file system IO switch is more general and works fine.

  • 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-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <sys/stat.h>
16#include <unistd.h>
17#include <string.h>
18
19#include "libio_.h"
20
21int fstat(
22  int          fd,
23  struct stat *sbuf
24)
25{
26  rtems_libio_t *iop;
27
28  /*
29   *  Check to see if we were passed a valid pointer.
30   */
31
32  if ( !sbuf )
33    set_errno_and_return_minus_one( EFAULT );
34
35  /*
36   *  Now process the stat() request.
37   */
38
39  iop = rtems_libio_iop( fd );
40  rtems_libio_check_fd( fd );
41  rtems_libio_check_is_open(iop);
42
43  if ( !iop->handlers )
44    set_errno_and_return_minus_one( EBADF );
45
46  if ( !iop->handlers->fstat )
47    set_errno_and_return_minus_one( ENOTSUP );
48
49  /*
50   *  Zero out the stat structure so the various support
51   *  versions of stat don't have to.
52   */
53  memset( sbuf, 0, sizeof(struct stat) );
54
55  return (*iop->handlers->fstat)( &iop->pathinfo, sbuf );
56}
57
58/*
59 *  _fstat_r
60 *
61 *  This is the Newlib dependent reentrant version of fstat().
62 */
63
64#if defined(RTEMS_NEWLIB)
65
66#include <reent.h>
67
68int _fstat_r(
69  struct _reent *ptr,
70  int            fd,
71  struct stat   *buf
72)
73{
74  return fstat( fd, buf );
75}
76#endif
Note: See TracBrowser for help on using the repository browser.