Skip to content
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

Filesystem/Win32: Recreate hardlinks on fs::pending_file #16256

Merged
merged 4 commits into from
Oct 29, 2024

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Oct 27, 2024

Attempting to address #16255
Also fixes #16260

@@ -2486,16 +2485,62 @@ bool fs::pending_file::commit(bool overwrite)
disp.DeleteFileW = false;
ensure(SetFileInformationByHandle(file.get_handle(), FileDispositionInfo, &disp, sizeof(disp)));
}

std::vector<std::wstring> hardlinkPaths;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scnakecase


const auto ws1 = to_wchar(m_path);

const HANDLE fileHandle = CreateFileW(ws1.get(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snakecase

while (fileHandle != INVALID_HANDLE_VALUE)
{
// Get file ID (used to check for hardlinks)
BY_HANDLE_FILE_INFORMATION fileInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snakecase


// Buffer for holding link name
WCHAR linkNameBuffer[MAX_PATH];
HANDLE findHandle = FindFirstFileNameW(ws1.get(), 0, nullptr, linkNameBuffer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:
-Limiting to MAX_PATH on windows has been a problem in the past if I recall, we should avoid that if possible
-Is nullptr for StringLength even valid, documentation doesn't mention it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@elad335 elad335 marked this pull request as ready for review October 28, 2024 10:19
@digant73
Copy link
Contributor

maybe the fix for #16245 (reported in that PR) could be also provided in this PR

while (true)
{
buffer_size = link_name_buffer.size() - 1;
findHandle = FindFirstFileNameW(ws1.get(), 0, &buffer_size, link_name_buffer.data());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
findHandle = FindFirstFileNameW(ws1.get(), 0, &buffer_size, link_name_buffer.data());
find_handle = FindFirstFileNameW(ws1.get(), 0, &buffer_size, link_name_buffer.data());

@elad335 elad335 merged commit 8b8396b into RPCS3:master Oct 29, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] RPCS3 Doesn't Boot Correctly For Some Systems
4 participants