Changeset 1708 in vbox
- Timestamp:
- Mar 26, 2007 5:54:16 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 19859
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvHostRawDisk.cpp
r1695 r1708 37 37 #include <iprt/string.h> 38 38 39 #ifdef __LINUX__ 39 #ifdef __WIN32__ 40 #include <windows.h> 41 #include <winioctl.h> 42 #elif __LINUX__ 40 43 #include <errno.h> 41 44 #include <sys/ioctl.h> 42 45 #include <linux/hdreg.h> 43 46 #include <linux/fs.h> 44 #endif /* __LINUX__ */47 #endif /* !__WIN32__ && !__LINUX__ */ 45 48 46 49 #include "Builtins.h" … … 326 329 pThis->cSectors = 0; 327 330 pThis->enmTranslation = PDMBIOSTRANSLATION_AUTO; 328 #if 0 /* def __WIN__ */331 #ifdef __WIN32__ 329 332 DISK_GEOMETRY DriveGeo; 330 uint32_tcbDriveGeo;331 if (DeviceI OControl((HANDLE)pThis->HostDiskFile,332 IOCTL_DISK_GET_ GET_DRIVE_GEOMETRY, NULL, 0,333 DWORD cbDriveGeo; 334 if (DeviceIoControl((HANDLE)pThis->HostDiskFile, 335 IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, 333 336 &DriveGeo, sizeof(DriveGeo), &cbDriveGeo, NULL)) 334 #elif __LINUX__ 337 { 338 if (DriveGeo.MediaType == FixedMedia) 339 { 340 pThis->cCylinders = DriveGeo.Cylinders.QuadPart; 341 pThis->cHeads = DriveGeo.TracksPerCylinder; 342 pThis->cSectors = DriveGeo.SectorsPerTrack; 343 pThis->enmTranslation = PDMBIOSTRANSLATION_NONE; 344 if (!pThis->cbSize) 345 { 346 /* Windows NT has no IOCTL_DISK_GET_LENGTH_INFORMATION 347 * ioctl. This was added to Windows XP, so use the 348 * available info from DriveGeo. */ 349 pThis->cbSize = DriveGeo.Cylinders.QuadPart 350 * DriveGeo.TracksPerCylinder 351 * DriveGeo.SectorsPerTrack 352 * DriveGeo.BytesPerSector; 353 } 354 } 355 else 356 rc = VERR_MEDIA_NOT_RECOGNIZED; 357 } 358 else 359 rc = RTErrConvertFromWin32(GetLastError()); 360 #elif defined(__LINUX__) 335 361 struct hd_geometry DriveGeo; 336 if (ioctl(pThis->HostDiskFile, HDIO_GETGEO, &DriveGeo) < 0) 337 rc = RTErrConvertFromErrno(errno); 338 else 362 if (!ioctl(pThis->HostDiskFile, HDIO_GETGEO, &DriveGeo)) 339 363 { 340 364 pThis->cCylinders = DriveGeo.cylinders; … … 347 371 if (!ioctl(pThis->HostDiskFile, BLKGETSIZE, &cBlocks)) 348 372 pThis->cbSize = (uint64_t)cBlocks * 512; 373 else 374 rc = RTErrConvertFromErrno(errno); 349 375 } 350 376 } 377 else 378 rc = RTErrConvertFromErrno(errno); 379 #else 380 /** @todo add further host OS geometry detection mechanisms. */ 381 AssertMsgFail("Host disk support for this host is unimplemented.\n"); 382 rc = VERR_NOT_IMPLEMENTED; 351 383 #endif 352 /** @todo add further host OS geometry detection mechanisms. */353 384 } 354 385
Note:
See TracChangeset
for help on using the changeset viewer.