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
Provide case-sensitivity for normal Windows processes. #2954
Comments
I believe @SvenGroot is in the middle of writing a blog post you'll be very interested to read. Long story short is Windows will be supporting case-sensitivity on a per-directory basis. |
@benhillis I'm really impressed with how much of the WSL stuff (or stuff driven by WSL needs) is making it into the core functionality of Windows itself! |
The ask here stems from:
In other words, the straightforward ask is for an I am not sure that question will be answered in the forthcoming blog, which I believe (?) is related to NTFS extended attributes on directories, not NT object case sensitivity. If the ask is not related to the blog post, it might be polite to answer that here. Because it is a good question, and because DDoSolitary was asked politely to file a new issue. Or putting it in my own words: what blocked |
@therealkenc I'm guessing there will be a flag on Windows directories in the "properties" dialogue, and NtCreateFile will now check the case sensitivity setting on the target directory? |
Sure, exactly like that. Explorer could highlight the case sensitive versus case insensitive directories too, perhaps with some new folder artwork. [No, wait. I think the cheese was bad on my pizza tonight and I am not feeling very well. Nevermind. I have no idea if a flag in the Windows "properties" dialog is in the plans or not. Time will tell.] |
I just noticed that in build 17110 there is a command |
@DDoSolitary. Not file, directory. |
@fpqc Well, I mean if I can create a files that only differ in case in directories marked as case sensitive with NtCreateFile. |
We've just put up a blog post covering per-directory case sensitivity. Check it out! |
@SvenGroot Are you discussing shell support with the shell team for the properties dialog? |
Curious if they're getting the IEEE 1003.1-2008 band back together. Been a while since |
Hmmm. No joy looking at
" You can probably spawn But don't. You've put a lot of effort into the project (and props for that), but the right way to unpack the thing is with a static ELF tar on the WSL side, just like the guys in the Premier League are doing it. |
@therealkenc Well, it is the official way and a correct way but it's not necessarily the only correct way. I don't want to use it because it forces me to edit the registry only for runtime configuration and distribute bsdtar with my binary. Also, my current way makes features like |
I've made a program which can set the case sensitivity. @therealkenc The
You can find the full code in WSL_Reverse. |
In the 17095 WDK Insider Preview :
|
Be fun to throw a buffer at |
@therealkenc Could that be something they are introducing to support ext4 mounting in WSL, or maybe a thing for like vmware to implement WSL support in their shared drive driver? It seems weird that it would be in the driver kit. Like, you could imagine that is an interface for driver writers to make their linux-style metadata read by the driver and then forwarded into this WSL attribute? |
@fpqc May be ext4 mounting is not implemented. When |
@Biswa96 It looks like an interface for fs driver writers to make their devices available in WSL, whatever it is. |
Sort of. That enum is userspace facing (also kernel facing too, of course). What's happened is someone writing a NT filesystem driver can now implement Anything has access to NTFS has access to "WSL" of course. DrvFs and LxFs aren't materially that different these days, notwithstanding the (important) fact that with LxFs some state appears to live in the WSL drivers and is thus not accessible to (let's call) the the Windows side. There are other loose ends. Symlinks are always going to be tricky, because the POSIX filesystem semantics and the NT filesystem semantics are still different enough to matter, for example. There are certainly other loose ends and details too. There are a couple of hints in the two blog posts. From the first blog:
And the second:
The first makes DrvFs slower than they'd probably like. The second is a limitation they'd probably rather not have. Liking and getting are different things though. |
@therealkenc I guess, but I/O perf on lxfs isn't anything to read or write home about either. I understand that performance on DrvFS is worse than lxfs because it doesn't cache inodes (I think this is what you were referring to), but I wonder what the big bottleneck in lxfs is (and how much meddling in other parts of Windows they'll be allowed to do to improve it). Have you done any private investigations? |
I have been holding off for two years on asking about that. There has to be a "reason" (good or otherwise), I just haven't quite figured it out. Russ (when he was around) used to allude to the problem but never tipped enough info to tell for sure. There are various things you can cache (dentries, data), and we know lxfs does cache stuff. One big difference brought up a lot is *unix filesystems can |
The 1003.1 band is still going. IEEE 1003.1 is at 2017 now, not 2008, and 202x and 203x are on the horizon. Due to procedural requirements the fixes for some known issues can't be made part of the base until the 203x edition. So mode_t can remain able to be typedef'd as short, as that is how some older file systems still supported by some platforms store it on media, it will not be adding bits for 202x. This has been discussed a few times. What the stat struct might get in 202x is new required or optional fields, but presently there is no existing practice I'm aware of, by Microsoft or any other company, suitable for basing a proposal on. So it getting any extensions, like for case insensitivity support, is doubtful. This is partly why the stat struct definition, and mode_t, has been static since the 2001 edition. What practice has been implemented by various file systems and platforms is more of the "works for me" variety instead. The FileStatLxInformation control and FILE_STAT_LX_INFORMATION struct are specific to the two MS file systems, but no one else's, as example of "works for MS". The same applies to how various Unix/Linux-specific file systems implement features like xattrs or alternate data streams; it isn't just an MS thing. |
I was being sardonic (my bad; that doesn't always come across well in prose).
Correct.
Also correct. But YRMV. |
Does the Insider SDK has that FILE_STAT_LX_INFORMATION struct definition? |
@Biswa96 |
|
That's the issue, people's results vary, in features and reliability; so it's difficult to say any of them is a standard platforms have to support. |
So, one has not to add the EA value with FILE_FULL_EA_INFORMATION struct. As the documentation says:
Just set This may be useful for @DDoSolitary DDoSolitary/LxRunOffline#36 |
@Biswa96 yes, it's definitely useful. It means no more NtQuery/SetEaFile and its opaque EA data structure. I believe I can use FILE_STAT_LX_INFORMATION and NtQuery/SetInformationFile to access WSL's filesystem information if they work as expected. |
I'm closing this issue because MS has provided fine-grained case sensitivity settings. (I just tried it out and |
Might as well. But I'd sure still appreciate an answer to the original question. Which paraphrasing is: How did WSL implement case sensitivity in LxFS prior to the per-directory case sensitivity flags, on a system where
But of course, on most people's systems, it it is set to |
WSL used to use a mechanism that allowed us to override the ObCaseInsensitive registry key on a per-thread basis. This option is highly locked down, and cannot be used by normal applications. Even WSL had to do a number of mitigations to avoid security problems, such as not allowing the use of case sensitivity in the root of a drive. Even then, it was not fool proof, and that's why we eventually abandoned this approach. Now that WSL no longer requires it, we will probably remove per-thread case sensitivity from the system, because there is no way to use it safely. |
And it wouldn't be. It would be used by a filter driver. What is the mechanism? |
The mechanism is undocumented, unsafe to use, and will probably be removed in the future. Attempting to use it, even if it was a public API, would be extremely unwise. That's all I'll say about it, sorry. :) |
No that's not where the mechanism lives. Anyway Sven, do appreciate the reply. |
@therealkenc Here are your sweets, extracted from LxCore.sys. These may override the registry "per-thread-basis": BOOLEAN LxpDrvFsEnableCaseSensitivityIfNeeded(int a1, int a2) {
int ThreadInformation = 1;
if ( !(*(_DWORD *)(a1 + 48) & 8) || *(_DWORD *)(a1 + 80) || a2 && a2 == *(_QWORD *)(*(_QWORD *)(a1 - 112) + 48i64) )
return FALSE;
ZwSetInformationThread(handle, (THREADINFOCLASS)43, &ThreadInformation, sizeof(int));
return TRUE;
}
NTSTATUS LxpDrvFsRestoreCaseSensitivity(BOOLEAN var) {
if (var) {
int ThreadInformation = 0;
NTSTATUS result = ZwSetInformationThread(handle, (THREADINFOCLASS)43, &ThreadInformation, sizeof(int));
}
return result;
} Also there are other two registry values, seems to be interesting: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"NtfsEnableDirCaseSensitivity"=dword:1
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
"obcaseinsensitive"=dword:1
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\lxss]
"DrvFsAllowForceCaseSensitivity"=dword:1 |
Nice work, impressive 🏆. That But for now I think I'm going to heed Sven's warning that (I'm paraphrasing here): "Ken, the thing is fragile as ****. I can barely keep it afloat myself and I work here 50 hours a week and I have access to all the source code. Only some kind of idiot would try." I'm willing to take his word for it. 😏 |
|
It's in
Sorry I misread the question. |
Correct, mostly, about not being in ntdll but it starts there. The guts is split between *krnl and file system .sys drivers, apparently. Somewhere, based on a header grep of "SENSITIVE", !OBJ_CASE_INSENSITIVE passed into Zw/NtCreate/OpenFile gets converted to FO_OPENED_CASE_SENSITIVE and driver specific flags in Irps for the file system driver to process appropriately, as a request based consideration that might take into account symbolic roots in the registry or not, not stored on the filesystem with a FO_CREATED_CASE_SENSITIVE (sic) or equivalent private flag. This is obfuscated further with the client Create/OpenFile routines which interface through ntdll calling it FILE_FLAG_POSIX_SEMANTICS, not using anything *SENSITIVE, and not fully implementing in the kernel what the term "POSIX semantics" entails. There are unaddressed issues besides case sensitivity; how many I couldn't really say. |
Previous discussion:
#449 (comment)
#449 (comment)
#449 (comment)
#449 (comment)
Per-process control of case-sensitivity really helps program that wants to interact with WSL's file system.
The text was updated successfully, but these errors were encountered: