Lines Matching full:tar
1 /* 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)(overw…
22 config TAR
23 bool "tar"
26 usage: tar [-cxt] [-fvohmjkOS] [-XTCf NAME] [FILE...]
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 in otoi()
553 struct tar_hdr tar; in unpack_tar() local
560 memcpy(&tar, first, i = 512); in unpack_tar()
565 i = readall(TT.fd, &tar, 512); in unpack_tar()
570 // Two consecutive empty headers ends tar even if there's more data in unpack_tar()
571 if (!i || !*tar.name) { in unpack_tar()
577 tar.padd[0] = and = 0; in unpack_tar()
579 // Is this a valid TAR header? in unpack_tar()
580 if (!is_tar_header(&tar)) error_exit("bad header"); in unpack_tar()
581 TT.hdr.size = OTOI(tar.size); in unpack_tar()
584 if ((tar.type<'0' || tar.type>'7') && tar.type!='S' in unpack_tar()
585 && (*tar.magic && tar.type)) in unpack_tar()
588 if (tar.type == 'K') alloread(&TT.hdr.link_target, TT.hdr.size); in unpack_tar()
589 else if (tar.type == 'L') alloread(&TT.hdr.name, TT.hdr.size); in unpack_tar()
590 else if (tar.type == 'x') { in unpack_tar()
617 if (tar.type == 'S') { in unpack_tar()
624 s = 386+(char *)&tar; in unpack_tar()
633 if (!(*sparse ? sparse[504] : ((char *)&tar)[482])) break; in unpack_tar()
643 // Odd number of entries (from corrupted tar) would be dropped here in unpack_tar()
653 TT.hdr.mode = OTOI(tar.mode)&0xfff; in unpack_tar()
654 if (tar.type == 'S' || !tar.type) TT.hdr.mode |= 0x8000; in unpack_tar()
655 else TT.hdr.mode |= (char []){8,8,10,2,6,4,1,8}[tar.type-'0']<<12; in unpack_tar()
656 TT.hdr.uid = OTOI(tar.uid); in unpack_tar()
657 TT.hdr.gid = OTOI(tar.gid); in unpack_tar()
658 TT.hdr.mtime = OTOI(tar.mtime); in unpack_tar()
659 maj = OTOI(tar.major); in unpack_tar()
660 min = OTOI(tar.minor); in unpack_tar()
662 TT.hdr.uname = xstrndup(TT.owner ? TT.owner : tar.uname, sizeof(tar.uname)); in unpack_tar()
663 TT.hdr.gname = xstrndup(TT.group ? TT.group : tar.gname, sizeof(tar.gname)); in unpack_tar()
677 if (!TT.hdr.link_target && *tar.link) in unpack_tar()
678 TT.hdr.link_target = xstrndup(tar.link, sizeof(tar.link)); in unpack_tar()
681 i = (tar.type=='S') ? 0 : strnlen(tar.prefix, sizeof(tar.prefix)); in unpack_tar()
682 TT.hdr.name = xmprintf("%.*s%s%.*s", i, tar.prefix, in unpack_tar()
683 (i && tar.prefix[i-1] != '/') ? "/" : "", in unpack_tar()
684 (int)sizeof(tar.name), tar.name); in unpack_tar()
687 // Old broken tar recorded dir as "file with trailing slash" in unpack_tar()
695 || (tar.type && !S_ISREG(TT.hdr.mode))) in unpack_tar()
728 if (tar.type=='3' || tar.type=='4') printf("%u,%u", maj, min); in unpack_tar()
756 // todo: short write exits tar here, other skips data. in unpack_tar()
852 else error_exit("Not tar"); in tar_main()
924 char *tbz[] = {".tbz", ".tbz2", ".tar.bz", ".tar.bz2"}; in tar_main()
925 if (strend(TT.f, ".tgz") || strend(TT.f, ".tar.gz")) in tar_main()
927 if (strend(TT.f, ".txz") || strend(TT.f, ".tar.xz")) in tar_main()