Changeset 85929 in vbox for trunk/src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp
- Timestamp:
- Aug 28, 2020 2:40:55 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 140122
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp
r82968 r85929 1 1 /* $Id$ */ 2 2 /** @file 3 * Classes for handling hardware detection under FreeBSD.3 * VirtualBox Main - Code for handling hardware detection under FreeBSD, VBoxSVC. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #define LOG_GROUP LOG_GROUP_MAIN19 20 18 21 19 /********************************************************************************************************************************* 22 20 * Header Files * 23 21 *********************************************************************************************************************************/ 24 25 #include <HostHardwareLinux.h>22 #define LOG_GROUP LOG_GROUP_MAIN 23 #include "HostHardwareLinux.h" 26 24 27 25 #include <VBox/log.h> … … 35 33 #include <iprt/string.h> 36 34 37 #i fdef RT_OS_FREEBSD38 # include <sys/param.h>39 # include <sys/types.h>40 # include <sys/stat.h>41 # include <unistd.h>42 # include <stdio.h>43 # include <sys/ioctl.h>44 # include <fcntl.h>45 # include <cam/cam.h>46 # include <cam/cam_ccb.h>47 # 48 #endif /* RT_OS_FREEBSD */ 35 #include <sys/param.h> 36 #include <sys/types.h> 37 #include <sys/stat.h> 38 #include <unistd.h> 39 #include <stdio.h> 40 #include <sys/ioctl.h> 41 #include <fcntl.h> 42 #include <cam/cam.h> 43 #include <cam/cam_ccb.h> 44 #include <camlib.h> 45 #include <cam/scsi/scsi_pass.h> 46 49 47 #include <vector> 50 48 … … 53 51 * Typedefs and Defines * 54 52 *********************************************************************************************************************************/ 55 56 static int getDriveInfoFromEnv(const char *pcszVar, DriveInfoList *pList, 57 bool isDVD, bool *pfSuccess); 58 static int getDVDInfoFromCAM(DriveInfoList *pList, bool *pfSuccess); 53 typedef enum DriveType_T 54 { 55 Fixed, 56 DVD, 57 Any 58 } DriveType_T; 59 60 61 /********************************************************************************************************************************* 62 * Internal Functions * 63 *********************************************************************************************************************************/ 64 static int getDriveInfoFromEnv(const char *pcszVar, DriveInfoList *pList, bool isDVD, bool *pfSuccess) RT_NOTHROW_PROTP; 65 static int getDriveInfoFromCAM(DriveInfoList *pList, DriveType_T enmDriveType, bool *pfSuccess) RT_NOTHROW_PROTP; 66 59 67 60 68 /** Find the length of a string, ignoring trailing non-ascii or control 61 * characters */ 62 static size_t strLenStripped(const char *pcsz) 69 * characters 70 * @note Code duplicated in HostHardwareLinux.cpp */ 71 static size_t strLenStripped(const char *pcsz) RT_NOTHROW_DEF 63 72 { 64 73 size_t cch = 0; 65 74 for (size_t i = 0; pcsz[i] != '\0'; ++i) 66 if (pcsz[i] > 32 && pcsz[i] < 127)75 if (pcsz[i] > 32 /*space*/ && pcsz[i] < 127 /*delete*/) 67 76 cch = i; 68 77 return cch + 1; 69 78 } 70 79 71 static void strLenRemoveTrailingWhiteSpace(char *psz, size_t cchStr)72 {73 while ( (cchStr > 0)74 && (psz[cchStr -1] == ' '))75 psz[--cchStr] = '\0';76 }77 80 78 81 /** 79 * Initialise the device description for a DVD drive based on 80 * vendor and model name strings. 81 * @param pcszVendor the vendor ID string 82 * @param pcszModel the product ID string 83 * @param pszDesc where to store the description string (optional) 84 * @param cchDesc the size of the buffer in @pszDesc 82 * Initialize the device description for a drive based on vendor and model name 83 * strings. 84 * 85 * @param pcszVendor The raw vendor ID string. 86 * @param pcszModel The raw product ID string. 87 * @param pszDesc Where to store the description string (optional) 88 * @param cbDesc The size of the buffer in @pszDesc 89 * 90 * @note Used for disks as well as DVDs. 85 91 */ 86 92 /* static */ 87 void dvdCreateDeviceString(const char *pcszVendor, const char *pcszModel, 88 char *pszDesc, size_t cchDesc) 93 void dvdCreateDeviceString(const char *pcszVendor, const char *pcszModel, char *pszDesc, size_t cbDesc) RT_NOTHROW_DEF 89 94 { 90 95 AssertPtrReturnVoid(pcszVendor); 91 96 AssertPtrReturnVoid(pcszModel); 92 97 AssertPtrNullReturnVoid(pszDesc); 93 AssertReturnVoid(!pszDesc || c chDesc > 0);98 AssertReturnVoid(!pszDesc || cbDesc > 0); 94 99 size_t cchVendor = strLenStripped(pcszVendor); 95 100 size_t cchModel = strLenStripped(pcszModel); … … 99 104 { 100 105 if (cchVendor > 0) 101 RTStrPrintf(pszDesc, c chDesc, "%.*s %s", cchVendor, pcszVendor,106 RTStrPrintf(pszDesc, cbDesc, "%.*s %s", cchVendor, pcszVendor, 102 107 cchModel > 0 ? pcszModel : "(unknown drive model)"); 103 108 else 104 RTStrPrintf(pszDesc, cchDesc, "%s", pcszModel); 105 } 106 } 107 108 109 int VBoxMainDriveInfo::updateDVDs () 109 RTStrPrintf(pszDesc, cbDesc, "%s", pcszModel); 110 RTStrPurgeEncoding(pszDesc); 111 } 112 } 113 114 115 int VBoxMainDriveInfo::updateDVDs() RT_NOEXCEPT 110 116 { 111 117 LogFlowThisFunc(("entered\n")); 112 int rc = VINF_SUCCESS; 113 bool fSuccess = false; /* Have we succeeded in finding anything yet? */ 114 118 int rc; 115 119 try 116 120 { 117 mDVDList.clear 121 mDVDList.clear(); 118 122 /* Always allow the user to override our auto-detection using an 119 123 * environment variable. */ 124 bool fSuccess = false; /* Have we succeeded in finding anything yet? */ 125 rc = getDriveInfoFromEnv("VBOX_CDROM", &mDVDList, true /* isDVD */, &fSuccess); 120 126 if (RT_SUCCESS(rc) && !fSuccess) 121 rc = getDriveInfoFromEnv("VBOX_CDROM", &mDVDList, true /* isDVD */, 122 &fSuccess); 123 if (RT_SUCCESS(rc) && !fSuccess) 124 rc = getDVDInfoFromCAM(&mDVDList, &fSuccess); 125 } 126 catch(std::bad_alloc &e) 127 rc = getDriveInfoFromCAM(&mDVDList, DVD, &fSuccess); 128 } 129 catch (std::bad_alloc &) 127 130 { 128 131 rc = VERR_NO_MEMORY; … … 132 135 } 133 136 134 int VBoxMainDriveInfo::updateFloppies ()137 int VBoxMainDriveInfo::updateFloppies() RT_NOEXCEPT 135 138 { 136 139 LogFlowThisFunc(("entered\n")); 137 int rc = VINF_SUCCESS; 138 bool fSuccess = false; /* Have we succeeded in finding anything yet? */ 139 140 int rc; 140 141 try 141 142 { 142 mFloppyList.clear (); 143 /* Always allow the user to override our auto-detection using an 144 * environment variable. */ 145 if (RT_SUCCESS(rc) && !fSuccess) 146 rc = getDriveInfoFromEnv("VBOX_FLOPPY", &mFloppyList, false /* isDVD */, 147 &fSuccess); 148 } 149 catch(std::bad_alloc &e) 143 /* Only got the enviornment variable here... */ 144 mFloppyList.clear(); 145 bool fSuccess = false; /* ignored */ 146 rc = getDriveInfoFromEnv("VBOX_FLOPPY", &mFloppyList, false /* isDVD */, &fSuccess); 147 } 148 catch (std::bad_alloc &) 150 149 { 151 150 rc = VERR_NO_MEMORY; … … 155 154 } 156 155 156 int VBoxMainDriveInfo::updateFixedDrives() RT_NOEXCEPT 157 { 158 LogFlowThisFunc(("entered\n")); 159 int rc; 160 try 161 { 162 mFixedDriveList.clear(); 163 bool fSuccess = false; /* ignored */ 164 rc = getDriveInfoFromCAM(&mFixedDriveList, Fixed, &fSuccess); 165 } 166 catch (std::bad_alloc &) 167 { 168 rc = VERR_NO_MEMORY; 169 } 170 LogFlowThisFunc(("rc=%Rrc\n", rc)); 171 return rc; 172 } 173 174 static void strDeviceStringSCSI(device_match_result *pDevResult, char *pszDesc, size_t cbDesc) RT_NOTHROW_DEF 175 { 176 char szVendor[128]; 177 cam_strvis((uint8_t *)szVendor, (const uint8_t *)pDevResult->inq_data.vendor, 178 sizeof(pDevResult->inq_data.vendor), sizeof(szVendor)); 179 char szProduct[128]; 180 cam_strvis((uint8_t *)szProduct, (const uint8_t *)pDevResult->inq_data.product, 181 sizeof(pDevResult->inq_data.product), sizeof(szProduct)); 182 dvdCreateDeviceString(szVendor, szProduct, pszDesc, cbDesc); 183 } 184 185 static void strDeviceStringATA(device_match_result *pDevResult, char *pszDesc, size_t cbDesc) RT_NOTHROW_DEF 186 { 187 char szProduct[256]; 188 cam_strvis((uint8_t *)szProduct, (const uint8_t *)pDevResult->ident_data.model, 189 sizeof(pDevResult->ident_data.model), sizeof(szProduct)); 190 dvdCreateDeviceString("", szProduct, pszDesc, cbDesc); 191 } 192 193 static void strDeviceStringSEMB(device_match_result *pDevResult, char *pszDesc, size_t cbDesc) RT_NOTHROW_DEF 194 { 195 sep_identify_data *pSid = (sep_identify_data *)&pDevResult->ident_data; 196 197 char szVendor[128]; 198 cam_strvis((uint8_t *)szVendor, (const uint8_t *)pSid->vendor_id, 199 sizeof(pSid->vendor_id), sizeof(szVendor)); 200 char szProduct[128]; 201 cam_strvis((uint8_t *)szProduct, (const uint8_t *)pSid->product_id, 202 sizeof(pSid->product_id), sizeof(szProduct)); 203 dvdCreateDeviceString(szVendor, szProduct, pszDesc, cbDesc); 204 } 205 206 static void strDeviceStringMMCSD(device_match_result *pDevResult, char *pszDesc, size_t cbDesc) RT_NOTHROW_DEF 207 { 208 struct cam_device *pDev = cam_open_btl(pDevResult->path_id, pDevResult->target_id, 209 pDevResult->target_lun, O_RDWR, NULL); 210 if (pDev == NULL) 211 { 212 Log(("Error while opening drive device. Error: %s\n", cam_errbuf)); 213 return; 214 } 215 216 union ccb *pCcb = cam_getccb(pDev); 217 if (pCcb != NULL) 218 { 219 struct mmc_params mmcIdentData; 220 RT_ZERO(mmcIdentData); 221 222 struct ccb_dev_advinfo *pAdvi = &pCcb->cdai; 223 pAdvi->ccb_h.flags = CAM_DIR_IN; 224 pAdvi->ccb_h.func_code = XPT_DEV_ADVINFO; 225 pAdvi->flags = CDAI_FLAG_NONE; 226 pAdvi->buftype = CDAI_TYPE_MMC_PARAMS; 227 pAdvi->bufsiz = sizeof(mmcIdentData); 228 pAdvi->buf = (uint8_t *)&mmcIdentData; 229 230 if (cam_send_ccb(pDev, pCcb) >= 0) 231 { 232 if (strlen((char *)mmcIdentData.model) > 0) 233 dvdCreateDeviceString("", (const char *)mmcIdentData.model, pszDesc, cbDesc); 234 else 235 dvdCreateDeviceString("", mmcIdentData.card_features & CARD_FEATURE_SDIO ? "SDIO card" : "Unknown card", 236 pszDesc, cbDesc); 237 } 238 else 239 Log(("error sending XPT_DEV_ADVINFO CCB\n")); 240 241 cam_freeccb(pCcb); 242 } 243 else 244 Log(("Could not allocate CCB\n")); 245 cam_close_device(pDev); 246 } 247 248 /** @returns boolean success indicator (true/false). */ 249 static int nvmeGetCData(struct cam_device *pDev, struct nvme_controller_data *pCData) RT_NOTHROW_DEF 250 { 251 bool fSuccess = false; 252 union ccb *pCcb = cam_getccb(pDev); 253 if (pCcb != NULL) 254 { 255 struct ccb_dev_advinfo *pAdvi = &pCcb->cdai; 256 pAdvi->ccb_h.flags = CAM_DIR_IN; 257 pAdvi->ccb_h.func_code = XPT_DEV_ADVINFO; 258 pAdvi->flags = CDAI_FLAG_NONE; 259 pAdvi->buftype = CDAI_TYPE_NVME_CNTRL; 260 pAdvi->bufsiz = sizeof(struct nvme_controller_data); 261 pAdvi->buf = (uint8_t *)pCData; 262 RT_BZERO(pAdvi->buf, pAdvi->bufsiz); 263 264 if (cam_send_ccb(pDev, pCcb) >= 0) 265 { 266 if (pAdvi->ccb_h.status == CAM_REQ_CMP) 267 fSuccess = true; 268 else 269 Log(("Got CAM error %#x\n", pAdvi->ccb_h.status)); 270 } 271 else 272 Log(("Error sending XPT_DEV_ADVINFO CC\n")); 273 cam_freeccb(pCcb); 274 } 275 else 276 Log(("Could not allocate CCB\n")); 277 return fSuccess; 278 } 279 280 static void strDeviceStringNVME(device_match_result *pDevResult, char *pszDesc, size_t cbDesc) RT_NOTHROW_DEF 281 { 282 struct cam_device *pDev = cam_open_btl(pDevResult->path_id, pDevResult->target_id, 283 pDevResult->target_lun, O_RDWR, NULL); 284 if (pDev) 285 { 286 struct nvme_controller_data CData; 287 if (nvmeGetCData(pDev, &CData)) 288 { 289 char szVendor[128]; 290 cam_strvis((uint8_t *)szVendor, CData.mn, sizeof(CData.mn), sizeof(szVendor)); 291 char szProduct[128]; 292 cam_strvis((uint8_t *)szProduct, CData.fr, sizeof(CData.fr), sizeof(szProduct)); 293 dvdCreateDeviceString(szVendor, szProduct, pszDesc, cbDesc); 294 } 295 else 296 Log(("Error while getting NVME drive info\n")); 297 cam_close_device(pDev); 298 } 299 else 300 Log(("Error while opening drive device. Error: %s\n", cam_errbuf)); 301 } 302 303 157 304 /** 158 * Search for available CD/DVDdrives using the CAM layer.305 * Search for available drives using the CAM layer. 159 306 * 160 307 * @returns iprt status code 161 * @param pList the list to append the drives found to 162 * @param pfSuccess this will be set to true if we found at least one drive 163 * and to false otherwise. Optional. 308 * @param pList the list to append the drives found to 309 * @param enmDriveType search drives of specified type 310 * @param pfSuccess this will be set to true if we found at least one drive 311 * and to false otherwise. Optional. 164 312 */ 165 static int getDVDInfoFromCAM(DriveInfoList *pList, bool *pfSuccess) 166 { 167 int rc = VINF_SUCCESS; 168 RTFILE FileXpt; 169 170 rc = RTFileOpen(&FileXpt, "/dev/xpt0", RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 313 static int getDriveInfoFromCAM(DriveInfoList *pList, DriveType_T enmDriveType, bool *pfSuccess) RT_NOTHROW_DEF 314 { 315 RTFILE hFileXpt = NIL_RTFILE; 316 int rc = RTFileOpen(&hFileXpt, "/dev/xpt0", RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 171 317 if (RT_SUCCESS(rc)) 172 318 { … … 196 342 #define INQ_PAT inq_pat 197 343 #endif 198 DeviceMatchPattern.pattern.device_pattern.INQ_PAT.type = T_CDROM; 344 DeviceMatchPattern.pattern.device_pattern.INQ_PAT.type = enmDriveType == Fixed ? T_DIRECT 345 : enmDriveType == DVD ? T_CDROM : T_ANY; 199 346 DeviceMatchPattern.pattern.device_pattern.INQ_PAT.media_type = SIP_MEDIA_REMOVABLE | SIP_MEDIA_FIXED; 200 347 DeviceMatchPattern.pattern.device_pattern.INQ_PAT.vendor[0] = '*'; /* Matches anything */ … … 220 367 do 221 368 { 222 rc = RTFileIoCtl( FileXpt, CAMIOCOMMAND, &DeviceCCB, sizeof(union ccb), NULL);369 rc = RTFileIoCtl(hFileXpt, CAMIOCOMMAND, &DeviceCCB, sizeof(union ccb), NULL); 223 370 if (RT_FAILURE(rc)) 224 371 { … … 231 378 if (paMatches[i].type == DEV_MATCH_DEVICE) 232 379 { 380 /* 381 * The result list can contain some empty entries with DEV_RESULT_UNCONFIGURED 382 * flag set, e.g. in case of T_DIRECT. Ignore them. 383 */ 384 if ( (paMatches[i].result.device_result.flags & DEV_RESULT_UNCONFIGURED) 385 == DEV_RESULT_UNCONFIGURED) 386 continue; 387 233 388 /* We have the drive now but need the appropriate device node */ 234 389 struct device_match_result *pDevResult = &paMatches[i].result.device_result; … … 254 409 PeriphMatchPattern.pattern.periph_pattern.target_id = paMatches[i].result.device_result.target_id; 255 410 PeriphMatchPattern.pattern.periph_pattern.target_lun = paMatches[i].result.device_result.target_lun; 256 PeriphMatchPattern.pattern.periph_pattern.flags = (periph_pattern_flags)( PERIPH_MATCH_PATH | PERIPH_MATCH_TARGET 411 PeriphMatchPattern.pattern.periph_pattern.flags = (periph_pattern_flags)( PERIPH_MATCH_PATH 412 | PERIPH_MATCH_TARGET 257 413 | PERIPH_MATCH_LUN); 258 414 PeriphCCB.cdm.num_patterns = 1; … … 265 421 do 266 422 { 267 rc = RTFileIoCtl( FileXpt, CAMIOCOMMAND, &PeriphCCB, sizeof(union ccb), NULL);423 rc = RTFileIoCtl(hFileXpt, CAMIOCOMMAND, &PeriphCCB, sizeof(union ccb), NULL); 268 424 if (RT_FAILURE(rc)) 269 425 { … … 274 430 for (iPeriphMatch = 0; iPeriphMatch < PeriphCCB.cdm.num_matches; iPeriphMatch++) 275 431 { 276 if ( (aPeriphMatches[iPeriphMatch].type == DEV_MATCH_PERIPH) 277 && (!strcmp(aPeriphMatches[iPeriphMatch].result.periph_result.periph_name, "cd"))) 432 /* Ignore "passthrough mode" paths */ 433 if ( aPeriphMatches[iPeriphMatch].type == DEV_MATCH_PERIPH 434 && strcmp(aPeriphMatches[iPeriphMatch].result.periph_result.periph_name, "pass")) 278 435 { 279 436 pPeriphResult = &aPeriphMatches[iPeriphMatch].result.periph_result; … … 285 442 break; 286 443 287 } while ( (DeviceCCB.ccb_h.status == CAM_REQ_CMP)288 && (DeviceCCB.cdm.status == CAM_DEV_MATCH_MORE));444 } while ( DeviceCCB.ccb_h.status == CAM_REQ_CMP 445 && DeviceCCB.cdm.status == CAM_DEV_MATCH_MORE); 289 446 290 447 if (pPeriphResult) 291 448 { 292 449 char szPath[RTPATH_MAX]; 293 char szDesc[256];294 295 450 RTStrPrintf(szPath, sizeof(szPath), "/dev/%s%d", 296 451 pPeriphResult->periph_name, pPeriphResult->unit_number); 297 452 298 /* Remove trailing white space. */ 299 strLenRemoveTrailingWhiteSpace(pDevResult->inq_data.vendor, 300 sizeof(pDevResult->inq_data.vendor)); 301 strLenRemoveTrailingWhiteSpace(pDevResult->inq_data.product, 302 sizeof(pDevResult->inq_data.product)); 303 304 dvdCreateDeviceString(pDevResult->inq_data.vendor, 305 pDevResult->inq_data.product, 306 szDesc, sizeof(szDesc)); 307 308 pList->push_back(DriveInfo(szPath, "", szDesc)); 453 char szDesc[256] = { 0 }; 454 switch (pDevResult->protocol) 455 { 456 case PROTO_SCSI: strDeviceStringSCSI( pDevResult, szDesc, sizeof(szDesc)); break; 457 case PROTO_ATA: strDeviceStringATA( pDevResult, szDesc, sizeof(szDesc)); break; 458 case PROTO_MMCSD: strDeviceStringMMCSD(pDevResult, szDesc, sizeof(szDesc)); break; 459 case PROTO_SEMB: strDeviceStringSEMB( pDevResult, szDesc, sizeof(szDesc)); break; 460 case PROTO_NVME: strDeviceStringNVME( pDevResult, szDesc, sizeof(szDesc)); break; 461 default: break; 462 } 463 464 try 465 { 466 pList->push_back(DriveInfo(szPath, "", szDesc)); 467 } 468 catch (std::bad_alloc &) 469 { 470 pList->clear(); 471 rc = VERR_NO_MEMORY; 472 break; 473 } 309 474 if (pfSuccess) 310 475 *pfSuccess = true; … … 312 477 } 313 478 } 314 } while ( (DeviceCCB.ccb_h.status == CAM_REQ_CMP) 315 && (DeviceCCB.cdm.status == CAM_DEV_MATCH_MORE)); 479 } while ( DeviceCCB.ccb_h.status == CAM_REQ_CMP 480 && DeviceCCB.cdm.status == CAM_DEV_MATCH_MORE 481 && RT_SUCCESS(rc)); 316 482 317 483 RTMemFree(paMatches); … … 320 486 rc = VERR_NO_MEMORY; 321 487 322 RTFileClose( FileXpt);488 RTFileClose(hFileXpt); 323 489 } 324 490 325 491 return rc; 326 492 } 493 327 494 328 495 /** 329 496 * Extract the names of drives from an environment variable and add them to a 330 497 * list if they are valid. 498 * 331 499 * @returns iprt status code 332 500 * @param pcszVar the name of the environment variable. The variable … … 337 505 * @param pfSuccess this will be set to true if we found at least one drive 338 506 * and to false otherwise. Optional. 507 * 508 * @note This is duplicated in HostHardwareLinux.cpp. 339 509 */ 340 static int getDriveInfoFromEnv(const char *pcszVar, DriveInfoList *pList, 341 bool isDVD, bool *pfSuccess) 510 static int getDriveInfoFromEnv(const char *pcszVar, DriveInfoList *pList, bool isDVD, bool *pfSuccess) RT_NOTHROW_DEF 342 511 { 343 512 AssertPtrReturn(pcszVar, VERR_INVALID_POINTER); 344 513 AssertPtrReturn(pList, VERR_INVALID_POINTER); 345 514 AssertPtrNullReturn(pfSuccess, VERR_INVALID_POINTER); 346 LogFlowFunc(("pcszVar=%s, pList=%p, isDVD=%d, pfSuccess=%p\n", pcszVar, 347 pList, isDVD, pfSuccess)); 515 LogFlowFunc(("pcszVar=%s, pList=%p, isDVD=%d, pfSuccess=%p\n", pcszVar, pList, isDVD, pfSuccess)); 348 516 int rc = VINF_SUCCESS; 349 517 bool success = false; … … 352 520 try 353 521 { 354 c onst char *pcszCurrent = pszFreeMe;355 while (p cszCurrent && *pcszCurrent != '\0')522 char *pszCurrent = pszFreeMe; 523 while (pszCurrent && *pszCurrent != '\0') 356 524 { 357 const char *pcszNext = strchr(pcszCurrent, ':'); 358 char szPath[RTPATH_MAX], szReal[RTPATH_MAX]; 359 char szDesc[256], szUdi[256]; 360 if (pcszNext) 361 RTStrPrintf(szPath, sizeof(szPath), "%.*s", 362 pcszNext - pcszCurrent - 1, pcszCurrent); 363 else 364 RTStrPrintf(szPath, sizeof(szPath), "%s", pcszCurrent); 365 if (RT_SUCCESS(RTPathReal(szPath, szReal, sizeof(szReal)))) 525 char *pszNext = strchr(pszCurrent, ':'); 526 if (pszNext) 527 *pszNext++ = '\0'; 528 529 char szReal[RTPATH_MAX]; 530 char szDesc[1] = "", szUdi[1] = ""; /* differs on freebsd because no devValidateDevice */ 531 if ( RT_SUCCESS(RTPathReal(pszCurrent, szReal, sizeof(szReal))) 532 /*&& devValidateDevice(szReal, isDVD, NULL, szDesc, sizeof(szDesc), szUdi, sizeof(szUdi)) - linux only */) 366 533 { 367 szUdi[0] = '\0'; /** @todo r=bird: missing a call to devValidateDevice() here and szUdi wasn't368 * initialized because of that. Need proper fixing. */369 534 pList->push_back(DriveInfo(szReal, szUdi, szDesc)); 370 535 success = true; 371 536 } 372 p cszCurrent = pcszNext ? pcszNext + 1 : NULL;537 pszCurrent = pszNext; 373 538 } 374 539 if (pfSuccess != NULL) 375 540 *pfSuccess = success; 376 541 } 377 catch (std::bad_alloc &e)542 catch (std::bad_alloc &) 378 543 { 379 544 rc = VERR_NO_MEMORY; … … 383 548 return rc; 384 549 } 550
Note:
See TracChangeset
for help on using the changeset viewer.