[rtems commit] Fix untar mkdir when the directory exists.
Chris Johns
chrisj at rtems.org
Thu Nov 17 22:10:25 UTC 2016
Module: rtems
Branch: master
Commit: 3a30c6fa5c20246bf08c2cf90f498e2f76c9fab2
Changeset: http://git.rtems.org/rtems/commit/?id=3a30c6fa5c20246bf08c2cf90f498e2f76c9fab2
Author: Chris Johns <chrisj at rtems.org>
Date: Fri Nov 18 09:10:20 2016 +1100
Fix untar mkdir when the directory exists.
---
cpukit/libmisc/untar/untar.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c
index ecf1877..13d8c36 100644
--- a/cpukit/libmisc/untar/untar.c
+++ b/cpukit/libmisc/untar/untar.c
@@ -189,7 +189,7 @@ Make_Path(const rtems_printer *printer, const char* filename, bool end_is_dir)
if (!path_end) {
r = mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO);
if (r < 0) {
- Print_Error(printer, "mkdir", path);
+ Print_Error(printer, "mkdir (unlink)", path);
free(copy);
return -1;
}
@@ -310,7 +310,7 @@ Untar_ProcessHeader(
}
} else if (*linkflag == DIRTYPE) {
int r;
- rtems_printf(printer, "untar: dir: %s\n", fname);
+ rtems_printf(printer, "untar: dir: %s\n", fname);
if (Make_Path(printer, fname, true) < 0) {
retval = UNTAR_FAIL;
}
@@ -319,7 +319,9 @@ Untar_ProcessHeader(
if (errno == EEXIST) {
struct stat stat_buf;
if (stat(fname, &stat_buf) == 0) {
- if (!S_ISDIR(stat_buf.st_mode)) {
+ if (S_ISDIR(stat_buf.st_mode)) {
+ r = 0;
+ } else {
r = unlink(fname);
if (r == 0) {
r = mkdir(fname, *mode);
More information about the vc
mailing list