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

DokanUnmount() always fails #57

Closed
Corillian opened this issue Sep 15, 2015 · 15 comments
Closed

DokanUnmount() always fails #57

Corillian opened this issue Sep 15, 2015 · 15 comments

Comments

@Corillian
Copy link

I have not been able to find a way to call DokanUnmount() such that it actually succeeds. Not only that but dokanctl.exe /u M also fails. The only way I can unmount the drive is by executing dokanctl.exe /u M /f however DokanMain() still doesn't return and additional calls to DokanUnmount() also fail.

I am running a console application and DokanMain() is being called on its own thread with DOKAN_OPTION_KEEP_ALIVE | DOKAN_OPTION_DEBUG.

@Liryna
Copy link
Member

Liryna commented Sep 16, 2015

@Corillian
Copy link
Author

Here's the log from the Visual Studio debug console:

The thread 0x15bc has exited with code 0 (0x0).
SftpManager::Initialize() WSAStartup() succeeded
SftpManager::Initialize() libssh2 initialized
Dokan: debug mode on
device opened
mounted: M:\ -> \Volume{d6cc17c5-173a-4085-bce7-964f1e9f5de9}
###Create 0000
SftpOpenDirectory()
CreateFile status = 0
###QueryVolumeInfo 0000
SftpGetVolumeInformation()
###QueryVolumeInfo 0000
SftpGetVolumeInformation()
###Cleanup 0000
SftpCleanup()
###Close 0000
SftpCloseFile()
###Create 0001
   CreateDisposition 0x00000001
CreateFile status = -2
###Create 0002
   CreateDisposition 0x00000001
CreateFile status = -2
###Create 0003
SftpOpenDirectory()
CreateFile status = 0
###QueryVolumeInfo 0003
SftpGetVolumeInformation()
###QueryVolumeInfo 0003
SftpGetVolumeInformation()
###Create 0004
###Cleanup 0003
SftpCleanup()
###Create 0005
SftpOpenDirectory()
###Close 0003
SftpCloseFile()
CreateFile status = 0
SftpOpenDirectory()
CreateFile status = 0
###QueryVolumeInfo 0005
###QueryVolumeInfo 0004
SftpGetVolumeInformation()
SftpGetVolumeInformation()
###QueryVolumeInfo 0004
SftpGetVolumeInformation()
###QueryVolumeInfo 0005
SftpGetVolumeInformation()
###Create 0006
   CreateDisposition 0x00000001
CreateFile status = 0
###Cleanup 0004
###GetFileInfo 0006
SftpGetFileInformation()
SftpCleanup()
###Cleanup 0005
SftpCleanup()
###Create 0007
   CreateDisposition 0x00000001
CreateFile status = 0
###Close 0005
SftpCloseFile()
###Close 0004
SftpCloseFile()
###GetFileInfo 0007
SftpGetFileInformation()
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
###Cleanup 0006
SftpCleanup()
###Close 0006
SftpCloseFile()
###Cleanup 0007
SftpCleanup()
###Close 0007
SftpCloseFile()
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
First-chance exception at 0x0000000077064B62 (kernel32.dll) in SftpDrive.exe: 0x40010005: Control-C.

The thread 0xa80 has exited with code 0 (0x0).
The thread 0x1a40 has exited with code 0 (0x0).
SftpManager::Cleanup() libssh2 exited
SftpManager::Cleanup() WSACleanup()
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
The thread 0x4610 has exited with code 0 (0x0).
The thread 0x4ee8 has exited with code 0 (0x0).
The thread 0x4ed8 has exited with code 0 (0x0).
The thread 0x78c has exited with code 0 (0x0).
The thread 0x3fec has exited with code 0 (0x0).
The thread 0x4a18 has exited with code 0 (0x0).
DokanRemoveMountPoint M:\
DokanControl recieved DeviceName:\Volume{d6cc17c5-173a-4085-bce7-964f1e9f5de9}
send release
The thread 0x4670 has exited with code 0 (0x0).
The thread 0x4eac has exited with code 0 (0x0).
The program '[11540] SftpDrive.exe' has exited with code 0 (0x0).

I took the following steps:

  1. I executed the application as an x64 console application running on Windows 7 with Visual Studio 2013
  2. I entered console output to force the application to unmount the drive and exit. This is represented by the first block of DokanRemoveMountPoint failed log entries.
  3. I then executed .\dokanctl.exe /u M /f from an administrator powershell which returned:
mounter path C:\Program Files\Dokan\DokanLibrary\mounter.exe
driver path C:\WINDOWS\system32\drivers\dokan.sys
Unmount success: MUnmount status = 0
  1. The Dokan thread still hadn't exited so I tried executing some quit/unmount commands again. This is represented by the second block of DokanRemoveMountPoint failed log entries.
  2. I used ctrl + c to kill the console application. During application teardown, after main() returned, you get an unmount failure. After the unmount failure the DokainMain() thread is killed by the OS which is followed by an unmount success:
First-chance exception at 0x0000000077064B62 (kernel32.dll) in SftpDrive.exe: 0x40010005: Control-C.

The thread 0xa80 has exited with code 0 (0x0).
The thread 0x1a40 has exited with code 0 (0x0).
SftpManager::Cleanup() libssh2 exited
SftpManager::Cleanup() WSACleanup() <---- End of main()
DokanRemoveMountPoint M:
DokanRemoveMountPoint failed
<------------- DokainMain() thread is one of the following ------------->
The thread 0x4610 has exited with code 0 (0x0).
The thread 0x4ee8 has exited with code 0 (0x0).
The thread 0x4ed8 has exited with code 0 (0x0).
The thread 0x78c has exited with code 0 (0x0).
The thread 0x3fec has exited with code 0 (0x0).
The thread 0x4a18 has exited with code 0 (0x0).
<---------------------------------------------------------------------------------->
DokanRemoveMountPoint M:\
DokanControl recieved DeviceName:\Volume{d6cc17c5-173a-4085-bce7-964f1e9f5de9}
send release
The thread 0x4670 has exited with code 0 (0x0).
The thread 0x4eac has exited with code 0 (0x0).
The program '[11540] SftpDrive.exe' has exited with code 0 (0x0).

I'll try out Mirror.exe and enable more robust logging within the next few days.

@marinkobabic
Copy link
Contributor

Please can you use DebugView https://technet.microsoft.com/en-us/library/bb896647.aspx so that we can see, why the mounter service failed to delete the mount point.

@Liryna
Copy link
Member

Liryna commented Sep 28, 2015

Since we have no update from you @Corillian .

@Liryna Liryna closed this as completed Sep 28, 2015
@Corillian
Copy link
Author

I'm afraid my inactivity hardly means the problem is resolved. I have plenty of things to work on and am unable to devote all of my time to figuring out why this driver is hanging. To that end I have been unable to gather any debug output as my locally built copy of the driver fails to install with:

mounter path C:\Dokan\x64\Debug\mounter.exe
driver path C:\WINDOWS\system32\drivers\dokan.sys
driver install failedmounter install failed

I'm using the source tagged at v0.7.4. I followed your build/install instructions and I am running windows 7 x64 in allow unsigned drivers mode. I just noticed you released the pre-release for 0.8.0, I'll give that a try and see if I still have this problem.

@Corillian
Copy link
Author

Ok I got the install issues sorted out. It looks like my service was hung due to the inability to unmount Dokan, I hadn't explicitly killed the process, and to make a long story short when I ran the 0.7.4 uninstaller stuff got corrupted and created non-obvious issues. Unfortunately even though I now have my debug build of Dokan installed and running I am not getting any additional debug info in DebugView or my Visual Studio output window. I double checked HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Debug Print Filter property IHVDRIVER was set to 0xd, I ran bcdedit -debug on, dokanctl.exe /d 9 and I'm not getting any additional information.

@Liryna Liryna reopened this Sep 28, 2015
@Corillian
Copy link
Author

Alrighty I got the debug output. My WinDbg kernel capture was turned off. GitHub won't let me upload the log file but you can find it at http://pastebin.com/ZPqvk5a0. The major highlights are when I call DokanUnmount() I get the following output:

[DokanFS] ==> DokanDispatchIoControl
[DokanFS]   ProcessId 4828
[DokanFS]    => DokanGlobalDeviceControl
[DokanFS] DokanRegisterPendingIrpForService
[DokanFS] ==> DokanRegisterPendingIrpMain
[DokanFS] <== DokanRegisterPendingIrpMain
[DokanFS]    <= DokanGlobalDeviceControl
[DokanFS] => NotificationLoop
[DokanFS] <== DokanDispatchIoControl
[DokanFS] <= NotificationLoop
[DokanFS]   status = STATUS_SUCCESS

DokanUnmount() returns false and my Dokan thread continues to be hung in DokanMain(). When I manually unmount the drive with dokanctl.exe /u M /f I get:

[DokanFS] ==> DokanDispatchIoControl
[DokanFS]   ProcessId 4828
[DokanFS]    => DokanGlobalDeviceControl
[DokanFS] DokanRegisterPendingIrpForService
[DokanFS] ==> DokanRegisterPendingIrpMain
[DokanFS] <== DokanRegisterPendingIrpMain
[DokanFS]    <= DokanGlobalDeviceControl
[DokanFS] <== DokanDispatchIoControl
[DokanFS] => NotificationLoop
[DokanFS] <= NotificationLoop
[DokanFS] ==> ReleaseTimeoutPendingIRP
[DokanFS]   IrpQueue is Empty
[DokanFS]   status = STATUS_SUCCESS

which still doesn't cause DokanMain() to return and when I kill the process I get:

00001062    22.74924088 [DokanFS] DokanRegisterPendingIrpForService 
00001063    22.74924278 [DokanFS] ==> DokanRegisterPendingIrpMain   
00001064    22.74924469 [DokanFS] <== DokanRegisterPendingIrpMain   
00001065    22.74924850 [DokanFS]    <= DokanGlobalDeviceControl    
00001066    22.74924850 [DokanFS] <== DokanDispatchIoControl    
00001067    22.74925423 [DokanFS] => NotificationLoop   
00001068    22.74925995 [DokanFS] <= NotificationLoop   
00001069    24.00300598 [DokanFS]   status = STATUS_SUCCESS 
00001070    24.65510368 [DokanFS] ==> DokanIrpCancelRoutine 
00001071    24.65510750 [DokanFS]    canceled IRP #0    
00001072    24.65510750 [DokanFS] ==> DokanIrpCancelRoutine 
00001073    24.65511131 [DokanFS] <== DokanIrpCancelRoutine 
00001074    24.65511322 [DokanFS]    canceled IRP #0    
00001075    24.65511322 [DokanFS] ==> DokanIrpCancelRoutine 
00001076    24.65511513 [DokanFS] <== DokanIrpCancelRoutine 
00001077    24.65511513 [DokanFS]    canceled IRP #0    
00001078    24.65511703 [DokanFS] <== DokanIrpCancelRoutine 
00001079    24.65512466 [DokanFS] ==> DokanIrpCancelRoutine 
00001080    24.65512657 [DokanFS]    canceled IRP #0    
00001081    24.65512657 [DokanFS] <== DokanIrpCancelRoutine 
00001082    24.65513992 [DokanFS] ==> DokanIrpCancelRoutine 
00001083    24.65514183 [DokanFS]    canceled IRP #0    
00001084    24.65514374 [DokanFS] <== DokanIrpCancelRoutine 
00001085    24.65533257 [DokanFS] ==> DokanCleanup  
00001086    24.65533447 [DokanFS]   ProcessId 4376  
00001087    24.65533829 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001088    24.65534019 [DokanFS]   status = STATUS_SUCCESS 
00001089    24.65534210 [DokanFS] <== DokanCleanup  
00001090    24.65534401 [DokanFS] ==> DokanClose    
00001091    24.65534782 [DokanFS]   ProcessId 4376  
00001092    24.65534782 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001093    24.65534973 [DokanFS]   status = STATUS_SUCCESS 
00001094    24.65535164 [DokanFS] <== DokanClose    
00001095    24.65535355 [DokanFS] ==> DokanCleanup  
00001096    24.65535736 [DokanFS]   ProcessId 4376  
00001097    24.65535927 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001098    24.65536118 [DokanFS]    IdType = DCB   
00001099    24.65536118 [DokanFS]    ccb is NULL    
00001100    24.65536308 [DokanFS]   status = STATUS_SUCCESS 
00001101    24.65536690 [DokanFS] <== DokanCleanup  
00001102    24.65536880 [DokanFS] ==> DokanClose    
00001103    24.65537071 [DokanFS]   ProcessId 4376  
00001104    24.65537453 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001105    24.65537643 [DokanFS]    IdType = DCB   
00001106    24.65537643 [DokanFS]    ccb is NULL    
00001107    24.65537834 [DokanFS]   status = STATUS_SUCCESS 
00001108    24.65538025 [DokanFS] <== DokanClose    
00001109    24.65538406 [DokanFS] ==> DokanCleanup  
00001110    24.65538406 [DokanFS]   ProcessId 4376  
00001111    24.65538597 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001112    24.65538788 [DokanFS]    IdType = DCB   
00001113    24.65538979 [DokanFS]    ccb is NULL    
00001114    24.65538979 [DokanFS]   status = STATUS_SUCCESS 
00001115    24.65539360 [DokanFS] <== DokanCleanup  
00001116    24.65539551 [DokanFS] ==> DokanClose    
00001117    24.65539742 [DokanFS]   ProcessId 4376  
00001118    24.65539932 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001119    24.65539932 [DokanFS]    IdType = DCB   
00001120    24.65540314 [DokanFS]    ccb is NULL    
00001121    24.65540504 [DokanFS]   status = STATUS_SUCCESS 
00001122    24.65540504 [DokanFS] <== DokanClose    
00001123    24.65540695 [DokanFS] ==> DokanCleanup  
00001124    24.65541077 [DokanFS]   ProcessId 4376  
00001125    24.65541267 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001126    24.65541458 [DokanFS]    IdType = DCB   
00001127    24.65541458 [DokanFS]    ccb is NULL    
00001128    24.65541649 [DokanFS]   status = STATUS_SUCCESS 
00001129    24.65542030 [DokanFS] <== DokanCleanup  
00001130    24.65542030 [DokanFS] ==> DokanClose    
00001131    24.65542221 [DokanFS]   ProcessId 4376  
00001132    24.65542412 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001133    24.65542603 [DokanFS]    IdType = DCB   
00001134    24.65542603 [DokanFS]    ccb is NULL    
00001135    24.65542984 [DokanFS]   status = STATUS_SUCCESS 
00001136    24.65542984 [DokanFS] <== DokanClose    
00001137    24.65543175 [DokanFS] ==> DokanCleanup  
00001138    24.65543365 [DokanFS]   ProcessId 4376  
00001139    24.65543365 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001140    24.65543365 [DokanFS]    IdType = DCB   
00001141    24.65543556 [DokanFS]    ccb is NULL    
00001142    24.65543556 [DokanFS]   status = STATUS_SUCCESS 
00001143    24.65543938 [DokanFS] <== DokanCleanup  
00001144    24.65543938 [DokanFS] ==> DokanClose    
00001145    24.65544128 [DokanFS]   ProcessId 4376  
00001146    24.65544319 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001147    24.65544319 [DokanFS]    IdType = DCB   
00001148    24.65544319 [DokanFS]    ccb is NULL    
00001149    24.65544701 [DokanFS]   status = STATUS_SUCCESS 
00001150    24.65544701 [DokanFS] <== DokanClose    
00001151    24.65544891 [DokanFS] ==> DokanCleanup  
00001152    24.65544891 [DokanFS]   ProcessId 4376  
00001153    24.65545082 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001154    24.65545273 [DokanFS]    IdType = DCB   
00001155    24.65545273 [DokanFS]    ccb is NULL    
00001156    24.65545273 [DokanFS]   status = STATUS_SUCCESS 
00001157    24.65545654 [DokanFS] <== DokanCleanup  
00001158    24.65545654 [DokanFS] ==> DokanClose    
00001159    24.65545845 [DokanFS]   ProcessId 4376  
00001160    24.65545845 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001161    24.65546036 [DokanFS]    IdType = DCB   
00001162    24.65546036 [DokanFS]    ccb is NULL    
00001163    24.65546227 [DokanFS]   status = STATUS_SUCCESS 
00001164    24.65546227 [DokanFS] <== DokanClose    
00001165    24.65546608 [DokanFS] ==> DokanCleanup  
00001166    24.65546608 [DokanFS]   ProcessId 4376  
00001167    24.65546799 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001168    24.65546799 [DokanFS]    IdType = DCB   
00001169    24.65546989 [DokanFS]    ccb is NULL    
00001170    24.65546989 [DokanFS]   status = STATUS_SUCCESS 
00001171    24.65547180 [DokanFS] <== DokanCleanup  
00001172    24.65547180 [DokanFS] ==> DokanClose    
00001173    24.65547562 [DokanFS]   ProcessId 4376  
00001174    24.65547562 [DokanFS]   FileName: (null) FCB.FileName: (null)   
00001175    24.65547752 [DokanFS]    IdType = DCB   
00001176    24.65547752 [DokanFS]    ccb is NULL    
00001177    24.65547943 [DokanFS]   status = STATUS_SUCCESS 
00001178    24.65547943 [DokanFS] <== DokanClose    
00001179    25.93808556 [DokanFS] ==> ReleaseTimeoutPendingIRP  
00001180    25.93810654 [DokanFS]   IrpQueue is Empty   
00001181    30.93859482 [DokanFS] ==> ReleaseTimeoutPendingIRP  
00001182    30.93859863 [DokanFS]   IrpQueue is Empty   
00001183    35.93759537 [DokanFS] ==> ReleaseTimeoutPendingIRP  
00001184    35.93759918 [DokanFS]   IrpQueue is Empty   
00001185    40.93784332 [DokanFS] ==> ReleaseTimeoutPendingIRP  
00001186    40.93784332 [DokanFS]   IrpQueue is Empty   
00001187    40.93785095 [DokanFS]   Timeout, force to umount    
00001188    40.93785095 [DokanFS] ==> DokanUnmount  
00001189    40.93785477 [DokanFS]   Send Unmount to Service : \Volume{d6cc17c5-1731-4085-bce7-964f1e9f5de9} 
00001190    40.93786621 [DokanFS] => NotificationLoop   
00001191    40.93787003 [DokanFS] ==> DokanStopCheckThread  
00001192    40.93787003 [DokanFS]   status = STATUS_SUCCESS 
00001193    40.93787384 [DokanFS] <= NotificationLoop   
00001194    40.93787384 [DokanFS] <== DokanStopCheckThread  
00001195    40.93787384 [DokanFS] ==> DokanStopCheckThreadInternal  
00001196    40.93787384 [DokanFS] ==> DokanStopEventNotificationThread  
00001197    40.93787766 [DokanFS] <== DokanStopEventNotificationThread  
00001198    40.93788528 [DokanFS]   Delete Symbolic Name: \DosDevices\Global\Volume{d6cc17c5-1731-4085-bce7-964f1e9f5de9}   
00001199    40.93789673 [DokanFS]   FCB allocated: 8    
00001200    40.93789673 [DokanFS]   FCB     freed: 8    
00001201    40.93789673 [DokanFS]   CCB allocated: 9    
00001202    40.93789673 [DokanFS]   CCB     freed: 9    
00001203    40.93790436 [DokanFS]   Delete DeviceObject 
00001204    40.93790817 [DokanFS]   Delete Disk DeviceObject    
00001205    40.93790817 [DokanFS] <== DokanUnmount  
00001206    40.93791199 [DokanFS]   DokanTimeoutThread catched KillEvent    
00001207    40.93791199 [DokanFS] ==> DokanStopEventNotificationThreadInternal  
00001208    40.93791199 [DokanFS] <== DokanTimeoutThread    
00001209    40.93798828 [DokanFS] <== DokanStopCheckThreadInternal  
00001210    40.93799591 [DokanFS] <== NotificationThread    
00001211    40.93799973 [DokanFS] <== DokanStopEventNotificationThreadInternal  
00001212    40.93812943 [DokanFS] ==> DokanDispatchIoControl    
00001213    40.93813324 [DokanFS]   ProcessId 4828  
00001214    40.93813324 [DokanFS]    => DokanGlobalDeviceControl    
00001215    40.93813324 [DokanFS] DokanRegisterPendingIrpForService 
00001216    40.93814087 [DokanFS] ==> DokanRegisterPendingIrpMain   
00001217    40.93814087 [DokanFS] <== DokanRegisterPendingIrpMain   
00001218    40.93814087 [DokanFS]    <= DokanGlobalDeviceControl    
00001219    40.93814468 [DokanFS] <== DokanDispatchIoControl    

I hope that helps, let me know if there's anything else I can assist with.

@Liryna
Copy link
Member

Liryna commented Sep 28, 2015

Good to have news from you :) !!!
Thanks for the logs but for me it seems to be ok
my service was hung due to the inability to unmount Dokan
You think the thread is lock somewhere ?

Just to be sure I understand well:
dokanctl.exe /u M /f does make your device disapear from your computer ?
if DokainMain does not return, it mean some thread are still running.
DokanUnmount() returns false DokanUnmount call DokanRemoveMountPoint and DokanMountControl
https://github.com/dokan-dev/dokany/blob/master/dokan/mount.c#L122

If you can add some logs and see where it fail and why, it would be nice !

Sorry for taking your time but you are the only personn who has repport this issue 😢

@marinkobabic
Copy link
Contributor

The log obove is provided by driver and not by mounter service we are interested in.

@Corillian
Copy link
Author

@marinkobabic I don't have any mounter service output beyond:

[17816] Service (DokanMounter) installed
[17816] Service (DokanMounter) started

@Corillian
Copy link
Author

Ok I have discovered why the call to DokanUnmount() is failing. My code does the following:

if(!DokanUnmount(m_localDriveRoot[0])) // m_localDriveRoot[0] resolves to L'M'

at which point DokanUnmount() does the following:

BOOL DOKANAPI
DokanUnmount(
    WCHAR   DriveLetter)
{
    WCHAR mountPoint[] = L"M:";  // <--- FAIL
    mountPoint[0] = DriveLetter; // <--- FAIL
    return DokanRemoveMountPoint(mountPoint);
}

The issue is that the Dokan mounter service expects the drive name to be formatted as M:\ and when it isn't FindMountEntry() is unable to locate the mounted drive:

for (listEntry = g_MountList.Flink; listEntry != &g_MountList; listEntry = listEntry->Flink) {
        mountEntry = CONTAINING_RECORD(listEntry, MOUNT_ENTRY, ListEntry);
        if (useMountPoint) {
            if (wcscmp(DokanControl->MountPoint, mountEntry->MountControl.MountPoint) == 0) { // <--- FAIL
                found = TRUE;
                break;
            }
        } else {
            if (wcscmp(DokanControl->DeviceName, mountEntry->MountControl.DeviceName) == 0) {
                found = TRUE;
                break;
            }
        }
    }

dokanctl.exe also has the same problem unless the user correctly supplies the mount point in the format C:\:

control.Type = DOKAN_CONTROL_UNMOUNT;
control.Option = DOKAN_CONTROL_OPTION_FORCE_UNMOUNT;
wcscpy_s(control.MountPoint, sizeof(control.MountPoint) / sizeof(WCHAR), MountPoint); // <--- POSSIBLE FAIL
DokanMountControl(&control);

however dokanctl.exe would still succeed in unmounting the drive because of the /f flag which causes mounter.exe to attempt to unmount a mount point even if it can't be located:

DbgPrintW(L"DokanControl MountEntry not found. Try unmount '%s' force: %d\n", Control->MountPoint, Control->Option);
if (Control->Option == DOKAN_CONTROL_OPTION_FORCE_UNMOUNT && DokanControlUnmount(Control->MountPoint)) {
    Control->Status = DOKAN_CONTROL_SUCCESS;
    break;
}

Now that DokanUnmount() succeeds my call to DokanMain() properly returns DOKAN_SUCCESS. I don't understand why .\dokanctl.exe /u M /f did not cause DokanMain() to return before so it seems likely there's still a problem with unmounting somewhere. A pull request will be forthcoming shortly.

@Liryna
Copy link
Member

Liryna commented Sep 29, 2015

Oh this part of the code has been changed not so long time ago.
Have you seen a28a915 and #14 ?

@Corillian
Copy link
Author

Ok this is a bit frustrating. The documentation explicitly states that when mounting I should use a drive letter formatted as M:\ or a path (which it shows without a trailing \):

   typedef struct _DOKAN_OPTIONS {
       USHORT  Version;  // Supported Dokan Version, ex. "530" (Dokan ver 0.5.3)
       ULONG   ThreadCount;  // number of threads to be used
       ULONG   Options;  // combination of DOKAN_OPTIONS_*
       ULONG64 GlobalContext;  // FileSystem can use this variable
       LPCWSTR MountPoint;  // mount point "M:\" (drive letter) or
                            // "C:\mount\dokan" (path in NTFS)
   } DOKAN_OPTIONS, *PDOKAN_OPTIONS;

That's it, that's all there is for documentation right there. For unmounting the docs mention File system can be unmounted by calling the function DokanUnmount or DokanRemoveMountPoint. - nothing else. Commit a28a915 broke DokanUnmount() for what the documentation says is the proper mount point format which is what caused me all of these problems. DokanUnmount() should have just been removed if it is no longer an acceptable way of unmounting. Either way the documentation definitely should have been updated to highlight DokanRemoveMountPoint() as the preferred method and why.

On top of that, commit a28a915 still doesn't solve the root problem: Dokan isn't normalizing mount paths. This is a major issue and if you noticed in my description above .\dokanctl.exe /u is also broken unless you type, letter for case-sensitive letter, the exact string for the mount path. My commit provides some normalizing sanity if your mount path is nothing more than a drive letter. It fixes both DokanUnmount() and .\dokanctl.exe /u for any mount path that is formatted as M, M:, or M:\.

To summarize: Dokan should normalize mount paths and I suspect, at least for single letter drive mounts, it should also be case-insensitive.

@Liryna
Copy link
Member

Liryna commented Oct 1, 2015

@Corillian, Yes I see your point !
I totally agree about you idea to normalizing mount paths.
(I continue the discution in your PR)

@Liryna
Copy link
Member

Liryna commented Oct 10, 2015

Fixed with #79

@Liryna Liryna closed this as completed Oct 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants