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

4.104.114.84.95
Last change on this file since bd914b46 was 3ba74c73, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/00 at 21:08:14

2000-11-01 Joel Sherrill <joel@…>

  • include/Makefile.am, include/rtems/libio_.h, libc/Makefile.am, libc/assoc.c, libc/assocnamebad.c, libc/base_fs.c, libc/cfsetispeed.c, libc/cfsetospeed.c, libc/chdir.c, libc/chmod.c, libc/chown.c, libc/close.c, libc/closedir.c, libc/dup2.c, libc/error.c, libc/eval.c, libc/fchdir.c, libc/fchmod.c, libc/fcntl.c, libc/fdatasync.c, libc/fpathconf.c, libc/fstat.c, libc/fsync.c, libc/ftruncate.c, libc/getdents.c, libc/ioctl.c, libc/libio.c, libc/libio_sockets.c, libc/link.c, libc/lseek.c, libc/malloc.c, libc/mallocfreespace.c, libc/mknod.c, libc/mount.c, libc/newlibc.c, libc/no_libc.c, libc/open.c, libc/read.c, libc/readlink.c, libc/rmdir.c, libc/stat.c, libc/symlink.c, libc/tcsetattr.c, libc/telldir.c, libc/ttyname.c, libc/ttyname_r.c, libc/umask.c, libc/unlink.c, libc/unmount.c, libc/utime.c, libc/write.c: assoc.h, error.h, libio_.h, libio.h, and libcsupport.h moved from libc to lib/include/rtems and now must be referenced as <rtems/XXX.h>.
  • include/rtems/Makefile.am, include/rtems/.cvsignore: New file.
  • include/rtems/assoc.h, include/rtems/error.h, include/rtems/libcsupport.h, include/rtems/libio.h, include/rtems/libio_.h: New/moved files.
  • Property mode set to 100644
File size: 1.8 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/*
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 <rtems/libio_.h>
40
41int _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_h ){
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_h)( &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
90int _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
Note: See TracBrowser for help on using the repository browser.