OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [fstat.c] - Blame information for rev 1026

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  fstat.c,v 1.8 2002/01/04 18:29:36 joel Exp
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
#include <rtems/seterr.h>
24
 
25
int fstat(
26
  int          fd,
27
  struct stat *sbuf
28
)
29
{
30
  rtems_libio_t *iop;
31
 
32
  /*
33
   *  Check to see if we were passed a valid pointer.
34
   */
35
 
36
  if ( !sbuf )
37
    rtems_set_errno_and_return_minus_one( EFAULT );
38
 
39
  /*
40
   *  Now process the stat() request.
41
   */
42
 
43
  iop = rtems_libio_iop( fd );
44
  rtems_libio_check_fd( fd );
45
  rtems_libio_check_is_open(iop);
46
 
47
  if ( !iop->handlers )
48
    rtems_set_errno_and_return_minus_one( EBADF );
49
 
50
  if ( !iop->handlers->fstat_h )
51
    rtems_set_errno_and_return_minus_one( ENOTSUP );
52
 
53
  /*
54
   *  Zero out the stat structure so the various support
55
   *  versions of stat don't have to.
56
   */
57
  memset( sbuf, 0, sizeof(struct stat) );
58
 
59
  return (*iop->handlers->fstat_h)( &iop->pathinfo, sbuf );
60
}
61
 
62
/*
63
 *  _fstat_r
64
 *
65
 *  This is the Newlib dependent reentrant version of fstat().
66
 */
67
 
68
#if defined(RTEMS_NEWLIB)
69
 
70
#include <reent.h>
71
 
72
int _fstat_r(
73
  struct _reent *ptr,
74
  int            fd,
75
  struct stat   *buf
76
)
77
{
78
  return fstat( fd, buf );
79
}
80
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.