PATCH] untar: do not exit with error when created directory already exists (fixes #2413).

Gedare Bloom gedare at rtems.org
Wed Sep 9 15:05:43 UTC 2015


Do we still have two versions of the untar code?

This looks good to commit.

On Mon, Sep 7, 2015 at 5:23 AM, Pavel Pisa <pisa at cmp.felk.cvut.cz> wrote:
> ---
>  cpukit/libmisc/untar/untar.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c
> index aed8fed..4591a8b 100644
> --- a/cpukit/libmisc/untar/untar.c
> +++ b/cpukit/libmisc/untar/untar.c
> @@ -28,6 +28,7 @@
>  #include <string.h>
>  #include <stdlib.h>
>  #include <unistd.h>
> +#include <errno.h>
>  #include <sys/stat.h>
>  #include <fcntl.h>
>  #include <rtems/untar.h>
> @@ -203,6 +204,13 @@ Untar_FromMemory(
>        }
>      } else if (linkflag == DIRTYPE) {
>        if ( mkdir(fname, S_IRWXU | S_IRWXG | S_IRWXO) != 0 ) {
> +        if (errno == EEXIST) {
> +          struct stat stat_buf;
> +          if ( stat(fname, &stat_buf) == 0 ) {
> +            if (  S_ISDIR(stat_buf.st_mode) )
> +              continue;
> +          }
> +        }
>          printk("Untar: failed to create directory %s\n", fname);
>          retval = UNTAR_FAIL;
>          break;
> --
> 1.9.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel



More information about the devel mailing list