diff --git a/CREDITS b/CREDITS index c614c42229..0a19cc087b 100644 --- a/CREDITS +++ b/CREDITS @@ -757,4 +757,4 @@ D: fix typos in documentation N: Pablo Baeyens W: https://github.com/mx-psi -I: 1598 +I: 1598, 1974 diff --git a/HISTORY.rst b/HISTORY.rst index 4058d66011..2eb190c9cf 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -27,6 +27,7 @@ XXXX-XX-XX (patch by MaWe2019) - 1598_: [Windows] psutil.disk_partitions() only returns mountpoints on drives where it first finds one +- 1974_: [Windows] psutil.disk_io_counters() raises permission error. 5.8.0 ===== diff --git a/psutil/arch/windows/disk.c b/psutil/arch/windows/disk.c index 7c35e81243..99dafce835 100644 --- a/psutil/arch/windows/disk.c +++ b/psutil/arch/windows/disk.c @@ -140,6 +140,12 @@ psutil_disk_io_counters(PyObject *self, PyObject *args) { "ignore PhysicalDrive%i", devNum); goto next; } + else if (GetLastError() == ERROR_ACCESS_DENIED) { + // Ignore disks that we are not able to access. + psutil_debug("DeviceIoControl -> ERROR_ACCESS_DENIED; " + "ignore PhysicalDrive%i", devNum); + goto next; + } // XXX: it seems we should also catch ERROR_INVALID_PARAMETER: // https://sites.ualberta.ca/dept/aict/uts/software/openbsd/ // ports/4.1/i386/openafs/w-openafs-1.4.14-transarc/