source: rtems/c/src/exec/libcsupport/src/stat.c @ a02224e

4.104.114.84.95
Last change on this file since a02224e was a02224e, checked in by Joel Sherrill <joel.sherrill@…>, on 01/04/02 at 18:29:37

2002-01-04 Ralf Corsepius <corsepiu@…>

  • include/rtems/libio_.h: Remove set_errno_and_return_minus_one.
  • libc/cfsetispeed.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/cfsetospeed.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/chdir.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/chmod.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/chown.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/chroot.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/closedir.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/eval.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/fchdir.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/fchmod.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/fdatasync.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/fpathconf.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/fstat.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/fsync.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/ftruncate.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/getdents.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/ioctl.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/link.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/lseek.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/mknod.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/open.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/read.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/readlink.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/rmdir.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/stat.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/symlink.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/tcsetattr.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/telldir.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/ttyname.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/ttyname_r.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/unlink.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/unmount.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/utime.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • libc/write.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[07a3253d]1/*
2 *  stat() - POSIX 1003.1b 5.6.2 - Get File Status
3 *
[933388ae]4 *  Reused from lstat().
5 *
[08311cc3]6 *  COPYRIGHT (c) 1989-1999.
[07a3253d]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
[9c49db4]16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
[933388ae]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
[07a3253d]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
[3ba74c73]43#include <rtems/libio_.h>
[a02224e]44#include <rtems/seterr.h>
[07a3253d]45
[933388ae]46int _STAT_NAME(
[07a3253d]47  const char  *path,
48  struct stat *buf
49)
50{
51  int                              status;
52  rtems_filesystem_location_info_t loc;
53
54  /*
55   *  Check to see if we were passed a valid pointer.
56   */
57
58  if ( !buf )
[a02224e]59    rtems_set_errno_and_return_minus_one( EFAULT );
[07a3253d]60
[933388ae]61  status = rtems_filesystem_evaluate_path( path, 0, &loc, _STAT_FOLLOW_LINKS );
[07a3253d]62  if ( status != 0 )
63    return -1;
64 
[9c3fa30]65  if ( !loc.handlers->fstat_h ){
[dd0f326]66    rtems_filesystem_freenode( &loc );
[a02224e]67    rtems_set_errno_and_return_minus_one( ENOTSUP );
[d71fcab]68  }
[07a3253d]69
70  /*
71   *  Zero out the stat structure so the various support
72   *  versions of stat don't have to.
73   */
74
75  memset( buf, 0, sizeof(struct stat) );
76
[9c3fa30]77  status =  (*loc.handlers->fstat_h)( &loc, buf );
[d71fcab]78
[dd0f326]79  rtems_filesystem_freenode( &loc );
[d71fcab]80 
81  return status;
[07a3253d]82}
83#endif
84
85/*
[933388ae]86 *  _stat_r, _lstat_r
[07a3253d]87 *
[933388ae]88 *  This is the Newlib dependent reentrant version of stat() and lstat().
[07a3253d]89 */
90
91#if defined(RTEMS_NEWLIB)
92
93#include <reent.h>
94
[933388ae]95int _STAT_R_NAME(
[07a3253d]96  struct _reent *ptr,
97  const char    *path,
98  struct stat   *buf
99)
100{
[933388ae]101  return _STAT_NAME( path, buf );
[07a3253d]102}
103#endif
Note: See TracBrowser for help on using the repository browser.