RTEMS 6.3
Loading...
Searching...
No Matches
stat.c
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
9
10/*
11 * COPYRIGHT (c) 1989-2013.
12 * On-Line Applications Research Corporation (OAR).
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifdef HAVE_CONFIG_H
37#include "config.h"
38#endif
39
40/*
41 * lstat() and stat() share the same implementation with a minor
42 * difference on how links are evaluated.
43 */
44
45#ifndef _STAT_NAME
46#define _STAT_NAME stat
47#define _STAT_R_NAME _stat_r
48#define _STAT_FOLLOW_LINKS RTEMS_FS_FOLLOW_LINK
49#endif
50
51#include <sys/stat.h>
52#include <string.h>
53
54#include <rtems/libio_.h>
55
56/*
57 * Prototype to avoid warnings
58 */
59int _STAT_NAME( const char *path, struct stat *buf );
60
66int _STAT_NAME( const char *path, struct stat *buf )
67{
68 int rv = 0;
70 int eval_flags = _STAT_FOLLOW_LINKS;
71 const rtems_filesystem_location_info_t *currentloc =
72 rtems_filesystem_eval_path_start( &ctx, path, eval_flags );
73
74 memset( buf, 0, sizeof( *buf ) );
75
76 rv = (*currentloc->handlers->fstat_h)( currentloc, buf );
77
78 rtems_filesystem_eval_path_cleanup( &ctx );
79
80 return rv;
81}
82
83#if defined(RTEMS_NEWLIB)
84
85#include <reent.h>
86
87/*
88 * Prototype to avoid warnings
89 */
90int _STAT_R_NAME(
91 struct _reent *ptr RTEMS_UNUSED,
92 const char *path,
93 struct stat *buf
94);
95
99int _STAT_R_NAME(
100 struct _reent *ptr RTEMS_UNUSED,
101 const char *path,
102 struct stat *buf
103)
104{
105 return _STAT_NAME( path, buf );
106}
107#endif
struct rtems_filesystem_location_info_tt rtems_filesystem_location_info_t
File system location.
#define RTEMS_UNUSED
Tells the compiler that the variable or function is deliberately unused.
Definition basedefs.h:902
LibIO Internal Interface.
Path evaluation context.
Definition libio.h:105