Changeset 1740 in vbox
- Timestamp:
- Mar 27, 2007 4:21:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvHostRawDisk.cpp
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Author Date Id Revision
r1717 r1740 43 43 #include <errno.h> 44 44 #include <sys/ioctl.h> 45 #include <sys/types.h> 46 #include <sys/stat.h> 47 #include <unistd.h> 45 48 #include <linux/hdreg.h> 46 49 #include <linux/fs.h> … … 341 344 pThis->cHeads = DriveGeo.TracksPerCylinder; 342 345 pThis->cSectors = DriveGeo.SectorsPerTrack; 343 pThis->enmTranslation = PDMBIOSTRANSLATION_NONE;344 346 if (!pThis->cbSize) 345 347 { … … 359 361 rc = RTErrConvertFromWin32(GetLastError()); 360 362 #elif defined(__LINUX__) 361 struct hd_geometry DriveGeo;362 if (! ioctl(pThis->HostDiskFile, HDIO_GETGEO, &DriveGeo))363 struct stat DevStat; 364 if (!fstat(pThis->HostDiskFile, &DevStat) && S_ISBLK(DevStat.st_mode)) 363 365 { 364 pThis->cCylinders = DriveGeo.cylinders; 365 pThis->cHeads = DriveGeo.heads; 366 pThis->cSectors = DriveGeo.sectors; 367 pThis->enmTranslation = PDMBIOSTRANSLATION_NONE; 368 if (!pThis->cbSize) 366 struct hd_geometry DriveGeo; 367 if (!ioctl(pThis->HostDiskFile, HDIO_GETGEO, &DriveGeo)) 369 368 { 370 long cBlocks; 371 if (!ioctl(pThis->HostDiskFile, BLKGETSIZE, &cBlocks)) 372 pThis->cbSize = (uint64_t)cBlocks * 512; 373 else 374 rc = RTErrConvertFromErrno(errno); 369 pThis->cCylinders = DriveGeo.cylinders; 370 pThis->cHeads = DriveGeo.heads; 371 pThis->cSectors = DriveGeo.sectors; 372 if (!pThis->cbSize) 373 { 374 long cBlocks; 375 if (!ioctl(pThis->HostDiskFile, BLKGETSIZE, &cBlocks)) 376 pThis->cbSize = (uint64_t)cBlocks * 512; 377 else 378 rc = RTErrConvertFromErrno(errno); 379 } 375 380 } 381 else 382 rc = RTErrConvertFromErrno(errno); 376 383 } 377 else378 rc = RTErrConvertFromErrno(errno);379 384 #else 380 385 /** @todo add further host OS geometry detection mechanisms. */ … … 382 387 rc = VERR_NOT_IMPLEMENTED; 383 388 #endif 389 /* Do geometry cleanup common to all host operating systems. 390 * Very important, as Windows guests are very sensitive to odd 391 * PCHS settings, and for big disks they consider anything 392 * except the standard mapping as odd. */ 393 if (pThis->cCylinders != 0) 394 { 395 if (pThis->cSectors == 63 && pThis->cCylinders >= 1024) 396 { 397 /* For big disks, use dummy PCHS values and let the BIOS 398 * select an appropriate LCHS mapping. */ 399 pThis->cCylinders = pThis->cbSize / 512 / 63 / 16; 400 pThis->cHeads = 16; 401 pThis->cSectors = 63; 402 pThis->enmTranslation = PDMBIOSTRANSLATION_LBA; 403 } 404 else 405 pThis->enmTranslation = PDMBIOSTRANSLATION_NONE; 406 } 384 407 } 385 408 -
Property svn:eol-style
set to
Note:
See TracChangeset
for help on using the changeset viewer.