-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement disk.GetDiskSerialNumber for Windows via WMI #541
Conversation
…uld be drive letter, so it can be used in IOCountersStat. See last part of https://msdn.microsoft.com/en-us/library/windows/desktop/aa394592(v=vs.85).aspx.
Tested on windows 7/server 2016. The result is right, but slow. |
disk/disk_windows.go
Outdated
InterfaceType string | ||
SerialNumber string | ||
} | ||
type Win32_DiskPartition struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't export these types (I know there are similarly exported wmi types in other gopsutil packages but that's a mistake as Windows-only and thus should not be part of the public API).
Thank you! This works on my Windows 10 environment. |
I wouldn't have merged this PR @shirou, on Windows a letter C:, D:, etc is a disk partition and not a physical disk (\.\PHYSICALDRIVEX is), see my commit message at Lomanic@8905b92. Plus, this result should be compared to the one found on Linux, see https://stackoverflow.com/q/27297348/ (that's why I did not create a PR for my commit). |
ahhh.. I'm sorry. Could you revert this merge ? > @Lomanic |
I have reverted this PR. sorry. |
Hi @Lomanic , to your first question, I did this on purpose so that the serial number can be returned with iocounters, like that on linux (/boot/efi, /, /home also not physical disk). Otherwise users of this library will have to find the physical disk id related to the iocounter's name themselves. As to the second question, This method is supposed to be used on windows, so I think it's ok if all windows system do the reverse thing. |
I think we should have the following:
So we might merge back this PR, but with some checks added if we query a physical drive path. |
Hi @Lomanic , I tested on my local machine (I have dual system installed, win10 professional 1607 1493.953, and fedora 4.16.12-200.fc27). Here is the result I get:
|
Fix shirou/gopsutil#435. Parameter should be drive letter, so it can be used in IOCountersStat directly. See last part of https://msdn.microsoft.com/en-us/library/windows/desktop/aa394592(v=vs.85).aspx.