source: rtems/c/src/lib/libc/stat.c @ d7aecdc

4.104.114.84.95
Last change on this file since d7aecdc was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/01 at 18:26:44

2001-01-08 Ralf Corsepius <corsepiu@…>

  • configure.in: Add libc/config.h
  • libc/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • libc/.cvsignore: Add config.h and stamp-h
  • libc/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
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$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20/*
21 *  lstat() and stat() share the same implementation with a minor
22 *  difference on how links are evaluated.
23 */
24
25#ifndef _STAT_NAME
26#define _STAT_NAME         stat
27#define _STAT_R_NAME       _stat_r
28#define _STAT_FOLLOW_LINKS TRUE
29#endif
30
31
32#include <rtems.h>
33
34#if !defined(RTEMS_UNIX)
35
36#include <rtems/libio.h>
37#include <sys/types.h>
38#include <sys/stat.h>
39#include <unistd.h>
40#include <fcntl.h>
41#include <errno.h>
42
43#include <rtems/libio_.h>
44
45int _STAT_NAME(
46  const char  *path,
47  struct stat *buf
48)
49{
50  int                              status;
51  rtems_filesystem_location_info_t loc;
52
53  /*
54   *  Check to see if we were passed a valid pointer.
55   */
56
57  if ( !buf )
58    set_errno_and_return_minus_one( EFAULT );
59
60  status = rtems_filesystem_evaluate_path( path, 0, &loc, _STAT_FOLLOW_LINKS );
61  if ( status != 0 )
62    return -1;
63 
64  if ( !loc.handlers->fstat_h ){
65    rtems_filesystem_freenode( &loc );
66    set_errno_and_return_minus_one( ENOTSUP );
67  }
68
69  /*
70   *  Zero out the stat structure so the various support
71   *  versions of stat don't have to.
72   */
73
74  memset( buf, 0, sizeof(struct stat) );
75
76  status =  (*loc.handlers->fstat_h)( &loc, buf );
77
78  rtems_filesystem_freenode( &loc );
79 
80  return status;
81}
82#endif
83
84/*
85 *  _stat_r, _lstat_r
86 *
87 *  This is the Newlib dependent reentrant version of stat() and lstat().
88 */
89
90#if defined(RTEMS_NEWLIB)
91
92#include <reent.h>
93
94int _STAT_R_NAME(
95  struct _reent *ptr,
96  const char    *path,
97  struct stat   *buf
98)
99{
100  return _STAT_NAME( path, buf );
101}
102#endif
Note: See TracBrowser for help on using the repository browser.