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

Fix trailing backslash in path of GetFileInformation()/OpenDirectory() call during SetAccessControl() #49

Closed
viciousviper opened this issue Aug 29, 2015 · 3 comments

Comments

@viciousviper
Copy link

When calling SetAccessControl() on a DirectoryInfo instance in C# the call sequence executed on a mounted IDokanOperationsProxy contains several calls with a redundant trailing backslash character:

OpenDirectory ("\Dir***", ...)
GetFileInformation ("\Dir***
",...)
Cleanup ("\Dir***", ...)
CloseFile ("\Dir***
", ...)

This is the only known case where dokany calls the IDokanOperationsProxy with a trailing backslash in the filename (actually a directory name). Even in the same call sequence all other methods use the directory name without the trailing slash.
Please change the call pattern so that all file/directory paths are consistently named without a trailing backslash - with the exception of the root directory path \.

See below for the full call sequence taken from a trace of the test DirectoryInfoTest.SetAccessControl_CallsApiCorrectly() in the DokanNet.Tests project.
Relevant filenames are emphasized in bold.

CreateFile[1] ("", ..)
GetFileInformation[1] ("", ...)
Cleanup[1] ("", ...)
CloseFile[0] ("", ...)
CreateFile[1] ("\Dir", ...)
GetFileInformation[1] ("\Dir", ...)
CreateFile[2] ("", ...)
GetFileInformation[2] ("", ...)
GetFileSecurity[2] ("", ...)
Cleanup[2] ("", ...)
CloseFile[1] ("", ...)
GetFileInformation[1] ("\Dir", ...)
GetFileSecurity[1] ("\Dir", ...)
OpenDirectory[2] ("\Dir", ...)
GetFileInformation[2] ("\Dir", ...)
Cleanup[2] ("\Dir", ...)
CloseFile[1] ("\Dir", ...)
OpenDirectory[2] ("\Dir", ...)
GetFileInformation[2] ("\Dir", ...)
Cleanup[2] ("\Dir", ...)
CloseFile[1] ("\Dir", ...)
SetFileSecurity[1] ("\Dir", ..)
OpenDirectory[2] ("\Dir", ..)
GetFileInformation[2] ("\Dir", ..)
Cleanup[2] ("\Dir", ...)
CloseFile[1] ("\Dir", ...)
OpenDirectory[2] ("\Dir", ...)
GetFileInformation[2] ("\Dir", ...)
Cleanup[2] ("\Dir", ...)
CloseFile[1] ("\Dir", ...)
Cleanup[1] ("\Dir", ...)
Waiting for closure (#1)
CloseFile[0] ("\Dir", ...)

@Liryna
Copy link
Member

Liryna commented Aug 29, 2015

This should make the work.
(I was not able to reproduce the "\Dir" to test).

@Maxhy
Copy link
Member

Maxhy commented Sep 7, 2015

@Liryna The changes are wrong.
Among other things it breaks directory rename when the directory is located at root drive.

@Maxhy Maxhy reopened this Sep 7, 2015
@Maxhy
Copy link
Member

Maxhy commented Sep 7, 2015

Reverted the 'empty filename change' only which was a wrong fix and cause the new bug, with commit 4496617.

@Maxhy Maxhy closed this as completed Sep 7, 2015
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

3 participants