Closed GoogleCodeExporter closed 8 years ago
See GetLogicalDriveStrings() to get a list of all the drive names:
http://msdn.microsoft.com/en-us/library/aa364975%28VS.85%29.aspx
And QueryDosDevice() for converting a dos path to an NT device name:
http://msdn.microsoft.com/en-us/library/aa365461%28VS.85%29.aspx
There's also code samples in MSDN for converting an NT device name to a drive
letter:
http://msdn.microsoft.com/en-us/library/aa366789%28VS.85%29.aspx
I would be careful about copying any code directly since it doesn't look like
particularly elegant code but it gives us a starting point at least.
Original comment by jlo...@gmail.com
on 9 Mar 2010 at 4:43
Added Linux implementation as r538.
Original comment by billiej...@gmail.com
on 13 Mar 2010 at 12:27
Exposed QueryDosDevice() as r543.
The raw drive name conversion is now made.
Original comment by billiej...@gmail.com
on 13 Mar 2010 at 6:49
Original comment by g.rodola
on 22 Jun 2010 at 7:37
Because of the extreme complexity deriving from doing this in pure C in two
different ways for both OSX and BSD, r591 implements this functionality by
parsing lsof command output.
If lsof is not installed NotImplementedError exception is raised.
Jay could you try this out on OSX?
Original comment by g.rodola
on 7 Jul 2010 at 11:40
Original comment by g.rodola
on 19 Jul 2010 at 8:18
Reopening as there's a problem on Windows.
The script below hangs when svnchost.exe process is encountered.
import psutil
for p in psutil.process_iter():
print(p)
print(p.get_open_files())
Original comment by g.rodola
on 20 Jul 2010 at 11:47
The culprit seems to be NtQueryObject().
I found different sources describing this problem, like:
http://www.codeproject.com/Articles/35202/GetFinalPathNameByHandle-API-Hangs.asp
x
Here is provided a solution which runs NtQueryObject() into a separate thread
with a timeout of 1 second:
http://forum.sysinternals.com/discussion-howto-enumerate-handles_topic19403_page
2.html
Original comment by g.rodola
on 5 Aug 2010 at 4:05
http://forum.sysinternals.com/topic19403_page7.html
> The thread hack doesn't work on XP (SP2, maybe SP3) because it has a bug
where you
> cannot terminate the hanging thread.
> Also in Windows 7 NtQueryObject has been completely fixed - no hangs at all.
In
> Vista the bug is still there but you can at least terminate the hanging
thread.
Original comment by g.rodola
on 5 Aug 2010 at 4:18
Process explorer provides a hack for this:
http://www.koders.com/csharp/fid7DE6B7813A01C2AA46DAAC5C2C9E49999E7E0E34.aspx?s=
mdef:search#L259
Original comment by g.rodola
on 5 Aug 2010 at 4:45
[deleted comment]
Added a hack in r627 which skip handlers having certain access codes.
This seems to be enough to fix the problem and pass the test above which was
commented out in the test suite.
I still have to figure out whether we can avoid this on Windows 7 where
NtQueryObject() is supposed to have been fixed.
Original comment by g.rodola
on 5 Aug 2010 at 7:54
Tried out on Windows 7 and the same problem occurs.
The only thing which has been fixed is that the process, despite freezed, can
be killed via taskmgr, while on Windows XP I was forced to reboot the computer.
Closing this out as fixed.
Original comment by g.rodola
on 5 Aug 2010 at 7:57
[deleted comment]
Updated csets after the SVN -> Mercurial migration:
r538 == revision 99e11dcca77e
r543 == revision 1ebe83c24b7c
r591 == revision 6d3522006aed
r627 == revision a182f3b140ae
Original comment by g.rodola
on 2 Mar 2013 at 11:52
Original issue reported on code.google.com by
billiej...@gmail.com
on 8 Mar 2010 at 7:49