summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/_rename_r.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/cpukit/libcsupport/src/_rename_r.c b/cpukit/libcsupport/src/_rename_r.c
index b0a636f468..1395099b5e 100644
--- a/cpukit/libcsupport/src/_rename_r.c
+++ b/cpukit/libcsupport/src/_rename_r.c
@@ -25,16 +25,22 @@
#include <rtems/libio_.h>
#include <rtems/seterr.h>
+#include <sys/stat.h>
+
int _rename_r(
struct _reent *ptr,
const char *old,
const char *new
)
{
+ struct stat sb;
int s;
+ s = stat( old, &sb);
+ if ( s < 0 )
+ return s;
s = link( old, new );
- if ( !s )
+ if ( s < 0 )
return s;
- return unlink( old );
+ return S_ISDIR(sb.st_mode) ? rmdir( old ) : unlink( old );
}