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

Feature/improvements to the windows filesystem implementation #210

Conversation

stagnation
Copy link
Contributor

This fixes some issues we found when developing windows runners.

Comment on lines 466 to 468
// NB: We have never seen `ERROR_MORE_DATA` during development,
// it seems it is never raised. But according to the docs is should be set
// and we should proceed with the happy path.
Copy link
Member

Choose a reason for hiding this comment

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

That's because you've never attempted to read directories containing filenames that are more than 256 bytes long. Please remove this comment, as it is a valid case that we should handle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, that makes sense. I will setup a test to verify that this works. Have you used this API before, or know of good documentation? I have mostly been tinkering with it manually to see what pops back out.

https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfileinformationbyhandleex
https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/Win7Samples/winbase/io/extendedfileapis/ExtendedFileAPIs.cpp#L468

Copy link
Member

Choose a reason for hiding this comment

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

I don't know anything about it. I don't use Windows myself. ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll need some more time to tinker with this.
I now have a manual test that hits the ERROR_MORE_DATA for a 250-character filename and a small initial buffer.
Will wire that up.

Have not been able to test against the long-file path API as it is hard to actually create such files. I'm not very familiar with the special APIs either.

// would fill. Any larger allocation would be unused and lead to
// resource exhaustion. We have not found good documentation for how to
// use this.
outBufferSize = clamp(outBufferSize*2, 62000)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this, why don't we simply use a buffer that is twice as big as what the last call to GetFileInformationByHandleEx() filled? So if we give it a 4 KB buffer and the kernel fills the entire 4 KB, then the next time we call it with 8 KB. Then we don't need to make guesses about what the kernel's limit actually is.

}
names = append(names, fileName)
continue
Copy link
Member

Choose a reason for hiding this comment

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

This statement isn't necessary, right? A loop always continues on its own.

@stagnation stagnation force-pushed the feature/improvements-to-the-windows-filesystem-implementation branch 2 times, most recently from fb4b004 to fa362db Compare July 3, 2024 09:34
Nils Wireklint added 3 commits July 4, 2024 09:59
The 'ERROR_MORE_DATA' error is only raised if a single entry could not
fit into the buffer, not that there are no more entries. This instead
polls until the bookend 'ERROR_NO_MORE_DATA' is raised instead.
This fixes execution errors where some programs fail to execute while a
source file is hardlinked into another scheduled actions. Many compilers
restrict the sharing mode for the files they open, 'cl.exe' for instance
does not allow other processes to have open WRITE handles to its source
files, and fails with SHARING_VIOLATION if such handles are open. The
hardlinking file fetcher does not need this permission and we solve many
crashes by removing it.
@stagnation stagnation force-pushed the feature/improvements-to-the-windows-filesystem-implementation branch from fa362db to d0d76db Compare July 4, 2024 08:04
@EdSchouten EdSchouten merged commit a2eab49 into buildbarn:master Jul 8, 2024
1 check passed
@stagnation stagnation deleted the feature/improvements-to-the-windows-filesystem-implementation branch July 8, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants