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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [stat.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  stat() - POSIX 1003.1b 5.6.2 - Get File Status
3
 *
4
 *  Reused from lstat().
5
 *
6
 *  COPYRIGHT (c) 1989-1999.
7
 *  On-Line Applications Research Corporation (OAR).
8
 *
9
 *  The license and distribution terms for this file may be
10
 *  found in the file LICENSE in this distribution or at
11
 *  http://www.OARcorp.com/rtems/license.html.
12
 *
13
 *  $Id: stat.c,v 1.2 2001-09-27 12:01:15 chris Exp $
14
 */
15
 
16
/*
17
 *  lstat() and stat() share the same implementation with a minor
18
 *  difference on how links are evaluated.
19
 */
20
 
21
#ifndef _STAT_NAME
22
#define _STAT_NAME         stat
23
#define _STAT_R_NAME       _stat_r
24
#define _STAT_FOLLOW_LINKS TRUE
25
#endif
26
 
27
 
28
#include <rtems.h>
29
 
30
#if !defined(RTEMS_UNIX)
31
 
32
#include <rtems/libio.h>
33
#include <sys/types.h>
34
#include <sys/stat.h>
35
#include <unistd.h>
36
#include <fcntl.h>
37
#include <errno.h>
38
 
39
#include "libio_.h"
40
 
41
int _STAT_NAME(
42
  const char  *path,
43
  struct stat *buf
44
)
45
{
46
  int                              status;
47
  rtems_filesystem_location_info_t loc;
48
 
49
  /*
50
   *  Check to see if we were passed a valid pointer.
51
   */
52
 
53
  if ( !buf )
54
    set_errno_and_return_minus_one( EFAULT );
55
 
56
  status = rtems_filesystem_evaluate_path( path, 0, &loc, _STAT_FOLLOW_LINKS );
57
  if ( status != 0 )
58
    return -1;
59
 
60
  if ( !loc.handlers->fstat ){
61
    rtems_filesystem_freenode( &loc );
62
    set_errno_and_return_minus_one( ENOTSUP );
63
  }
64
 
65
  /*
66
   *  Zero out the stat structure so the various support
67
   *  versions of stat don't have to.
68
   */
69
 
70
  memset( buf, 0, sizeof(struct stat) );
71
 
72
  status =  (*loc.handlers->fstat)( &loc, buf );
73
 
74
  rtems_filesystem_freenode( &loc );
75
 
76
  return status;
77
}
78
#endif
79
 
80
/*
81
 *  _stat_r, _lstat_r
82
 *
83
 *  This is the Newlib dependent reentrant version of stat() and lstat().
84
 */
85
 
86
#if defined(RTEMS_NEWLIB)
87
 
88
#include <reent.h>
89
 
90
int _STAT_R_NAME(
91
  struct _reent *ptr,
92
  const char    *path,
93
  struct stat   *buf
94
)
95
{
96
  return _STAT_NAME( path, buf );
97
}
98
#endif

powered by: WebSVN 2.1.0

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