summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport/src/stat.c')
-rw-r--r--cpukit/libcsupport/src/stat.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/cpukit/libcsupport/src/stat.c b/cpukit/libcsupport/src/stat.c
index 9f06deaa52..af56fd87be 100644
--- a/cpukit/libcsupport/src/stat.c
+++ b/cpukit/libcsupport/src/stat.c
@@ -14,7 +14,7 @@
*/
#if HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
/*
@@ -25,55 +25,29 @@
#ifndef _STAT_NAME
#define _STAT_NAME stat
#define _STAT_R_NAME _stat_r
-#define _STAT_FOLLOW_LINKS true
+#define _STAT_FOLLOW_LINKS RTEMS_LIBIO_FOLLOW_LINK
#endif
-
-#include <rtems.h>
-
-#include <rtems/libio.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
#include <string.h>
#include <rtems/libio_.h>
-#include <rtems/seterr.h>
-int _STAT_NAME(
- const char *path,
- struct stat *buf
-)
+int _STAT_NAME( const char *path, struct stat *buf )
{
- int status;
- rtems_filesystem_location_info_t loc;
-
- /*
- * Check to see if we were passed a valid pointer.
- */
-
- if ( !buf )
- rtems_set_errno_and_return_minus_one( EFAULT );
-
- status = rtems_filesystem_evaluate_path( path, strlen( path ),
- 0, &loc, _STAT_FOLLOW_LINKS );
- if ( status != 0 )
- return -1;
-
- /*
- * Zero out the stat structure so the various support
- * versions of stat don't have to.
- */
+ int rv = 0;
+ rtems_filesystem_eval_path_context_t ctx;
+ int eval_flags = _STAT_FOLLOW_LINKS;
+ const rtems_filesystem_location_info_t *currentloc =
+ rtems_filesystem_eval_path_start( &ctx, path, eval_flags );
- memset( buf, 0, sizeof(struct stat) );
+ memset( buf, 0, sizeof( *buf ) );
- status = (*loc.handlers->fstat_h)( &loc, buf );
+ rv = (*currentloc->handlers->fstat_h)( currentloc, buf );
- rtems_filesystem_freenode( &loc );
+ rtems_filesystem_eval_path_cleanup( &ctx );
- return status;
+ return rv;
}
/*