-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Minor follow-up initrd feedback items #14186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1143,6 +1143,7 @@ void wsl::windows::common::filesystem::CreateCpioInitrd(_In_ const std::filesyst | |
| constexpr size_t headerSize = 110; | ||
| const auto nameLen = strlen(name) + 1; | ||
| const auto headerPadding = (4 - ((headerSize + nameLen) % 4)) % 4; | ||
| const bool isTrailer = strcmp(name, "TRAILER!!!") == 0; | ||
|
|
||
| // Get current time for mtime. CPIO newc format only supports 32-bit fields. | ||
| const auto mtime = static_cast<DWORD>(time(nullptr)); | ||
|
|
@@ -1165,10 +1166,10 @@ void wsl::windows::common::filesystem::CreateCpioInitrd(_In_ const std::filesyst | |
| "%08X" // namesize | ||
| "%08X", // check | ||
| 0, | ||
| (fileSize > 0) ? 0100755 : 0, | ||
| isTrailer ? 0 : 0100755, | ||
| 0, | ||
| 0, | ||
| (fileSize > 0) ? 1 : 0, | ||
| isTrailer ? 0 : 1, | ||
|
Comment on lines
1168
to
+1172
|
||
| mtime, | ||
| fileSize, | ||
| 0, | ||
|
|
@@ -1214,7 +1215,8 @@ void wsl::windows::common::filesystem::CreateCpioInitrd(_In_ const std::filesyst | |
| LARGE_INTEGER currentPos{}; | ||
| THROW_IF_WIN32_BOOL_FALSE(SetFilePointerEx(destFile.get(), {}, ¤tPos, FILE_CURRENT)); | ||
|
|
||
| const auto archivePadding = (archiveBlockSize - (currentPos.LowPart % archiveBlockSize)) % archiveBlockSize; | ||
| const auto currentSize = static_cast<ULONGLONG>(currentPos.QuadPart); | ||
| const auto archivePadding = static_cast<DWORD>((archiveBlockSize - (currentSize % archiveBlockSize)) % archiveBlockSize); | ||
| if (archivePadding > 0) | ||
| { | ||
| char paddingBuffer[archiveBlockSize] = {0}; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -325,10 +325,10 @@ class SimpleTests | |||||||||||
| THROW_IF_WIN32_BOOL_FALSE(GetFileSizeEx(cpioHandle.get(), &cpioSize)); | ||||||||||||
| VERIFY_ARE_EQUAL(cpioSize.QuadPart % 512, 0LL); // Archive padded to 512-byte boundary | ||||||||||||
|
|
||||||||||||
| char header[110] = {}; | ||||||||||||
| char header[111] = {}; | ||||||||||||
| DWORD bytesRead; | ||||||||||||
| THROW_IF_WIN32_BOOL_FALSE(ReadFile(cpioHandle.get(), header, sizeof(header), &bytesRead, nullptr)); | ||||||||||||
| VERIFY_ARE_EQUAL(bytesRead, static_cast<DWORD>(sizeof(header))); | ||||||||||||
| THROW_IF_WIN32_BOOL_FALSE(ReadFile(cpioHandle.get(), header, 110, &bytesRead, nullptr)); | ||||||||||||
| VERIFY_ARE_EQUAL(bytesRead, 110u); | ||||||||||||
|
Comment on lines
+330
to
+331
|
||||||||||||
| THROW_IF_WIN32_BOOL_FALSE(ReadFile(cpioHandle.get(), header, 110, &bytesRead, nullptr)); | |
| VERIFY_ARE_EQUAL(bytesRead, 110u); | |
| const DWORD headerBytesToRead = static_cast<DWORD>(sizeof(header) - 1); | |
| THROW_IF_WIN32_BOOL_FALSE(ReadFile(cpioHandle.get(), header, headerBytesToRead, &bytesRead, nullptr)); | |
| VERIFY_ARE_EQUAL(bytesRead, headerBytesToRead); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated but I keep getting annoyed that the test-storage directory isn't in the gitignore in the main branch.