From 933388ae2d3f1c2d4939e701ea9cd1290c851886 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 22 Apr 1999 21:13:23 +0000 Subject: Added lstat(). --- c/src/exec/libcsupport/src/lstat.c | 19 +++++++++++++++++++ c/src/exec/libcsupport/src/stat.c | 26 ++++++++++++++++++++------ c/src/lib/libc/Makefile.in | 2 +- c/src/lib/libc/lstat.c | 19 +++++++++++++++++++ c/src/lib/libc/stat.c | 26 ++++++++++++++++++++------ 5 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 c/src/exec/libcsupport/src/lstat.c create mode 100644 c/src/lib/libc/lstat.c (limited to 'c') diff --git a/c/src/exec/libcsupport/src/lstat.c b/c/src/exec/libcsupport/src/lstat.c new file mode 100644 index 0000000000..2c1746ac6e --- /dev/null +++ b/c/src/exec/libcsupport/src/lstat.c @@ -0,0 +1,19 @@ +/* + * lstat() - BSD 4.3 and SVR4 - Get File Status + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#define _STAT_NAME lstat +#define _STAT_R_NAME _lstat_r +#define _STAT_FOLLOW_LINKS FALSE + +#include "stat.c" diff --git a/c/src/exec/libcsupport/src/stat.c b/c/src/exec/libcsupport/src/stat.c index 8ad7e61511..db28d0eedc 100644 --- a/c/src/exec/libcsupport/src/stat.c +++ b/c/src/exec/libcsupport/src/stat.c @@ -1,6 +1,8 @@ /* * stat() - POSIX 1003.1b 5.6.2 - Get File Status * + * Reused from lstat(). + * * COPYRIGHT (c) 1989-1998. * On-Line Applications Research Corporation (OAR). * Copyright assigned to U.S. Government, 1994. @@ -12,6 +14,18 @@ * $Id$ */ +/* + * lstat() and stat() share the same implementation with a minor + * difference on how links are evaluated. + */ + +#ifndef _STAT_NAME +#define _STAT_NAME stat +#define _STAT_R_NAME _stat_r +#define _STAT_FOLLOW_LINKS TRUE +#endif + + #include #if !defined(RTEMS_UNIX) @@ -25,7 +39,7 @@ #include "libio_.h" -int stat( +int _STAT_NAME( const char *path, struct stat *buf ) @@ -40,7 +54,7 @@ int stat( if ( !buf ) set_errno_and_return_minus_one( EFAULT ); - status = rtems_filesystem_evaluate_path( path, 0, &loc, TRUE ); + status = rtems_filesystem_evaluate_path( path, 0, &loc, _STAT_FOLLOW_LINKS ); if ( status != 0 ) return -1; @@ -59,21 +73,21 @@ int stat( #endif /* - * _stat_r + * _stat_r, _lstat_r * - * This is the Newlib dependent reentrant version of stat(). + * This is the Newlib dependent reentrant version of stat() and lstat(). */ #if defined(RTEMS_NEWLIB) #include -int _stat_r( +int _STAT_R_NAME( struct _reent *ptr, const char *path, struct stat *buf ) { - return stat( path, buf ); + return _STAT_NAME( path, buf ); } #endif diff --git a/c/src/lib/libc/Makefile.in b/c/src/lib/libc/Makefile.in index 2bc8599d9e..c30130b7bd 100644 --- a/c/src/lib/libc/Makefile.in +++ b/c/src/lib/libc/Makefile.in @@ -47,7 +47,7 @@ MALLOC_PIECES=\ LIBC_GLUE_PIECES=\ __gettod __times \ - truncate access stat pathconf \ + truncate access stat lstat pathconf \ newlibc no_libc UNIX_LIBC_PIECES=unixlibc hosterr diff --git a/c/src/lib/libc/lstat.c b/c/src/lib/libc/lstat.c new file mode 100644 index 0000000000..2c1746ac6e --- /dev/null +++ b/c/src/lib/libc/lstat.c @@ -0,0 +1,19 @@ +/* + * lstat() - BSD 4.3 and SVR4 - Get File Status + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#define _STAT_NAME lstat +#define _STAT_R_NAME _lstat_r +#define _STAT_FOLLOW_LINKS FALSE + +#include "stat.c" diff --git a/c/src/lib/libc/stat.c b/c/src/lib/libc/stat.c index 8ad7e61511..db28d0eedc 100644 --- a/c/src/lib/libc/stat.c +++ b/c/src/lib/libc/stat.c @@ -1,6 +1,8 @@ /* * stat() - POSIX 1003.1b 5.6.2 - Get File Status * + * Reused from lstat(). + * * COPYRIGHT (c) 1989-1998. * On-Line Applications Research Corporation (OAR). * Copyright assigned to U.S. Government, 1994. @@ -12,6 +14,18 @@ * $Id$ */ +/* + * lstat() and stat() share the same implementation with a minor + * difference on how links are evaluated. + */ + +#ifndef _STAT_NAME +#define _STAT_NAME stat +#define _STAT_R_NAME _stat_r +#define _STAT_FOLLOW_LINKS TRUE +#endif + + #include #if !defined(RTEMS_UNIX) @@ -25,7 +39,7 @@ #include "libio_.h" -int stat( +int _STAT_NAME( const char *path, struct stat *buf ) @@ -40,7 +54,7 @@ int stat( if ( !buf ) set_errno_and_return_minus_one( EFAULT ); - status = rtems_filesystem_evaluate_path( path, 0, &loc, TRUE ); + status = rtems_filesystem_evaluate_path( path, 0, &loc, _STAT_FOLLOW_LINKS ); if ( status != 0 ) return -1; @@ -59,21 +73,21 @@ int stat( #endif /* - * _stat_r + * _stat_r, _lstat_r * - * This is the Newlib dependent reentrant version of stat(). + * This is the Newlib dependent reentrant version of stat() and lstat(). */ #if defined(RTEMS_NEWLIB) #include -int _stat_r( +int _STAT_R_NAME( struct _reent *ptr, const char *path, struct stat *buf ) { - return stat( path, buf ); + return _STAT_NAME( path, buf ); } #endif -- cgit v1.2.3