source: rtems/c/src/exec/libcsupport/src/stat.c @ 07a3253d

4.104.114.84.95
Last change on this file since 07a3253d was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 23, 1998 at 7:07:58 PM

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  stat() - 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 <rtems.h>
16
17#if !defined(RTEMS_UNIX)
18
19#include <rtems/libio.h>
20#include <sys/types.h>
21#include <sys/stat.h>
22#include <unistd.h>
23#include <fcntl.h>
24#include <errno.h>
25
26#include "libio_.h"
27
28int stat(
29  const char  *path,
30  struct stat *buf
31)
32{
33  int                              status;
34  rtems_filesystem_location_info_t loc;
35
36  /*
37   *  Check to see if we were passed a valid pointer.
38   */
39
40  if ( !buf )
41    set_errno_and_return_minus_one( EFAULT );
42
43  status = rtems_filesystem_evaluate_path( path, 0, &loc, TRUE );
44  if ( status != 0 )
45    return -1;
46 
47  if ( !loc.handlers->fstat )
48    set_errno_and_return_minus_one( ENOTSUP );
49
50  /*
51   *  Zero out the stat structure so the various support
52   *  versions of stat don't have to.
53   */
54
55  memset( buf, 0, sizeof(struct stat) );
56
57  return (*loc.handlers->fstat)( &loc, buf );
58}
59#endif
60
61/*
62 *  _stat_r
63 *
64 *  This is the Newlib dependent reentrant version of stat().
65 */
66
67#if defined(RTEMS_NEWLIB)
68
69#include <reent.h>
70
71int _stat_r(
72  struct _reent *ptr,
73  const char    *path,
74  struct stat   *buf
75)
76{
77  return stat( path, buf );
78}
79#endif
Note: See TracBrowser for help on using the repository browser.