-
Notifications
You must be signed in to change notification settings - Fork 63
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
Fixing dokan support discussion... #256
Comments
Somebody started working on updated Dokan support (#241 and #236) but I dunno if they ever got any further :-/ See also https://github.com/PyFilesystem/pyfilesystem/search?q=dokan&state=open&type=Issues |
Thanks for the ping, @lurch. Unfortunately that is currently at the very bottom of my TODO list, and lacking more experience with Dokan I doubt I can fix this on my own :( |
👍 I am willing to help on this ! I will try to take a look at it in the next days and see what changes should be made. |
It would be great to see working Dokan support in pyfilesystem again :-) |
I am willing to review pyfilesystem, especially documentation. But I am also looking forward to seeing Dokan working with pyfilesystem, tell me how can I help. @Liryna |
@arekbulski Ok, I just wanted to know if you planned to update the wrapper yourself. I began to update most of the natives commandes https://github.com/Liryna/pyfilesystem without implementing it
Where does the dllimport happen ? How to set library name ? |
You import windll from ctypes, which is a library loader. Member name is used as library name that is DLL name to be loaded. And for the library object, member name is used as function name. Simple example:
In your code Dokan is the library name, DokanMain/DokanVersion are imported functions. You might limit it to |
Thank you for your answer @arekbulski ❤️ |
I think so, one way to know for sure. |
Yes I will make the test 😃 |
I am currently able to start the mount of a dokan device with my last changes https://github.com/Liryna/pyfilesystem If someone could guide me, it would be nice ! https://github.com/dokan-dev/dokany/blob/master/dokan/dokan.h#L111 |
Throw it at Stack Overflow. I am not familiar enough with it. I do not understand why USHORT is not taken from c_ushort. |
Not surprised. There is no point in supporting dinosaur-old versions of Python. |
My bad, I found that all call work with dokan1.dll in Release mode and not in Debug as I was doing. CreateFile fail here https://github.com/Liryna/pyfilesystem/blob/master/fs/expose/dokan/__init__.py#L453 when
I am not familiar with fs api and the code seems to not have been updated since 3 years (dokan part). It there one of the pyfilesystem that could help me to review fs api calls ? |
Here is the isdir() from MemoryFS and normpath() that it uses. From what I read in these methods, fs objects require/expect paths formatted in their way. Notice that normpath does not recognize backslash at all. It is not recognized as one of ('..', '.', '') so it gets passed as a component, normpath('') should give '/' right? isdir('') will give False which will lead to further problems. https://github.com/Liryna/pyfilesystem/blob/master/fs/memoryfs.py#L321 |
👍 @arekbulski You are exactly right I had to add in all functions: I don't know if this is the best way but I am now able to run the test. I am just not able to write the test file and will look into this. |
Pull request created: #258 I am able to Create/Delete/List/Rename/Read/Write files without issues. |
Well, it is you who is doing all the hard work. I am just good at code analysis. 😃 |
A pleasure 👍 I always wanted dokan being compatible with python. |
That's correct - as far as pyfilesystem is concerned, a file named |
You are right |
No. As I already tried to explain, pyfilesystem has the concept of (abstract) "pyfilesystem paths", and (concrete) "system paths". It's kinda difficult to explain clearly, but it means that user-code making use of pyfilesystem is always identical, no matter what platform it's running on, and what the backend filesystem is. (and this is also why pyfilesystem has no 'current directory' concept, because some of the backend filesystems don't support that) |
All right 👍 , so If I understand correctly If not, I have no idea what to do since dokan directly send the path like that and there is no way to change it. |
I totally understand and agree with the concept behind abstract paths. However on Windows backslashes must be converted to a recognized separator or path splitting will lead to incorrect results. Remeber Dokan is Windows only. Btw windows syscalls work with slashes just as well as far I was told. |
I'm afraid I've never looked at any of the 'expose' classes in pyfilesystem, so maybe I'm getting confused between which paths are pyfilesystem-paths, and which paths are system-paths? :-S But anyway, IMHO it'd be much cleaner to have just a couple of functions that convert Dokan-paths to and from pyfilesystem-paths, and use those in each of the other functions; rather than sprinkling Given that you've updated all the docstrings to say that the Dokan class now supports mounting to an arbitrary path, rather than (just) a drive-letter, have you tested that? Does there need to be any code adding and removing this extra path-info from the Dokan-paths? (apologies if that's a stupid question, but I've never looked at dokan code) |
I have added the extract method to convert paths. |
I gave it a try just now, with a Python 2.7.11 (32 bit) on Windows 10 64 bit, and the mounting subprocess went wrong, Windows shows a dialog saying Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fs\expose\dokan\__init__.py", line 973, in mount
check_ready(mp)
File "fs\expose\dokan\__init__.py", line 943, in check_ready
check_alive(mp)
File "fs\expose\dokan\__init__.py", line 931, in check_alive
raise OSError("dokan mount process exited prematurely")
OSError: dokan mount process exited prematurely The code I tried is: import fs.memoryfs
import fs.expose.dokan
fs.memoryfs.__file__
s = fs.memoryfs.MemoryFS()
mp = fs.expose.dokan.mount(s, 'Q:\\') My dokan installation is I'm not sure whether it's a problem with my dokan installation or with your code. If I get a chance to reboot my computer I'll test again and let you know the result. |
Hi @JokerQyou , Did you copy the dokan1.dll from x86 folder (C:\Program Files\Dokan\x86) ? |
I tested again with >>> import fs.memoryfs
>>> import fs.expose
>>> s = fs.memoryfs.MemoryFS()
>>> mp = fs.expose.
>>> from fs.expose import dokan
>>> mp = dokan.mount(s, 'Q:')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fs\expose\dokan\__init__.py", line 923, in mount
_check_path_string(path)
File "fs\expose\dokan\__init__.py", line 896, in _check_path_string
raise ValueError("invalid path: %r" % (path,))
ValueError: invalid path: 'Q:'
invalid path: 'Q:'
>>> mp = dokan.mount(s, 'Q:\\')
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "fs\expose\dokan\__init__.py", line 1061, in _do_mount
mount(fs, path, **opts)
File "fs\expose\dokan\__init__.py", line 964, in mount
res = libdokan.DokanMain(ctypes.byref(opts), ctypes.byref(opstruct))
WindowsError: exception: access violation reading 0x00DF0000
KeyboardInterrupt And I tested again with no mistake typing letters. >>> import fs.memoryfs
>>> from fs.expose import dokan
>>> s = fs.memoryfs.MemoryFS()
>>> mp = dokan.mount(s, 'Z:\\')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fs\expose\dokan\__init__.py", line 973, in mount
check_ready(mp)
File "fs\expose\dokan\__init__.py", line 940, in check_ready
check_alive(mp)
File "fs\expose\dokan\__init__.py", line 931, in check_alive
raise OSError("dokan mount process exited prematurely")
OSError: dokan mount process exited prematurely
dokan mount process exited prematurely And this time the I was testing within an interactive shell, does that affect anything? |
That's very strange Can you try to run the mirror.exe in
This should not affect dokan. If I understood correctly it mount the device but something is making it umount. |
@lurch have you been able to test it ? |
Unfortunately not yet, been far too busy with other stuff :-( |
Dokan 1.0.0 has been released https://github.com/dokan-dev/dokany/releases/tag/v1.0.0 |
@JokerQyou I made a change on the pull request, do you think can you clone again and try to test it ? |
Sorry for not having followed up on this. I've been impacted by a layoff that has taken me offline from my original motivation. Still interested in this library and will Follow up as soon as I can...
Raymond
|
I'd like to give it a try but I've been too busy... And I cannot afford a system restart (I reinstalled dokan with development files but have not restarted my computer) now. I'll test it if I got time tonight (GMT+8). |
I moved on to Construct. Unsubscribing from this thread. Ping me if needed. 👋 |
Moving this comment to here to try to separate 'general discussion' from 'code comments'...
Sorry, I'm not sure what you're asking me for? I do appreciate all the hard work you and others have been putting into getting this working 👍 I've never written Win32 API code myself, but I understand how 'murky' it can be. OTOH if you wanted to modify the PR so that it can only be used to expose ReadOnly filesystems (see e.g. http://docs.pyfilesystem.org/en/latest/base.html#fs.base.FS.getmeta and http://docs.pyfilesystem.org/en/latest/wrapfs/readonlyfs.html ), and documented it as such, then that could probably be merged. (Which will then hopefully be 'upgraded' later on to allow full dokan read/write access when this security issue gets fixed) I hope that doesn't sound too harsh, I hope you can see where I'm coming from. I'm afraid I don't get as much time to look at pyfilesystem as I'd like, and from their lack of input I assume @willmcgugan and @rfk are even busier than I am :-/ |
Thanks @lurch. Sorry I haven't been keeping up with the work here. Not being a massive Windows user I'll need a little guidance here. If we're talking about fixes then I'm all for it. But I'm guessing its not as clear cut? |
I've managed to test directly with the whole repo cloned from @Liryna 's remote, and here's the result with memory fs. λ ptpython
>>> import fs.memoryfs
>>> import fs.expose
>>> fs
<module 'fs' from 'fs\__init__.py'>
>>> s = fs.memoryfs.MemoryFS()
>>> from fs.expose import dokan
>>> mp = dokan.mount(s, 'Q:')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fs\expose\dokan\__init__.py", line 957, in mount
_check_path_string(path)
File "fs\expose\dokan\__init__.py", line 929, in _check_path_string
raise ValueError("invalid path: %r" % (path,))
ValueError: invalid path: 'Q:'
invalid path: 'Q:'
>>> mp = dokan.mount(s, 'Q:\\')
>>> mp
<fs.expose.dokan.MountProcess object at 0x050FEBB0>
>>> s
MemoryFS()
>>> s.listdir()
[]
>>> s.listdirinfo()
[] At this time And I've also tried to created a new folder with And I used the following code to unmount the drive: >>> dokan.unmount('Q:\\')
>>> Traceback (most recent call last):
File "<string>", line 3, in <module>
File "fs\expose\dokan\__init__.py", line 1096, in _do_mount
mount(fs, path, **opts)
File "fs\expose\dokan\__init__.py", line 998, in mount
res = libdokan.DokanMain(ctypes.byref(opts), ctypes.byref(opstruct))
WindowsError: exception: access violation reading 0x00000010 This error was not raised right after my command returned. Actually the unmount method returned very fast, but it was after several more seconds did the error come up. I suspect it was the background process which crashed. For pyfilesystem it was a fresh clone from https://github.com/Liryna/pyfilesystem.git , as for Dokan it was |
Current master in this repo should have all necessary changes. |
I can't get this to work, Dokany v1.3.0.1000 Output:
|
Will take a look when I can. Otherwise are you sure to use same 32/64
platform for dokan dll and python?
Le sam. 31 août 2019 à 23:09, BiatuAutMiahn <notifications@github.com> a
écrit :
… I can't get this to work, Dokany v1.3.0.1000
Output:
>>> from fs.memoryfs import MemoryFS
>>> from fs.expose import dokan
>>> fs = MemoryFS()
>>> # Mount device mount point
... mp = dokan.mount(fs, "Q:\\")
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "C:\ProgramData\Miniconda3\lib\site-packages\fs\expose\dokan\__init__.py", line 1107, in _do_mount
mount(fs, path, **opts)
File "C:\ProgramData\Miniconda3\lib\site-packages\fs\expose\dokan\__init__.py", line 1011, in mount
raise OSError("Dokan failed with error: %d" % (res,))
OSError: Dokan failed with error: -7
Traceback (most recent call last):
File "C:\ProgramData\Miniconda3\lib\site-packages\fs\expose\dokan\__init__.py", line 983, in check_ready
os.stat(path)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'Q:\\'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\ProgramData\Miniconda3\lib\site-packages\fs\expose\dokan\__init__.py", line 1018, in mount
check_ready(mp)
File "C:\ProgramData\Miniconda3\lib\site-packages\fs\expose\dokan\__init__.py", line 985, in check_ready
check_alive(mp)
File "C:\ProgramData\Miniconda3\lib\site-packages\fs\expose\dokan\__init__.py", line 976, in check_alive
raise OSError("dokan mount process exited prematurely")
OSError: dokan mount process exited prematurely
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#256?email_source=notifications&email_token=ABA4S65LOCPF4HSSOJ3YJQTQHLMY7A5CNFSM4CJUAUMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5TVIEY#issuecomment-526865427>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABA4S642QUVFWBZSHNCQ3SLQHLMY7ANCNFSM4CJUAUMA>
.
|
Tried both, CWD was in the dokany dll folder |
Oh this is helpful!
There is a version number in dokan py file normal. You would need to update
the value but this also mean probably something in the python wrapper need
to be updated also.
Will try to take a look in the next weeks if you want.
Best regards
Adrien JUND
Le ven. 6 sept. 2019 à 21:42, BiatuAutMiahn <notifications@github.com> a
écrit :
… I ran dokanctl to see options, enabled debug then found DebugView, tried
to run mp = dokan.mount(fs, "Q:\\") again and I found this...
[image: image]
<https://user-images.githubusercontent.com/6149596/64455944-f6874500-d0bc-11e9-8c6a-3526448b86be.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#256?email_source=notifications&email_token=ABA4S62BCHHIX75RJ5Z76FTQIKXDNA5CNFSM4CJUAUMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6D3W2Y#issuecomment-528989035>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABA4S66HDVLUWVTKTTAXZ5DQIKXDNANCNFSM4CJUAUMA>
.
|
Changed: and Q:\ has mounted! |
You need to a diff between dokan.h of 1.0.0 and latest Dokan and adapt the Python code accordingly. Otherwise you will get random crashes (which is why there are those version checks). |
If anyone would be interested, dokan-dev is still looking for an official dokan python wrapper! Ping @nznaza |
I have finally decided to look back into my repo. (When I first uploaded it I got burned out, and studies and whatnot got in the way) Creating, Deleting and Renaming Folders work. If people test and report bugs I will happily look into them. |
Hi! Any updates on this? Looking to use this to mount ramfs on Windows to display decrypted files using Python3. |
Could be willing to help with this, but would it be better suited here or the Dokany repo? Imho would be simpler to write an intermediate wrapper using C/C++ and then create python bindings to that intermediate wrapper optimized to use with Python? |
And then most of the work would be associated with updating the C/C++ intermediate binding interface? |
@hugo-hur |
No matter what I did it would not enumerate a directory properly. .. the sheer number duplicate requests was also an issue and made it not visible to use for what I had wanted to use it for. |
Python 2.7.9 64 bit and 32 bit
Dokan 0.7.4
FS 0.5.4
Windows 8.1
I tried the newer versions before I realized that 8.0 was API breaking. I've read through all the message boards I can find with no apparent 'fix'. Dokan 0.6.0 no longer appears to be available on the Dokan project page at Github. I
The text was updated successfully, but these errors were encountered: