Changeset 9298 for trunk/src/kernel32/hmdisk.cpp
- Timestamp:
- Sep 26, 2002, 6:06:07 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmdisk.cpp
r8980 r9298 1 /* $Id: hmdisk.cpp,v 1.5 2 2002-08-09 13:17:22sandervl Exp $ */1 /* $Id: hmdisk.cpp,v 1.53 2002-09-26 16:06:06 sandervl Exp $ */ 2 2 3 3 /* … … 52 52 HFILE hTemplate; 53 53 BOOL fPhysicalDisk; 54 DWORD dwPhysicalDiskNr; 54 55 BOOL fCDPlaying; 55 56 BOOL fShareViolation; … … 134 135 VOLUME_DISK_EXTENTS volext = {0}; 135 136 BOOL fPhysicalDisk = FALSE; 137 DWORD dwPhysicalDiskNr = 0; 136 138 137 139 dprintf2(("KERNEL32: HMDeviceDiskClass::CreateFile %s(%s,%08x,%08x,%08x)\n", … … 174 176 175 177 //Note: this only works on Warp 4.5 and up 176 sprintf(szDiskName, "\\\\.\\Physical_Disk%d", volext.Extents[0].DiskNumber); 177 fPhysicalDisk = TRUE; 178 sprintf(szDiskName, "\\\\.\\Physical_Disk%d", volext.Extents[0].DiskNumber+1); 179 fPhysicalDisk = TRUE; 180 dwPhysicalDiskNr = volext.Extents[0].DiskNumber + 1; 178 181 179 182 if(fLVMVolume && (pHMHandleData->dwAccess & GENERIC_WRITE)) { … … 199 202 { 200 203 //Note: this only works on Warp 4.5 and up 201 sprintf(szDiskName, "\\\\.\\Physical_Disk%c", lpFileName[17]); 202 fPhysicalDisk = TRUE; 204 sprintf(szDiskName, "\\\\.\\Physical_Disk%c", lpFileName[17]+1); 205 fPhysicalDisk = TRUE; 206 dwPhysicalDiskNr = (DWORD)(lpFileName[17] - '0')+1; 203 207 204 208 //TODO: could be removable in theory … … 285 289 //save volume start & length if volume must be accessed through the physical disk 286 290 //(no other choice for unmounted volumes) 287 drvInfo->fPhysicalDisk = fPhysicalDisk; 288 drvInfo->StartingOffset = volext.Extents[0].StartingOffset; 289 drvInfo->PartitionSize = volext.Extents[0].ExtentLength; 291 drvInfo->fPhysicalDisk = fPhysicalDisk; 292 drvInfo->dwPhysicalDiskNr = dwPhysicalDiskNr; 293 drvInfo->StartingOffset = volext.Extents[0].StartingOffset; 294 drvInfo->PartitionSize = volext.Extents[0].ExtentLength; 290 295 291 296 //save volume name for later (IOCtls) … … 891 896 } 892 897 893 if(OSLibDosGetDiskGeometry(pHMHandleData->hHMHandle, drvInfo->driveLetter, pGeom) == FALSE) { 894 dprintf(("!ERROR!: IOCTL_DISK_GET_DRIVE_GEOMETRY: OSLibDosGetDiskGeometry failed!!")); 895 return FALSE; 898 if(drvInfo->fPhysicalDisk) { 899 if(OSLibLVMGetDiskGeometry(drvInfo->dwPhysicalDiskNr, pGeom) == FALSE) { 900 dprintf(("!ERROR!: IOCTL_DISK_GET_DRIVE_GEOMETRY: OSLibDosGetDiskGeometry failed!!")); 901 return FALSE; 902 } 903 } 904 else { 905 if(OSLibDosGetDiskGeometry(pHMHandleData->hHMHandle, drvInfo->driveLetter, pGeom) == FALSE) { 906 dprintf(("!ERROR!: IOCTL_DISK_GET_DRIVE_GEOMETRY: OSLibDosGetDiskGeometry failed!!")); 907 return FALSE; 908 } 896 909 } 897 910 dprintf(("Cylinders %d", pGeom->Cylinders)); … … 1649 1662 DWORD offset, bytesread; 1650 1663 BOOL bRC; 1664 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1651 1665 1652 1666 dprintf2(("KERNEL32: HMDeviceDiskClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x)", … … 1671 1685 //If we didn't get an OS/2 handle for the disk before, get one now 1672 1686 if(!pHMHandleData->hHMHandle) { 1673 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData;1674 1687 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1675 1688 if(!pHMHandleData->hHMHandle) { … … 1700 1713 else lpRealBuf = (LPVOID)lpBuffer; 1701 1714 1715 //if unmounted volume, check upper boundary as we're accessing the entire physical drive 1716 //instead of just the volume 1717 if(drvInfo->fPhysicalDisk && (drvInfo->StartingOffset.HighPart != 0 || 1718 drvInfo->StartingOffset.LowPart != 0)) 1719 { 1720 LARGE_INTEGER distance, result, endpos; 1721 1722 //calculate end position in partition 1723 Add64(&drvInfo->StartingOffset, &drvInfo->PartitionSize, &endpos); 1724 1725 distance.HighPart = 0; 1726 distance.LowPart = nNumberOfBytesToRead; 1727 Add64(&distance, &drvInfo->CurrentFilePointer, &result); 1728 1729 //check upper boundary 1730 if(result.HighPart > endpos.HighPart || 1731 (result.HighPart == endpos.HighPart && result.LowPart > endpos.LowPart) ) 1732 { 1733 Sub64(&endpos, &drvInfo->CurrentFilePointer, &result); 1734 nNumberOfBytesToRead = result.LowPart; 1735 dprintf(("Read past end of volume; nNumberOfBytesToRead reduced to %d", nNumberOfBytesToRead)); 1736 DebugInt3(); 1737 } 1738 } 1739 1702 1740 if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) { 1703 1741 dprintf(("ERROR: Overlapped IO not yet implememented!!")); … … 1715 1753 } 1716 1754 else dprintf2(("KERNEL32: HMDeviceDiskClass::ReadFile read %x bytes pos %x", *lpNumberOfBytesRead, SetFilePointer(pHMHandleData, 0, NULL, FILE_CURRENT))); 1755 1756 //if unmounted volume, add starting offset to position as we're accessing the entire physical drive 1757 //instead of just the volume 1758 if(drvInfo->fPhysicalDisk && (drvInfo->StartingOffset.HighPart != 0 || 1759 drvInfo->StartingOffset.LowPart != 0) && bRC == TRUE) 1760 { 1761 LARGE_INTEGER distance, result; 1762 1763 distance.HighPart = 0; 1764 distance.LowPart = *lpNumberOfBytesRead; 1765 Add64(&distance, &drvInfo->CurrentFilePointer, &result); 1766 drvInfo->CurrentFilePointer = result; 1767 1768 dprintf(("New unmounted volume current file pointer %08x%08x", drvInfo->CurrentFilePointer.HighPart, drvInfo->CurrentFilePointer.LowPart)); 1769 } 1717 1770 1718 1771 return bRC; … … 1927 1980 else lpRealBuf = (LPVOID)lpBuffer; 1928 1981 1982 //if unmounted volume, check upper boundary as we're accessing the entire physical drive 1983 //instead of just the volume 1984 if(drvInfo->fPhysicalDisk && (drvInfo->StartingOffset.HighPart != 0 || 1985 drvInfo->StartingOffset.LowPart != 0)) 1986 { 1987 LARGE_INTEGER distance, result, endpos; 1988 1989 //calculate end position in partition 1990 Add64(&drvInfo->StartingOffset, &drvInfo->PartitionSize, &endpos); 1991 1992 distance.HighPart = 0; 1993 distance.LowPart = nNumberOfBytesToWrite; 1994 Add64(&distance, &drvInfo->CurrentFilePointer, &result); 1995 1996 //check upper boundary 1997 if(result.HighPart > endpos.HighPart || 1998 (result.HighPart == endpos.HighPart && result.LowPart > endpos.LowPart) ) 1999 { 2000 Sub64(&endpos, &drvInfo->CurrentFilePointer, &result); 2001 nNumberOfBytesToWrite = result.LowPart; 2002 dprintf(("Write past end of volume; nNumberOfBytesToWrite reduced to %d", nNumberOfBytesToWrite)); 2003 DebugInt3(); 2004 } 2005 } 2006 1929 2007 if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) { 1930 2008 dprintf(("ERROR: Overlapped IO not yet implememented!!")); … … 1936 2014 lpNumberOfBytesWritten); 1937 2015 // } 2016 2017 //if unmounted volume, add starting offset to position as we're accessing the entire physical drive 2018 //instead of just the volume 2019 if(drvInfo->fPhysicalDisk && (drvInfo->StartingOffset.HighPart != 0 || 2020 drvInfo->StartingOffset.LowPart != 0) && bRC == TRUE) 2021 { 2022 LARGE_INTEGER distance, result; 2023 2024 distance.HighPart = 0; 2025 distance.LowPart = *lpNumberOfBytesWritten; 2026 Add64(&distance, &drvInfo->CurrentFilePointer, &result); 2027 drvInfo->CurrentFilePointer = result; 2028 2029 dprintf(("New unmounted volume current file pointer %08x%08x", drvInfo->CurrentFilePointer.HighPart, drvInfo->CurrentFilePointer.LowPart)); 2030 } 1938 2031 1939 2032 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile returned %08xh\n",
Note:
See TracChangeset
for help on using the changeset viewer.