aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-03-23 18:32:04 -0700
committerRob Landley <rob@landley.net>2020-03-23 20:46:49 -0500
commit729f1de79c7c24745716f6781457fd46b58c456d (patch)
treeeddd59d5c446415d2c244f9f38418b1e5f8cf91d /toys
parent5a6d1746baacb40e2a3f094af50dbe9871afa3cf (diff)
downloadtoybox-729f1de79c7c24745716f6781457fd46b58c456d.tar.gz
tar: implement --absolute-names.
Used by the Linux kernel build when copying kernel headers to kernel-headers.tar.gz. Bug: http://b/152244851
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/tar.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/toys/posix/tar.c b/toys/posix/tar.c
index 16e4e49c..9642fbe6 100644
--- a/toys/posix/tar.c
+++ b/toys/posix/tar.c
@@ -17,7 +17,7 @@
* Why --exclude pattern but no --include? tar cvzf a.tgz dir --include '*.txt'
*
-USE_TAR(NEWTOY(tar, "&(restrict)(full-time)(no-recursion)(numeric-owner)(no-same-permissions)(overwrite)(exclude)*(mode):(mtime):(group):(owner):(to-command):o(no-same-owner)p(same-permissions)k(keep-old)c(create)|h(dereference)x(extract)|t(list)|v(verbose)J(xz)j(bzip2)z(gzip)S(sparse)O(to-stdout)m(touch)X(exclude-from)*T(files-from)*C(directory):f(file):a[!txc][!jzJa]", TOYFLAG_USR|TOYFLAG_BIN))
+USE_TAR(NEWTOY(tar, "&(restrict)(full-time)(no-recursion)(numeric-owner)(no-same-permissions)(overwrite)(exclude)*(mode):(mtime):(group):(owner):(to-command):o(no-same-owner)p(same-permissions)k(keep-old)c(create)|h(dereference)x(extract)|t(list)|v(verbose)J(xz)j(bzip2)z(gzip)S(sparse)O(to-stdout)P(absolute-names)m(touch)X(exclude-from)*T(files-from)*C(directory):f(file):a[!txc][!jzJa]", TOYFLAG_USR|TOYFLAG_BIN))
config TAR
bool "tar"
@@ -189,7 +189,7 @@ static int add_to_tar(struct dirtree *node)
}
i = 1;
- name = dirtree_path(node, &i);
+ name = hname = dirtree_path(node, &i);
// exclusion defaults to --no-anchored and --wildcards-match-slash
for (lnk = name; *lnk;) {
@@ -202,7 +202,7 @@ static int add_to_tar(struct dirtree *node)
if (S_ISDIR(st->st_mode) && name[i-1] != '/') strcat(name, "/");
// remove leading / and any .. entries from saved name
- for (hname = name; *hname == '/'; hname++);
+ if (!FLAG(P)) while (*hname == '/') hname++;
for (lnk = hname;;) {
if (!(lnk = strstr(lnk, ".."))) break;
if (lnk == hname || lnk[-1] == '/') {