source: rtems/cpukit/libcsupport/src/stat.c @ 933388ae

4.104.114.84.95
Last change on this file since 933388ae was 933388ae, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/99 at 21:13:23

Added lstat().

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