On 14/07/2015 1:57 am, Gedare Bloom wrote: > On Mon, Jul 13, 2015 at 11:26 AM, Pavel Pisa <p...@cmp.felk.cvut.cz> wrote: >> Hello Sujay Raj, >> >> >> On Tuesday 30 of June 2015 06:39:28 Sujay Raj wrote: >>> I need to access configurations files the for web server I am porting to >>> rtems. >>> >>> I create a tar archive , that contains the required folders and files , >>> convert it into c source using rtems-bin2c , ( a header file and a c source >>> ) and link them with my project. >>> >>> In the init, I call >>> >>> sc = Untar_FromMemory((void *)TARFILE_START, (size_t)TARFILE_SIZE); >>> >>> where TARFILE_START is the macro with the name of the array , TARFILE_SIZE >>> is the size of the array. >>> >>> But when I run the program, I get errors of the form >>> >>> "Untar: failed to create file <folder>/<filename>" >>> >> >> I have noticed and reported similar problem and workaround some >> time ago. Problem is, that Untar_FromMemory() function fails >> when it reaches a directory entry in a TAR file and given >> directory already exists. It fails even for existing >> top level directory which has to exists in RTEMS runing >> system and are packed by TAR by default. >> >> My fix is not ideal. Other (more generic option) is to use >> stat(const char *path, struct stat *buf) with check >> that target is already existing direcory. But using stat() >> in really minimal application can lead to unneeded overhead. >> Other option is to ignore directory create errors completelly >> but I do not like something like that in RT system. >> >> There is alternative way to untar file by other RTEMS functions >> but we use Untar_FromMemory() in more projects. If there is no >> objection or opinion for other solution, I prepare and check >> patch with stat(). >> >> >> From 4ce027b21cfde5bc6143d51d244345e05dd85cd4 Mon Sep 17 00:00:00 2001 >> Message-Id: >> <4ce027b21cfde5bc6143d51d244345e05dd85cd4.1436800331.git.pp...@pikron.com> >> From: Pavel Pisa <pp...@pikron.com> >> Date: Mon, 31 Mar 2014 00:57:12 +0200 >> Subject: [PATCH] untar: workaround for fail on top level directory existence. >> To: rtems-de...@rtems.org >> >> Signed-off-by: Pavel Pisa <pp...@pikron.com> >> --- >> cpukit/libmisc/untar/untar.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c >> index aed8fed..498fa12 100644 >> --- a/cpukit/libmisc/untar/untar.c >> +++ b/cpukit/libmisc/untar/untar.c >> @@ -203,6 +203,8 @@ Untar_FromMemory( >> } >> } else if (linkflag == DIRTYPE) { >> if ( mkdir(fname, S_IRWXU | S_IRWXG | S_IRWXO) != 0 ) { >> + if ( !strcmp(fname, "/") || !strcmp(fname, "./")) >> + continue; > So this just proceeds if the top-level directly already exists? I > don't really have a problem with the patch if there is a test case > that shows the problem case, but I think the reported failure may be > elsewhere since Sujay said the error was "Untar: failed to create > file" and not "directory".
Is this related to https://devel.rtems.org/ticket/2207 ? Chris > >> 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 > _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel