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

Process.get_open_files() does not support network handles #600

Open
mrjefftang opened this issue Mar 2, 2015 · 2 comments
Open

Process.get_open_files() does not support network handles #600

mrjefftang opened this issue Mar 2, 2015 · 2 comments

Comments

@mrjefftang
Copy link
Collaborator

On Windows, psutil_get_open_files returns a list of file names in a raw format such as:
\Device\HarddiskVolume1\Windows\systemew\file.txt

However for a network file, the raw format looks like this:
\Device\Mup\sharename\path\to\file.txt

These filenames are split to take the first 2 items "\Device\HarddiskVolume1" or "\Device\Mup" and passed to QueryDosDevice.

If QueryDosDevice fails, it just returns blank and the following call to isfile_strict will fail so the filename will not return.

There are 2 cases to consider:
1 - The network drive is mapped to a drive letter e.g. Z:\path\to\file.txt
2 - The network drive is not mapped: \sharename\path\to\file.txt

@giampaolo
Copy link
Owner

I can reproduce the issue by putting psutil GIT cloned directory in a shared folder (Z:\) and I see exactly the behavior you describe. In my case the file looks like "\VBOXSVR\psutil\file".
That kind of path is not usable by python (e.g. open() won't work). We would need the actual drive letter to which it is mapped, something like "Z:\VBOXSVR\psutil\file", but I'm not sure how to do that (QueryDosDevice does not resolve it).

@gustavohw
Copy link

Just ran into this issue. I can successfully get open files on local drive but completely breaks when trying network-mapped ones.

Is there any other alternative to get network-drives to work?

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