Lines Matching defs:tar
0 /* tar.c - create/extract archives
6 * http://pubs.opengroup.org/onlinepubs/007908799/xcu/tar.html
10 * https://www.gnu.org/software/tar/manual/html_node/Tar-Internals.html
13 * http://www.gnu.org/software/tar/manual/html_node/Writing-to-an-External-Program.html
17 * Why --exclude pattern but no --include? tar cvzf a.tgz dir --include '*.txt'
20 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))
23 bool "tar"
26 usage: tar [-cxt] [-fvohmjkOS] [-XTCf NAME] [FILES]
28 Create, extract, or list files in a .tar (or compressed t?z) file.
32 f tar FILE (default -) C Change to DIR first v Verbose display
69 // Parsed information about a tar header.
104 // When tar value too big or octal, use binary encoding with high bit set
546 struct tar_hdr tar;
553 memcpy(&tar, first, i = 512);
558 i = readall(TT.fd, &tar, 512);
563 // Two consecutive empty headers ends tar even if there's more data
564 if (!i || !*tar.name) {
570 tar.padd[0] = and = 0;
573 if (!is_tar_header(&tar)) error_exit("bad header");
574 TT.hdr.size = OTOI(tar.size);
577 if ((tar.type<'0' || tar.type>'7') && tar.type!='S'
578 && (*tar.magic && tar.type))
581 if (tar.type == 'K') alloread(&TT.hdr.link_target, TT.hdr.size);
582 else if (tar.type == 'L') alloread(&TT.hdr.name, TT.hdr.size);
583 else if (tar.type == 'x') {
610 if (tar.type == 'S') {
617 s = 386+(char *)&tar;
626 if (!(*sparse ? sparse[504] : ((char *)&tar)[482])) break;
636 // Odd number of entries (from corrupted tar) would be dropped here
646 TT.hdr.mode = OTOI(tar.mode)&0xfff;
647 if (tar.type == 'S' || !tar.type) TT.hdr.mode |= 0x8000;
648 else TT.hdr.mode |= (char []){8,8,10,2,6,4,1,8}[tar.type-'0']<<12;
649 TT.hdr.uid = OTOI(tar.uid);
650 TT.hdr.gid = OTOI(tar.gid);
651 TT.hdr.mtime = OTOI(tar.mtime);
652 maj = OTOI(tar.major);
653 min = OTOI(tar.minor);
655 TT.hdr.uname = xstrndup(TT.owner ? TT.owner : tar.uname, sizeof(tar.uname));
656 TT.hdr.gname = xstrndup(TT.group ? TT.group : tar.gname, sizeof(tar.gname));
670 if (!TT.hdr.link_target && *tar.link)
671 TT.hdr.link_target = xstrndup(tar.link, sizeof(tar.link));
674 i = (tar.type=='S') ? 0 : strnlen(tar.prefix, sizeof(tar.prefix));
675 TT.hdr.name = xmprintf("%.*s%s%.*s", i, tar.prefix,
676 (i && tar.prefix[i-1] != '/') ? "/" : "",
677 (int)sizeof(tar.name), tar.name);
680 // Old broken tar recorded dir as "file with trailing slash"
688 || (tar.type && !S_ISREG(TT.hdr.mode)))
721 if (tar.type=='3' || tar.type=='4') printf("%u,%u", maj, min);
749 // todo: short write exits tar here, other skips data.
845 else error_exit("Not tar");
917 char *tbz[] = {".tbz", ".tbz2", ".tar.bz", ".tar.bz2"};
918 if (strend(TT.f, ".tgz") || strend(TT.f, ".tar.gz"))
920 if (strend(TT.f, ".txz") || strend(TT.f, ".tar.xz"))