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

Symlinks information is not displayed on a "dir" command #380

Closed
hammerg opened this issue Aug 8, 2021 · 3 comments
Closed

Symlinks information is not displayed on a "dir" command #380

hammerg opened this issue Aug 8, 2021 · 3 comments
Assignees

Comments

@hammerg
Copy link
Contributor

hammerg commented Aug 8, 2021

When running a "dir" command on a NTFS directory, a symlink entries include information (the fact that this is a symlink and where it points to) for example:

C:\Temp\1>dir
 Volume in drive C has no label.
 Volume Serial Number is 721B-C4C3

 Directory of C:\Temp\1

08/08/2021  03:18 PM    <DIR>          .
08/08/2021  03:18 PM    <DIR>          ..
08/08/2021  03:17 PM                24 1.txt
08/08/2021  03:18 PM    <SYMLINK>      2.txt [1.txt]
               2 File(s)             24 bytes

However when using WinFsp's memfs with the same symlink the display doesn't include the extra information:

M:\>dir
 Volume in drive M is MEMFS
 Volume Serial Number is 1720-5D87

 Directory of M:\

08/08/2021  03:22 PM                24 1.txt
08/08/2021  03:22 PM                 0 2.txt
               2 File(s)             24 bytes

The "<SYMLINK>" and the "[1.txt]" are not shown.

I couldn't find where to add this information to the FSP_FSCTL_DIR_INFO in the ReadDirectory callback. Am I missing something or is it a WinFSP limitation?

Thanks in advanced, Gal.

@billziss-gh
Copy link
Collaborator

billziss-gh commented Sep 20, 2021

I have confirmed that this is the case.

After some research I have found that NTFS appears to use (abuse?) an unexpected field in the return from NtQueryDirectoryFile to communicate the reparse tag of a file (if any). This information is not documented anywhere in the NtQueryDirectoryFile documentation or even the IRP_MJ_DIRECTORY_CONTROL documentation (the latter being what file system drivers see when an NtQueryDirectoryFile is issued).

It turns out that NTFS returns the reparse tag in the EaSize field of directory information classes such as FILE_FULL_DIR_INFORMATION. This EaSize field is documented as: "combined length, in bytes, of the extended attributes (EA) for the file". Therefore the WinFsp FSD sets this to 0 when a file does not have extended attributes regardless if it is a reparse point or not (as sanity would suggest after reading the relevant documentation).

To fix this it looks like the FSD has to be modified to return the reparse tag in the EaSize field if a file/directory is a reparse point.

@billziss-gh
Copy link
Collaborator

Commit 3e66082 should fix this issue.

@billziss-gh
Copy link
Collaborator

This has now been merged into master. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants