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

Can't distinguish between directory's link and single file's link on smb2 #203

Open
hengwu0 opened this issue Jun 19, 2021 · 1 comment
Open

Comments

@hengwu0
Copy link

hengwu0 commented Jun 19, 2021

The smb2_type only have 3 values:

#define SMB2_TYPE_FILE      0x00000000
#define SMB2_TYPE_DIRECTORY 0x00000001
#define SMB2_TYPE_LINK      0x00000002

it is not enough for Caller to get the file's attributes. For example, a directory's link file is SMB2_TYPE_LINK, and an normal file's link file is also SMB2_TYPE_LINK too! It is hard for Caller to distinguish them. The code now is:

                if (fs->basic.file_attributes & SMB2_FILE_ATTRIBUTE_REPARSE_POINT) {
                        st->smb2_type = SMB2_TYPE_LINK;
                }

From code showed, smb2_type is getted from file_attributes, and file_attributes already saved all attributes. For example, it's value is (SMB2_FILE_ATTRIBUTE_REPARSE_POINT|SMB2_FILE_ATTRIBUTE_DIRECTORY)0x410 for a directory's link.
Let 'file_attributes' equal 'smb2_type', can help the Caller to get full information about the file in smb.

@hengwu0 hengwu0 changed the title Let 'file_attributes' equal 'smb2_type' Can't distinguish between directory's link and single file's link on smb2 Jun 19, 2021
@sahlberg
Copy link
Owner

sahlberg commented Jan 5, 2025

It is not that easy since windows will often not add the SMB2_FILE_ATTRIBUTE_DIRECTORY flag in the attributes for reparse points that point to a directory.
For example reparse points created with mklink on windows 2016 will not.

So the only reliable way to do this would be to stat() all links and see if they are a directory or not while reading the directory.

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

No branches or pull requests

2 participants