PyFilesystem / pyfilesystem

Python filesystem abstraction layer
http://pyfilesystem.org/
BSD 3-Clause "New" or "Revised" License
288 stars 63 forks source link

dokan unmount failed on windows7 #274

Open Pagliacii opened 7 years ago

Pagliacii commented 7 years ago

OS: windows7 x64 Python: 2.7(32bit) Pyfilesystem: 0.5.5a1 Dokan: 1.0.3 x64

>>> from fs.expose import dokan
>>> from fs.memoryfs import MemoryFS
>>> memfs = MemoryFS()
>>> dokan.mount(memfs, 'Q:\\')
<fs.expose.dokan.MountProcess object at 0x02784350>
>>> dokan.unmount('Q:\\')
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "C:\Python27\lib\site-packages\fs\expose\dokan\__init__.py", line 1107, in _do_mount
    mount(fs, path, **opts)
  File "C:\Python27\lib\site-packages\fs\expose\dokan\__init__.py", line 1009, in mount
    res = libdokan.DokanMain(ctypes.byref(opts), ctypes.byref(opstruct))
WindowsError: exception: access violation reading 0x0000004A
>>>

Anything wrong?

Rondom commented 7 years ago

@Liryna Do you have a clue?

Liryna commented 7 years ago

@Pagliacii @Rondom need to see if the correct dokan1.dll x86 is used since python 32bit is used here. I used the same code and never faced this 😢 otherwise would need more log to see what is happening.

Pagliacii commented 7 years ago

The dokan x86 could not be installed on x64 PC. When I use dokan.unmount in python 64 bit, it worked correctly.

Liryna commented 7 years ago

@Pagliacii Good to know it worked ! In case of, the x86 dokan1.dll is in the x64 package under the folder C:\Program Files\Dokan\ x86

Pagliacii commented 7 years ago

@Liryna Okay, I will try it next Monday! Thanks for your help!

Rondom commented 7 years ago

But then things should either work when it finds the DLL or not work when it does not find the DLL. If it crashes, it is a bug, isn't it?

Liryna commented 7 years ago

DLL has to be a side to side to the python project.

If it does not find it, there is an error at the start. If a dll is found x86 / x64, it will run. But if a different arch (python / dll) is used, you will get a crash at a moment.

I do not know if there is a way for python to tell if the dll is x86 or x64 before to load it.

Pagliacii commented 7 years ago

@Liryna How could I tell the python 32bit to find the x86 dokan1.dll? By the environment variable DokanLibrary1?

In my computer, I try to set the DokanLibrary1 as 'C:\Program Files\Dokan\x86', but it raised the windows error again.

And it could work correctly in python 64 bit.

>>> os.environ['DokanLibrary1']
'C:\\Program Files\\Dokan\\x86'
Pagliacii commented 7 years ago

@Liryna The access violation reading error happened when I try to unmount the virtual disk on python 32 bit with the x86 dokan1.dll in win7 x86.

I don't have another x86 pc to test the unmount, so I not sure that something wrong in x86 dokan1.dll.

Liryna commented 7 years ago

😢 would be interesting to know what is happening.

Pagliacii commented 7 years ago

I'm not familiar with the ctypes module, so I don't have any idea.