diff options
Diffstat (limited to 'libtar')
-rw-r--r-- | libtar/extract.c | 25 | ||||
-rw-r--r-- | libtar/libtar.h | 4 | ||||
-rw-r--r-- | libtar/wrapper.c | 4 |
3 files changed, 17 insertions, 16 deletions
diff --git a/libtar/extract.c b/libtar/extract.c index 554428715..620513c29 100644 --- a/libtar/extract.c +++ b/libtar/extract.c @@ -89,13 +89,13 @@ tar_set_file_perms(TAR *t, char *realname) /* switchboard */ int -tar_extract_file(TAR *t, char *realname) +tar_extract_file(TAR *t, char *realname, char *prefix) { int i; char *lnp; int pathname_len; int realname_len; - + if (t->options & TAR_NOOVERWRITE) { struct stat s; @@ -115,7 +115,7 @@ tar_extract_file(TAR *t, char *realname) } else if (TH_ISLNK(t)) { printf("link\n"); - i = tar_extract_hardlink(t, realname); + i = tar_extract_hardlink(t, realname, prefix); } else if (TH_ISSYM(t)) { printf("sym\n"); @@ -139,13 +139,13 @@ tar_extract_file(TAR *t, char *realname) } if (i != 0) { - printf("here i: %d\n", i); + printf("FAILED RESTORE OF FILE i: %s\n", realname); return i; } i = tar_set_file_perms(t, realname); if (i != 0) { - printf("i: %d\n", i); + printf("FAILED SETTING PERMS: %d\n", i); return i; } /* @@ -300,7 +300,7 @@ tar_skip_regfile(TAR *t) /* hardlink */ int -tar_extract_hardlink(TAR * t, char *realname) +tar_extract_hardlink(TAR * t, char *realname, char *prefix) { char *filename; char *linktgt = NULL; @@ -325,7 +325,8 @@ tar_extract_hardlink(TAR * t, char *realname) } else linktgt = th_get_linkname(t); - + char *newtgt = strdup(linktgt); + sprintf(linktgt, "%s/%s", prefix, newtgt); #ifdef DEBUG printf(" ==> extracting: %s (link to %s)\n", filename, linktgt); #endif @@ -346,7 +347,7 @@ int tar_extract_symlink(TAR *t, char *realname) { char *filename; - + if (!TH_ISSYM(t)) { printf("not a sym\n"); @@ -412,9 +413,9 @@ tar_extract_chardev(TAR *t, char *realname) compat_makedev(devmaj, devmin)) == -1) { #ifdef DEBUG - perror("mknod()"); + printf("mknod() failed, returning good anyway"); #endif - return -1; + return 0; } return 0; @@ -451,9 +452,9 @@ tar_extract_blockdev(TAR *t, char *realname) compat_makedev(devmaj, devmin)) == -1) { #ifdef DEBUG - perror("mknod()"); + printf("mknod() failed but returning anyway"); #endif - return -1; + return 0; } return 0; diff --git a/libtar/libtar.h b/libtar/libtar.h index 7a8f332ee..f2f423b9b 100644 --- a/libtar/libtar.h +++ b/libtar/libtar.h @@ -218,11 +218,11 @@ void th_finish(TAR *t); /***** extract.c ***********************************************************/ /* sequentially extract next file from t */ -int tar_extract_file(TAR *t, char *realname); +int tar_extract_file(TAR *t, char *realname, char *prefix); /* extract different file types */ int tar_extract_dir(TAR *t, char *realname); -int tar_extract_hardlink(TAR *t, char *realname); +int tar_extract_hardlink(TAR *t, char *realname, char *prefix); int tar_extract_symlink(TAR *t, char *realname); int tar_extract_chardev(TAR *t, char *realname); int tar_extract_blockdev(TAR *t, char *realname); diff --git a/libtar/wrapper.c b/libtar/wrapper.c index 7cd8ed12c..4d8216241 100644 --- a/libtar/wrapper.c +++ b/libtar/wrapper.c @@ -44,7 +44,7 @@ tar_extract_glob(TAR *t, char *globname, char *prefix) snprintf(buf, sizeof(buf), "%s/%s", prefix, filename); else strlcpy(buf, filename, sizeof(buf)); - if (tar_extract_file(t, filename) != 0) + if (tar_extract_file(t, filename, prefix) != 0) return -1; } @@ -86,7 +86,7 @@ tar_extract_all(TAR *t, char *prefix) continue; } */ - if (tar_extract_file(t, buf) != 0) + if (tar_extract_file(t, buf, prefix) != 0) return -1; } return (i == 1 ? 0 : -1); |