gopsutil icon indicating copy to clipboard operation
gopsutil copied to clipboard

`disk.IOCounters()` returns `ERROR_INVALID_FUNCTION` when Google Drive is mounted as a disk in Windows.

Open zak-pawel opened this issue 2 years ago • 2 comments

Describe the bug disk.IOCounters(names ...string) returns ERROR_INVALID_FUNCTION when Google Drive is mounted as a disk in Windows.

To Reproduce Call:

disk.IOCounters(nil)

when Google Drive is mounted as a disk in Windows and observe returned ERROR_INVALID_FUNCTION. In my case it has letter G.

Expected behavior

  1. ERROR_INVALID_FUNCTION (returned from windows.DeviceIoControl) can be ignored inside IOCountersWithContext (in the similar way as in mentioned https://github.com/giampaolo/psutil/blob/544e9daa4f66a9f80d7bf6c7886d693ee42f0a13/psutil/arch/windows/disk.c#L83)

or

  1. Filter based on names passed to IOCountersWithContext can be implemented (so consumer can get stats only for particular drives) - right now names are ignored.

Environment (please complete the following information):

  • [x] gopsutil: [v3.23.3]
  • [x] Windows: Microsoft Windows [Version 10.0.19045.2846]
  • [ ] Linux: [paste contents of /etc/os-release and the result of uname -a]
  • [ ] Mac OS: [paste the result of sw_vers and uname -a
  • [ ] FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
  • [ ] OpenBSD: [paste the result of uname -a]

Additional context Problem disappears after Google Drive is unmounted (Google Drive daemon is closed).

zak-pawel avatar May 05 '23 20:05 zak-pawel

Moreover, it seems that (in my case) more properties were read than saved to drivemap image

zak-pawel avatar May 05 '23 20:05 zak-pawel

Thank you for the report. I can reproduce on my Windows 11 + Google Drive veresion 74.0.3.0.

In the first investigation, the error is occurred at windows.DeviceIoControl. On normal C: drive, there is no error. Only Google drive mounted drive has this error.

windows.DeiveIoControl calls syscall, so it seems it is hard to investigate. I will try later.

shirou avatar May 13 '23 09:05 shirou