[BusyBox] Re: BusyBox tar Problem

Erik Andersen andersen at lineo.com
Fri Jun 9 20:45:50 UTC 2000


On Wed Jun 07, 2000 at 02:13:52PM -0700, Kevin Traas wrote:
> Uhhh... Okay, I think I've got this closer to being figured out.
> 
> The tarball I'm trying to extract has files such as:
> 
> lib/modules/2.2.15/net/3c59x.o
> 
> in it.
> 
> The first time I try extracting the archive, it gives me the "no such
> file or directory" error on the first file to be extracted from the
> archive - and then continues extracting the rest of the files in the
> archive (to the same directory structure mentioned above) quite
> normally.  
> 
> If I simply "up-arrow" and press Enter to repeat the same command, I
> don't get any errors and the first file in the archive now extracts
> correctly.
> 
> If, after running the extraction once (and getting the errors), I delete
> all the extracted files (located in lib/modules/2.2.15/net), leaving the
> directory structure in place, and run the extraction for a second time,
> I don't get any errors.
> 
> As I mentioned earlier, GNU tar extracts the archive without errors at
> any time.
> 
> So.... final conclusions:
> 
> - Busybox tar doesn't have this problem with all tarballs I create....
> 
> - It appears as if 'tar' creates a previously non-existing directory
> *after* it tries to extract the first file from the archive.  This would
> explain why further files in the archive and located in the same
> destination directory extract without any problems....
> 
> 
> Erik,  I don't know how to help you any further with this; however, I've
> attached one of my problematic tarballs to this email for your "testing"
> pleasure....  ;-)
> 
> (This tarball contains about 8 files, all stored in the dir structure
> mentioned above.)
> 
> If you figure out what's going on, please let me know.  I'd love to find
> out what's been causing my "hair-pulling" situation....   ;-)
> 

Could you try this patch.  I believe I have it fixed -- it was a thinko on my
part where I tried to open the file before ensuring that the directory tree that
the file was supposed to live in was first present.

 -Erik

--
Erik B. Andersen   email:  andersen at lineo.com
--This message was written using 73% post-consumer electrons--


Index: Changelog
===================================================================
RCS file: /cvs/busybox/Changelog,v
retrieving revision 1.155
diff -u -b -B -w -p -r1.155 Changelog
--- Changelog	2000/06/08 15:25:39	1.155
+++ Changelog	2000/06/09 20:42:37
@@ -67,6 +67,10 @@
 	    Pavel Roskin
 	* Syslogd will not go to background if "-n" is given. Better help
 	    and argument checking -- Pavel Roskin
+	* Fixed a small bug that could cause tar to emit warning messages
+	    and not extract the first file in a directory in some cases
+	    of nested directories.  Thanks to Kevin Traas <kevin at netmaster.com>
+	    for helping track this one down.
 	* More doc updates
 
 
Index: tar.c
===================================================================
RCS file: /cvs/busybox/tar.c,v
retrieving revision 1.48
diff -u -b -B -w -p -r1.48 tar.c
--- tar.c	2000/05/30 19:05:57	1.48
+++ tar.c	2000/06/09 20:42:37
@@ -300,11 +300,14 @@ tarExtractRegularFile(TarInfo *header, i
 
 	/* Open the file to be written, if a file is supposed to be written */
 	if (extractFlag==TRUE && tostdoutFlag==FALSE) {
-		if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, header->mode & ~S_IFMT)) < 0)
-			errorMsg(io_error, header->name, strerror(errno)); 
 		/* Create the path to the file, just in case it isn't there...
 		 * This should not screw up path permissions or anything. */
 		createPath(header->name, 0777);
+		if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, 
+						header->mode & ~S_IFMT)) < 0) {
+			errorMsg(io_error, header->name, strerror(errno)); 
+			return( FALSE);
+		}
 	}
 
 	/* Write out the file, if we are supposed to be doing that */





More information about the busybox mailing list