[BusyBox] Fix for busybox-tar
Arne Bernin
ab at netropol.de
Sun Dec 17 22:11:17 UTC 2000
Hi,
attached are two patches to cleanup the tar.c (two lines ;-),
and get archiving the root dir (/) right.
The first one is only to get the same behaviour for --exclude and -X, as -X
strips off all leading '/'s, and --exclude does this only whith the first. i
do not know if this is the right thing, there are still some Problems with
making things like tar -cv --exclude /init.d -f /tmp/test.tar /etc, as this
excludes /etc/init.d which it should not in my opinion.
The second patch is against utility.c /recursive_action. While recursivly
going throgh the directorys we get a //usr for the next dirs, cause
utility.c makes a sprintf(nextFile, "%s/%s", fileName, nex
t->d_name); and fileName is '/'. This is not done any more, if fileName is
'/'.
I know that cp and mv are using this too, but i haven't tested very well,
that is still works. but it should.
There is still at least one Problem left with tar:
if i make an --exclude and in this directory there is a subdir i do not have
the permission to dive into, tar exits saying that i don't have the
permission. Without the --exclude it leaves this dir out and continues...
-- arne
-------------------------------------------------------------------
Arne Bernin Netropol Digitale Systeme
Lagerstrasse 30a
Tel: +49 4043250000 D-20357 Hamburg/Germany
Fax: +49 40 43189490 ab at Netropol.de
-------------- next part --------------
--- busybox/tar.c Wed Dec 13 16:28:48 2000
+++ busybox-new/tar.c Sun Dec 17 22:56:50 2000
@@ -252,8 +252,8 @@
if (excludeList[excludeListSize] == NULL)
error_msg_and_die( "Option requires an argument: No file specified\n");
/* Remove leading "/"s */
- if (*excludeList[excludeListSize] =='/')
- excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
+ while (*excludeList[excludeListSize] =='/')
+ excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
/* Tack a NULL onto the end of the list */
excludeList[++excludeListSize] = NULL;
stopIt=TRUE;
-------------- next part --------------
--- busybox/utility.c Wed Dec 13 02:52:39 2000
+++ busybox-new/utility.c Sun Dec 17 22:51:22 2000
@@ -688,7 +688,13 @@
return FALSE;
}
memset(nextFile, 0, sizeof(nextFile));
- sprintf(nextFile, "%s/%s", fileName, next->d_name);
+ /* when fileName is the root dir,
+ just leave the name out!*/
+ if (*fileName == '/' && fileName[1] == '\0') {
+ sprintf(nextFile, "/%s",next->d_name);
+ } else {
+ sprintf(nextFile, "%s/%s", fileName, next->d_name);
+ }
status =
recursive_action(nextFile, TRUE, followLinks, depthFirst,
fileAction, dirAction, userData);
More information about the busybox
mailing list