site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hello, (originally posted at carbon-dev) Best regards, Dirk Stegemann ----- ioreg output for different machines: 3) MacBook Pro is similar to iMac Core Duo. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... I'd like to retrieve the system volume's hard disk serial number. For drives which indeed support such a serial number it can be read using the ioreg tool. Although I'd prefer to read the hard disk serial number using an API (e.g. IOKit) instead of using a dedicated tool, I'm more concerned about the different paths I seem to have to go through the dictionaries to get different drives' serial numbers when the drives are attached by different busses (see ioreg output below). Also, the *keys* used to query the dictionary for the S/N differ, e.g. "device serial" vs. "Serial Number". Apple's System Profiler gets them all, but maybe it also uses different code to read the S/N from different devices? Is there a recommended / unified way to retrieve a hard drive's serial number? At least, are there known pitfalls? Thanks for pointers, links, sample code snippets, comments, or whatever you might consider useful! P.S.: I've read TN1103 (the old version from 1998 which points to an antiquated ATA demo sample, as well as the new version which doesn't include disk querying capabilities). Ideally, I'd like to follow that versions IOKit query mechanism to retrieve the hard disk serial number. 1) ----- PB G4 17" (2005) -----> | +-o pci@f4000000 <class IOPlatformDevice, registered, matched, active, busy 0, retain count 10> | | | { [...] | | | } | | | | | +-o AppleMacRiscPCI <class AppleMacRiscPCI, !registered, ! matched, active, busy 0, retain count 12> | | | { [...] | | | } | | | | | +-o ata-6@D <class IOPCIDevice, registered, matched, active, busy 0, retain count 14> | | | | { [...] | | | | } | | | | | | | +-o AppleKauaiATA <class AppleKauaiATA, registered, matched, active, busy 0, retain count 5> | | | | { [...] | | | | } | | | | | | | +-o ATADeviceNub@0 <class ATADeviceNub, registered, matched, active, busy 0, retain count 6> | | | | { | | | | "ata device type" = "ata" | | | | "unit number" = 0 | | | | "IOUnit" = 0 | | | | "socket type" = "internal" | | | | "device model" = "ST9100823A " | | | | "extended LBA capacity" = 195371568 | | | | "device serial" = " 3LGxxxxx" | | | | "device revision" = "3.06 " | | | | } <----- PB G4 17" (2005) ----- 2) ----- iMac Core Duo 17" (2006) -----> | | +-o SATA@1F,2 <class IOPCIDevice, registered, matched, active, busy 0, retain count 15> | | | | { [...] | | | | } | | | | | | | +-o AppleAHCI <class AppleAHCI, !registered, !matched, active, busy 0, retain count 8> | | | | { [...] | | | | } | | | | | | | +-o AppleAHCIPort@2 <class AppleAHCIPort, registered, matched, active, busy 0, retain count 9> | | | | { [...] | | | | } | | | | | | | +-o IOAHCIDevice@0 <class IOAHCIDevice, registered, matched, active, busy 0, retain count 7> | | | | { [...] | | | | } | | | | | | | +-o AppleAHCIDiskDriver <class AppleAHCIDiskDriver, registered, matched, active, busy 0, retain count 9> | | | | { | | | | "NCQ" = Yes | | | | "IOMaximumBlockCountWrite" = 65536 | | | | "Revision" = "3.42 " | | | | "CFBundleIdentifier" = "com.apple.iokit.IOAHCIBlockStorage" | | | | "IOClass" = "AppleAHCIDiskDriver" | | | | "IOPolledInterface" = "not serializable" | | | | "IOProbeScore" = 0 | | | | "SATA Features" = 14 | | | | "IOMatchCategory" = "IODefaultMatchCategory" | | | | "Physical Interconnect Location" = "Internal" | | | | "Serial Number" = " 5MTxxxxx" | | | | "Model" = "ST3160023AS " | | | | "Physical Interconnect" = "SATA" | | | | "IOMaximumBlockCountRead" = 65536 | | | | "IOProviderClass" = "IOAHCIDevice" | | | | "Queue Depth" = 32 | | | | } <----- iMac Core Duo 15" (2006) ----- This email sent to site_archiver@lists.apple.com