summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/TarWriter.cpp
AgeCommit message (Collapse)Author
2020-04-27Reland D78945 TarWriter: Only use 137 of the 155 prefix bytes.Fangrui Song
With a fix to unittests/Support/TarWriterTest.cpp This makes lld's --reproduce output more compatible with tar 1.13 and before. This is a very old version of tar, but it's the version in both gnuwin and unxutils, and the cost for supporting them are very low, so we might as well just do that. https://bugs.chromium.org/p/chromium/issues/detail?id=1073524#c21 and onward has more details. Differential Revision: https://reviews.llvm.org/D78945
2020-04-27Revert "TarWriter: Only use 137 of the 155 prefix bytes."Nico Weber
This reverts commit 90d6ed144c1352e393556a799e79da6ec3a5fab9. Breaks check-llvm. Revert while I investigate.
2020-04-27TarWriter: Only use 137 of the 155 prefix bytes.Nico Weber
This makes lld's --reproduce output more compatible with tar 1.13 and before. This is a very old version of tar, but it's the version in both gnuwin and unxutils, and the cost for supporting them are very low, so we might as well just do that. https://bugs.chromium.org/p/chromium/issues/detail?id=1073524#c21 and onward has more details. Differential Revision: https://reviews.llvm.org/D78945
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-06-07[FileSystem] Split up the OpenFlags enumeration.Zachary Turner
This breaks the OpenFlags enumeration into two separate enumerations: OpenFlags and CreationDisposition. The first controls the behavior of the API depending on whether or not the target file already exists, and is not a flags-based enum. The second controls more flags-like values. This yields a more easy to understand API, while also allowing flags to be passed to the openForRead api, where most of the values didn't make sense before. This also makes the apis more testable as it becomes easy to enumerate all the configurations which make sense, so I've added many new tests to exercise all the different values. llvm-svn: 334221
2017-12-05[Support/TarWriter] - Don't allow TarWriter to add the same file more than once.George Rimar
This is for PR35460. Currently when LLD adds files to TarWriter it may pass the same file multiple times. For example it happens for clang reproduce file which specifies archive (.a) files more than once in command line. Patch makes TarWriter to ignore files with the same path, so it will add only the first one to archive. Differential revision: https://reviews.llvm.org/D40606 llvm-svn: 319750
2017-09-28Fix a UBsan bot.Rui Ueyama
If we do not initialize Prefix here, Prefix.data() returns a nullptr. Later, it is passed to memcpy. memcpy's behavior is undefined if src (or dst) is a nullptr even if a given size is 0. That's why this code triggered UBsan. llvm-svn: 314368
2017-09-27Fix off-by-one error in TarWriter.Rui Ueyama
The tar format originally supported up to 99 byte filename. The two extensions are proposed later: Ustar or PAX. In the UStar extension, a pathanme is split at a '/' and its "prefix" and "suffix" are stored in different locations in the tar header. Since "prefix" can be up to 155 byte, it can represent up to 254 byte filename (but exact limit depends on the location of '/' character in a pathname.) Our TarWriter first attempt to use UStar extension and then fallback to PAX extension. But there's a bug in UStar header creation. "Suffix" part must be a NUL- terminated string, but we didn't handle it correctly. As a result, if your filename just 100 characters long, the last character was droppped. This patch fixes the issue. Differential Revision: https://reviews.llvm.org/D38149 llvm-svn: 314349
2017-01-09TarWriter: Fix a bug in Ustar header.Rui Ueyama
If we split a filename into `Name` and `Prefix`, `Prefix` is at most 145 bytes. We had a bug that didn't split a path correctly. This bug was pointed out by Rafael in the post commit review. This patch adds a unit test for TarWriter to verify the fix. llvm-svn: 291494
2017-01-09TarWriter: Set "00" to Ustar version field.Rui Ueyama
Most (maybe all?) tar commands can handle tar archives with blank version fields, but POSIX requires "00" to be set to the field, so doing it is good for compliance. llvm-svn: 291479
2017-01-09Define sys::path::convert_to_slashRui Ueyama
This patch moves convertToUnixPathSeparator from LLD to LLVM. Differential Revision: https://reviews.llvm.org/D28444 llvm-svn: 291414
2017-01-07TarWriter: Use fitsInUstar function.Rui Ueyama
This change should have been commit as part of r291340. llvm-svn: 291341
2017-01-07TarWriter: Use Ustar header's "prefix" field to store long filenames.Rui Ueyama
Tar's Ustar header has the "prefix" field to store a directory part of a filename. It is not as flexible as the PAX-extended filename because there's still a limitation on the maximum filename size, but it mitigates the situation. This patch should unbreak some Windows buildbots that uses very old tar command. llvm-svn: 291340
2017-01-06Use %z for size_t and avoid deprecated string functionsReid Kleckner
This usage of strcpy and snprintf was certainly safe, but using them sets off various deprecation and lint warnings. Easier to just write the belt and suspenders version. llvm-svn: 291256
2017-01-06TarWriter: Emit PAX headers only when needed.Rui Ueyama
We use PAX headers to store long filenames (>= 100 bytes). It is not needed to emit PAX headers if filenames fit in the Ustar header. This patch implements that optimization. llvm-svn: 291215
2017-01-06Add a class to create a tar archive file.Rui Ueyama
In LLD, we create cpio archive files for --reproduce command. cpio was not a bad choice because it is very easy to create, but it was sometimes hard to use because people are not familiar with cpio command. I noticed that creating a tar archive isn't as hard as I thought. So I implemented it in this patch. Differential Revision: https://reviews.llvm.org/D28091 llvm-svn: 291209