Skip to content

ls: On Windows don't display files hidden by NTFS#1662

Merged
sylvestre merged 11 commits intouutils:masterfrom
DiegoMagdaleno:master
Dec 19, 2020
Merged

ls: On Windows don't display files hidden by NTFS#1662
sylvestre merged 11 commits intouutils:masterfrom
DiegoMagdaleno:master

Conversation

@DiegoMagdaleno
Copy link
Contributor

@DiegoMagdaleno DiegoMagdaleno commented Dec 18, 2020

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:
image

As you may see, there are some files named:
NTUSER.DAT{fa492542-3fc7-11eb-9272-e44a63569703}.TM.blf, etc

That are supposed to be hidden under the NTFS filesystem, after the patch:
image

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

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
Copy link
Contributor

@sylvestre sylvestre left a comment

Choose a reason for hiding this comment

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

Looks great!
Could you please fix the fix comments and and add a test tests/by-util/test_ls.rs here?

@DiegoMagdaleno
Copy link
Contributor Author

Im in progress of writing the tests

@DiegoMagdaleno
Copy link
Contributor Author

@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

@DiegoMagdaleno
Copy link
Contributor Author

I need fix some issues with UNIX.

Copy link
Contributor

@sylvestre sylvestre left a comment

Choose a reason for hiding this comment

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

Just some last nit. Thanks!

@sylvestre
Copy link
Contributor

Excellent, thanks!

@ajkessel
Copy link

ajkessel commented Dec 2, 2023

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?

@sylvestre
Copy link
Contributor

0.0.17 is pretty old. Could you please try with a more recent version?

@DiegoMagdaleno
Copy link
Contributor Author

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.

@ajkessel
Copy link

ajkessel commented Dec 2, 2023

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.

@tertsdiepraam
Copy link
Collaborator

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.

@ajkessel
Copy link

ajkessel commented Dec 2, 2023

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.

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.

4 participants