Re: PATCH] untar: do not exit with error when created directory already exists (fixes #2413).
Hello Gedare, On Wednesday 09 of September 2015 17:05:43 Gedare Bloom wrote: > Do we still have two versions of the untar code? There is another implementation which is IMFS specific. It is invoked by function rtems_tarfs_load() located in rtems/cpukit/libfs/src/imfs/imfs_load_tar.c It is better optimized that it does not copy data from image to RAM. But on the other hand is specific for IMFS only. The corrected implementation rtems/cpukit/libmisc/untar/untar.c is generic untar code which is independent on filesystem. So it can be used (in theory) to untar file to FAT or other filesystems and supports untar from memory Untar_FromMemory() and Untar_FromFile(). It has disadvantage that does not easily support to specify location where to untar when compared with rtems_tarfs_load(). So both implementations are not 1:1 feature equivalent. The rtems_tarfs_load() has been introduced in 2000 year. We use Untar_FromMemory() in our application but it may be more for historical reasons than that use of rtems_tarfs_load() would not provide same function and rtems_tarfs_load() is much less memory hungry than Untar_FromMemory(). But I think that it would worth to fix untar.c when it is present. It correctly worked in previous releases and (as I have located now) has been broken at commit e075b388728408e8745408c8dbdbe9635ccea399 untar: check return value from mkdir by Gedare Bloom :-) Best wishes, Pavel > This looks good to commit. > > On Mon, Sep 7, 2015 at 5:23 AM, Pavel Pisa 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 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: PATCH] untar: do not exit with error when created directory already exists (fixes #2413).
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 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 > #include > #include > +#include > #include > #include > #include > @@ -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@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
PATCH] untar: do not exit with error when created directory already exists (fixes #2413).
--- 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 #include #include +#include #include #include #include @@ -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@rtems.org http://lists.rtems.org/mailman/listinfo/devel