Changeset 26660 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Feb 19, 2010 2:49:54 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/solaris/RTSystemQueryDmiString-solaris.cpp
r26626 r26660 42 42 #include <smbios.h> 43 43 44 44 45 RTDECL(int) RTSystemQueryDmiString(RTSYSDMISTR enmString, char *pszBuf, size_t cbBuf) 45 46 { … … 49 50 AssertReturn(enmString > RTSYSDMISTR_INVALID && enmString < RTSYSDMISTR_END, VERR_INVALID_PARAMETER); 50 51 51 int rc = V INF_SUCCESS;52 int rc = VERR_NOT_SUPPORTED; 52 53 int err = 0; 53 54 smbios_hdl_t *pSMB = smbios_open(NULL /* default fd */, SMB_VERSION, 0 /* flags */, &err); 54 55 if (pSMB) 55 56 { 56 smbios_system_t hSMBSys; 57 id_t hSMBId = smbios_info_system(pSMB, &hSMBSys); 58 if (hSMBId != SMB_ERR) 57 if (enmString == RTSYSDMISTR_PRODUCT_UUID) 58 { 59 smbios_system_t hSMBSys; 60 id_t hSMBId = smbios_info_system(pSMB, &hSMBSys); 61 if (hSMBId != SMB_ERR) 62 { 63 static char const s_szHex[17] = "0123456789ABCDEF"; 64 char szData[64]; 65 char *pszData = szData; 66 unsigned cchUuid = RT_MIN(hSMBSys.smbs_uuidlen, sizeof(szData) - 1); 67 for (unsigned i = 0; i < cchUuid; i++) 68 { 69 *pszData++ = s_szHex[hSMBSys.smbs_uuid[i] >> 4]; 70 *pszData++ = s_szHex[hSMBSys.smbs_uuid[i] & 0xf]; 71 if (i == 3 || i == 5 || i == 7 || i == 9) 72 *pszData++ = '-'; 73 } 74 *pszData = '\0'; 75 rc = RTStrCopy(pszBuf, cbBuf, szData); 76 smbios_close(pSMB); 77 return rc; 78 } 79 } 80 else 59 81 { 60 82 smbios_info_t hSMBInfo; … … 64 86 switch (enmString) 65 87 { 66 case RTSYSDMISTR_PRODUCT_UUID: 67 { 68 static char const s_szHex[17] = "0123456789ABCDEF"; 69 char szData[64]; 70 char *pszData = szData; 71 for (unsigned i = 0; i < RT_MIN(hSMBSys.smbs_uuidlen, sizeof(szData) - 1); i++) 72 { 73 *pszData++ = s_szHex[hSMBSys.smbs_uuid[i] >> 4]; 74 *pszData++ = s_szHex[hSMBSys.smbs_uuid[i] & 0xf]; 75 if (i == 3 || i == 5 || i == 7 || i == 9) 76 *pszData++ = '-'; 77 } 78 *pszData = '\0'; 79 RTStrPrintf(pszBuf, cbBuf, "%s", szData); 80 rc = VINF_SUCCESS; 81 break; 82 } 88 case RTSYSDMISTR_PRODUCT_NAME: rc = RTStrCopy(pszBuf, cbBuf, hSMBInfo.smbi_product); break; 89 case RTSYSDMISTR_PRODUCT_VERSION: rc = RTStrCopy(pszBuf, cbBuf, hSMBInfo.smbi_version); break; 90 case RTSYSDMISTR_PRODUCT_SERIAL: rc = RTStrCopy(pszBuf, cbBuf, hSMBInfo.smbi_serial); break; 83 91 84 case RTSYSDMISTR_PRODUCT_NAME: RTStrPrintf(pszBuf, cbBuf, "%s", hSMBInfo.smbi_product); rc = VINF_SUCCESS; break; 85 case RTSYSDMISTR_PRODUCT_VERSION: RTStrPrintf(pszBuf, cbBuf, "%s", hSMBInfo.smbi_version); rc = VINF_SUCCESS; break; 86 case RTSYSDMISTR_PRODUCT_SERIAL: RTStrPrintf(pszBuf, cbBuf, "%s", hSMBInfo.smbi_serial); rc = VINF_SUCCESS; break; 87 88 default: 92 default: /* make gcc happy */ 89 93 rc = VERR_NOT_SUPPORTED; 90 94 } 95 smbios_close(pSMB); 96 return rc; 91 97 } 92 else93 rc = VERR_INTERNAL_ERROR_2;94 98 } 95 else96 rc = VERR_INTERNAL_ERROR;97 99 100 /* smbios_* error path. */ 101 err = smbios_errno(pSMB); 98 102 smbios_close(pSMB); 99 103 } 100 else101 rc = VERR_OPEN_FAILED;102 104 105 /* Do some error conversion. */ 106 if (err == EPERM || err == EACCES) 107 rc = VERR_ACCESS_DENIED; 103 108 return rc; 104 109 }
Note:
See TracChangeset
for help on using the changeset viewer.