ghw icon indicating copy to clipboard operation
ghw copied to clipboard

MacOS Block() returns no information

Open audiolion opened this issue 5 years ago • 5 comments

Hi 👋,

Wanted to use the ghw.Block() functionality, and noticed on Darwin that it returns no information. I used delve to debug what was happening, and while almost all the disk information was being found, it was getting to this section of code https://github.com/jaypipes/ghw/blob/e193f9455de9bf27be414e62e73e80d58bbc2885/block_darwin.go#L129-L136

and out was an empty string. This code is supposed to populate this struct https://github.com/jaypipes/ghw/blob/e193f9455de9bf27be414e62e73e80d58bbc2885/block_darwin.go#L91-L96

and when it fails it calls https://github.com/jaypipes/ghw/blob/e193f9455de9bf27be414e62e73e80d58bbc2885/block_darwin.go#L140-L142

which results in the this continue clause to be called https://github.com/jaypipes/ghw/blob/e193f9455de9bf27be414e62e73e80d58bbc2885/block_darwin.go#L248-L254

As a result, none of this code is called, so nothing ever gets populated https://github.com/jaypipes/ghw/blob/e193f9455de9bf27be414e62e73e80d58bbc2885/block_darwin.go#L257-L293

In summary, because the model number/serial number/vendor retrieval failed, we lost out on all the other information that was found. Two requests, could we populate the information even if this ioreg piece fails? And could we look into why the ioreg piece fails on darwin? I tried to query ioreg but I was not able to find an alternative way to pull this info.

audiolion avatar May 05 '20 16:05 audiolion

Hi @audiolion! Thanks very much for the bug report! I'll look into a fix ASAP.

jaypipes avatar May 05 '20 20:05 jaypipes

nice! If I can help in anyway let me know. I don't have another mac to confirm if this is purely an issue with my machine or if it presents on other machines as well. Maybe something changed with Catalina?

audiolion avatar May 05 '20 22:05 audiolion

@audiolion hey, I haven't forgotten about you! Trying to get my hands on a Mac to reproduce your issue and push a fix. Sorry for the delay!

jaypipes avatar May 21 '20 14:05 jaypipes

Hey no worries. Mac is so difficult to develop for because you can't emulate it :(. I might be able to set up a mac mini that you can remote into?

audiolion avatar May 21 '20 14:05 audiolion

I had the same problem so i had a friend run some tests and found this:

The MacBook i have runs on a HDD and diskutil reports the following DevicePath

IODeviceTree:/PCI0@0/SATA@1F,2/PRT0@0/PMP@0

So ioreg gets called with PMP@0 and returns nothing. The library doesn't work here. Note: I ran ioreg by hand with AppleAHCIDiskDriver as name and got the disk model/serial.

The MacBook from my friend uses a SSD and diskutil returns this DevicePath

IODeviceTree:/PCI0@0/RP01@1C/SSD0@0/AppleS3XController

In this case ioreg gets called with AppleS3XController and got the disk model/serial. The library works as expected.

codestation avatar Nov 23 '20 23:11 codestation