ls: On Windows don't display files hidden by NTFS#1662
ls: On Windows don't display files hidden by NTFS#1662sylvestre merged 11 commits intouutils:masterfrom DiegoMagdaleno:master
Conversation
This little check, allows us to hide the files that shoulnd't be shown on the listing on Windows operating systems. Just like the "dot" in UNIX based operating systems Windows uses its own file attributes to determine if a file is hidden or not. The lack of support for this option is normally an annoyance for many users, this commit adds full support for this feature
sylvestre
left a comment
There was a problem hiding this comment.
Looks great!
Could you please fix the fix comments and and add a test tests/by-util/test_ls.rs here?
This also fixes a logic error in the if statement for Windows operating systems
|
Im in progress of writing the tests |
|
@sylvestre I was thinking on maybe a way to do not duplicate the code would to pass change the "name.starts_with()" result, and implement this check in the "is_hidden" function, so if the name starts with a dot gets hidden, and then perform the windows check without issues |
|
I need fix some issues with UNIX. |
sylvestre
left a comment
There was a problem hiding this comment.
Just some last nit. Thanks!
|
Excellent, thanks! |
|
Should this work now on WSL? I just tested ls from rust-coreutils-0.0.17 on WSL/Ubuntu and am still seeing Windows system and hidden files. Am I doing something wrong? |
|
0.0.17 is pretty old. Could you please try with a more recent version? |
|
This was never designer to work on WSL, as that's the Linux version, the mount is done via 9P filesystem and I don't think that sends the necessary metadata to tell if a file is hidden or not. |
|
This was mentioned as a WSL feature request above. It creates problems for certain system/hidden files on the host drive to show up in WSL. Where would we go to fix this? Is it a Microsoft/WSL issue? Interestingly, though, vanilla ls gives several "permission denied" errors when pointed at /mnt/c, while rust ls just shows the files with error. |
|
WSL is not something we "explicitly support", I think. Basically, the WSL version of uutils is the Linux version, so it's up to microsoft to make WSL act like Linux such that the Linux version of uutils works correctly. However, if there is some non-WSL specific difference with GNU that's uncovered because of this, we should fix that. |
|
Is gnu ls attempting to access some aspect of these system files that uutils ls is not? I can think of any other reason why I'd get an "access denied" error on a directory listing with GNU but not uutils. |
This little check, allows us to hide the files that
shouldn't be shown on the listing on Windows operating
systems.
Just like the "dot" in UNIX based operating systems
Windows uses its own file attributes to determine if a file
is hidden or not.
The lack of support for this option is normally an annoyance
for many users, this commit adds full support for this feature.
Here is a little example of this issue:
Before the patch:

As you may see, there are some files named:
NTUSER.DAT{fa492542-3fc7-11eb-9272-e44a63569703}.TM.blf, etcThat are supposed to be hidden under the NTFS filesystem, after the patch:

As you can see, the files are now properly hidden, allowing for a much cleaner user experience, that fits right into the operating system.
This annoyance is pretty normal, among Windows users and has been requested on other coreutils projects:
´
Example with git bash
Feature request on WSL