llvm.org GIT mirror llvm / 0972d27
Handle UIDs and GIDs that don't fit in 6 decimal places. Newer unix systems have 32 bit uid and gid types, but the archive format was not updated. Fortunately, these fields are not normally used. Just truncate the data to fit in 6 chars. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199223 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
1 changed file(s) with 14 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
577577 }
578578
579579 template
580 static void printWithSpacePadding(raw_ostream &OS, T Data, unsigned Size) {
580 static void printWithSpacePadding(raw_fd_ostream &OS, T Data, unsigned Size,
581 bool MayTruncate = false) {
581582 uint64_t OldPos = OS.tell();
582583 OS << Data;
583584 unsigned SizeSoFar = OS.tell() - OldPos;
584 assert(Size >= SizeSoFar && "Data doesn't fit in Size");
585 unsigned Remaining = Size - SizeSoFar;
586 for (unsigned I = 0; I < Remaining; ++I)
587 OS << ' ';
585 if (Size > SizeSoFar) {
586 unsigned Remaining = Size - SizeSoFar;
587 for (unsigned I = 0; I < Remaining; ++I)
588 OS << ' ';
589 } else if (Size < SizeSoFar) {
590 assert(MayTruncate && "Data doesn't fit in Size");
591 // Some of the data this is used for (like UID) can be larger than the
592 // space available in the archive format. Truncate in that case.
593 OS.seek(OldPos + Size);
594 }
588595 }
589596
590597 static void print32BE(raw_fd_ostream &Out, unsigned Val) {
599606 unsigned GID, unsigned Perms,
600607 unsigned Size) {
601608 printWithSpacePadding(Out, ModTime.toEpochTime(), 12);
602 printWithSpacePadding(Out, UID, 6);
603 printWithSpacePadding(Out, GID, 6);
609 printWithSpacePadding(Out, UID, 6, true);
610 printWithSpacePadding(Out, GID, 6, true);
604611 printWithSpacePadding(Out, format("%o", Perms), 8);
605612 printWithSpacePadding(Out, Size, 10);
606613 Out << "`\n";