- Timestamp:
- Sep 26, 2002, 6:06:07 PM (23 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/disk.cpp
r8409 r9298 1 /* $Id: disk.cpp,v 1.3 7 2002-05-14 09:28:19sandervl Exp $ */1 /* $Id: disk.cpp,v 1.38 2002-09-26 16:06:06 sandervl Exp $ */ 2 2 3 3 /* … … 570 570 char szVolume[256]; 571 571 572 //tetsetsetetsetsetset573 SetLastError(ERROR_NO_MORE_FILES);574 return FALSE;575 //tetsetsetetsetsetset576 577 572 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 578 573 SetLastError(ERROR_NOT_SUPPORTED); … … 654 649 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 655 650 SetLastError(ERROR_NOT_SUPPORTED); 656 return FALSE;651 return INVALID_HANDLE_VALUE; 657 652 } 658 653 659 654 SetLastError(ERROR_NO_MORE_FILES); 660 return 0;655 return INVALID_HANDLE_VALUE; 661 656 } 662 657 //****************************************************************************** … … 672 667 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 673 668 SetLastError(ERROR_NOT_SUPPORTED); 674 return FALSE;669 return INVALID_HANDLE_VALUE; 675 670 } 676 671 -
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", -
trunk/src/kernel32/oslibdos.cpp
r9095 r9298 1 /* $Id: oslibdos.cpp,v 1.10 8 2002-08-22 14:21:26sandervl Exp $ */1 /* $Id: oslibdos.cpp,v 1.109 2002-09-26 16:06:07 sandervl Exp $ */ 2 2 /* 3 3 * Wrappers for OS/2 Dos* API … … 996 996 // @@@AH 2001-06-02 Win2k SP2 returns error 2 in this case 997 997 int winError = error2WinError(rc); 998 if (winError == ERROR_OPEN_FAILED_W )998 if (winError == ERROR_OPEN_FAILED_W || winError == ERROR_PATH_NOT_FOUND_W) 999 999 winError = ERROR_FILE_NOT_FOUND_W; 1000 1000 SetLastError(winError); … … 2473 2473 //****************************************************************************** 2474 2474 //****************************************************************************** 2475 BOOL 2475 BOOL OSLibDosGetDiskGeometry(HANDLE hDisk, DWORD cDisk, PVOID pdiskgeom) 2476 2476 { 2477 2477 PDISK_GEOMETRY pGeom = (PDISK_GEOMETRY)pdiskgeom; … … 2487 2487 if(rc == 0) 2488 2488 { 2489 pGeom->SectorsPerTrack = bpb.usSectorsPerTrack;2490 pGeom->BytesPerSector = bpb.usBytesPerSector;2491 pGeom->TracksPerCylinder = 80; //TODO:!!!!!2492 pGeom->Cylinders.u.LowPart = bpb.cCylinders;2493 pGeom->Cylinders.u.HighPart = 0;2494 switch(bpb.bDeviceType) {2495 case DEVTYPE_48TPI:2496 pGeom->MediaType = F5_360_512; //?????2497 break;2498 case DEVTYPE_96TPI:2499 pGeom->MediaType = F5_1Pt2_512; //?????2500 break;2501 case DEVTYPE_35:2502 pGeom->MediaType = F3_720_512;2503 break;2504 case DEVTYPE_8SD:2505 case DEVTYPE_8DD:2506 pGeom->MediaType = RemovableMedia;2507 break;2508 case DEVTYPE_FIXED:2509 pGeom->MediaType = FixedMedia;2510 break;2511 case DEVTYPE_TAPE:2512 pGeom->MediaType = RemovableMedia;2513 break;2514 case DEVTYPE_UNKNOWN: //others, include 1.44 3.5 inch disk drive2515 pGeom->MediaType = F3_1Pt44_512;2516 break;2517 case 8: //RW optical disk2518 pGeom->MediaType = RemovableMedia;2519 break;2520 case 9: //2.88 3.5 inch disk2521 pGeom->MediaType = F3_2Pt88_512;2522 break;2523 }2524 SetLastError(ERROR_SUCCESS_W);2525 return TRUE;2489 pGeom->SectorsPerTrack = bpb.usSectorsPerTrack; 2490 pGeom->BytesPerSector = bpb.usBytesPerSector; 2491 pGeom->TracksPerCylinder = 80; //TODO:!!!!! 2492 pGeom->Cylinders.u.LowPart = bpb.cCylinders; 2493 pGeom->Cylinders.u.HighPart = 0; 2494 switch(bpb.bDeviceType) { 2495 case DEVTYPE_48TPI: 2496 pGeom->MediaType = F5_360_512; //????? 2497 break; 2498 case DEVTYPE_96TPI: 2499 pGeom->MediaType = F5_1Pt2_512; //????? 2500 break; 2501 case DEVTYPE_35: 2502 pGeom->MediaType = F3_720_512; 2503 break; 2504 case DEVTYPE_8SD: 2505 case DEVTYPE_8DD: 2506 pGeom->MediaType = RemovableMedia; 2507 break; 2508 case DEVTYPE_FIXED: 2509 pGeom->MediaType = FixedMedia; 2510 break; 2511 case DEVTYPE_TAPE: 2512 pGeom->MediaType = RemovableMedia; 2513 break; 2514 case DEVTYPE_UNKNOWN: //others, include 1.44 3.5 inch disk drive 2515 pGeom->MediaType = F3_1Pt44_512; 2516 break; 2517 case 8: //RW optical disk 2518 pGeom->MediaType = RemovableMedia; 2519 break; 2520 case 9: //2.88 3.5 inch disk 2521 pGeom->MediaType = F3_2Pt88_512; 2522 break; 2523 } 2524 SetLastError(ERROR_SUCCESS_W); 2525 return TRUE; 2526 2526 } 2527 2527 dprintf(("OSLibDosGetDiskGeometry: error %d -> %d", rc, error2WinError(rc))); -
trunk/src/kernel32/osliblvm.cpp
r8401 r9298 1 /* $Id: osliblvm.cpp,v 1. 2 2002-05-10 14:55:13sandervl Exp $ */1 /* $Id: osliblvm.cpp,v 1.3 2002-09-26 16:06:07 sandervl Exp $ */ 2 2 3 3 /* … … 319 319 return FALSE; //no more volumes 320 320 } 321 volinfo = Get_Volume_Information(volctrl->Volume_Control_Data[volindex].Volume_Handle, &lasterror); 322 if(lasterror != LVM_ENGINE_NO_ERROR) { 323 DebugInt3(); 324 return FALSE; 321 while(volindex < volctrl->Count) { 322 volinfo = Get_Volume_Information(volctrl->Volume_Control_Data[volindex].Volume_Handle, &lasterror); 323 if(lasterror != LVM_ENGINE_NO_ERROR) { 324 DebugInt3(); 325 return FALSE; 326 } 327 //Don't report anything about LVM volumes until we support all those 328 //fancy features (like spanned volumes) 329 if(volinfo.Compatibility_Volume == TRUE) break; 330 dprintf(("Ignoring LVM volume %s", volinfo.Volume_Name)); 331 volindex++; 332 } 333 if(volindex >= volctrl->Count) { 334 return FALSE; //no more volumes 325 335 } 326 336 strncpy(lpszVolumeName, volinfo.Volume_Name, min(sizeof(volinfo.Volume_Name), cchBufferLength)-1); … … 428 438 pPartition->StartingOffset.u.HighPart = partctrl.Partition_Array[0].Partition_Start >> 23; 429 439 pPartition->StartingOffset.u.LowPart = partctrl.Partition_Array[0].Partition_Start << 9; 440 // pPartition->PartitionLength.u.HighPart= partctrl.Partition_Array[0].True_Partition_Size >> 23; 441 // pPartition->PartitionLength.u.LowPart = partctrl.Partition_Array[0].True_Partition_Size << 9; 442 // pPartition->HiddenSectors = 0; 430 443 pPartition->PartitionLength.u.HighPart= partctrl.Partition_Array[0].Usable_Partition_Size >> 23; 431 444 pPartition->PartitionLength.u.LowPart = partctrl.Partition_Array[0].Usable_Partition_Size << 9; … … 466 479 } 467 480 481 //TODO: spanned volumes 468 482 pVolExtent->NumberOfDiskExtents = 1; 469 483 pVolExtent->Extents[0].DiskNumber = 0; 470 484 pVolExtent->Extents[0].StartingOffset.u.HighPart = partctrl.Partition_Array[0].Partition_Start >> 23;; 471 485 pVolExtent->Extents[0].StartingOffset.u.LowPart = partctrl.Partition_Array[0].Partition_Start << 9; 486 // pVolExtent->Extents[0].ExtentLength.u.HighPart = partctrl.Partition_Array[0].True_Partition_Size >> 23; 487 // pVolExtent->Extents[0].ExtentLength.u.LowPart = partctrl.Partition_Array[0].True_Partition_Size << 9; 472 488 pVolExtent->Extents[0].ExtentLength.u.HighPart = partctrl.Partition_Array[0].Usable_Partition_Size >> 23; 473 489 pVolExtent->Extents[0].ExtentLength.u.LowPart = partctrl.Partition_Array[0].Usable_Partition_Size << 9; 474 490 491 //find number of disk on which this volume is located 492 diskinfo = Get_Drive_Control_Data(&lasterror); 493 if(lasterror != LVM_ENGINE_NO_ERROR) { 494 return FALSE; 495 } 496 for(int i=0;i<diskinfo.Count;i++) { 497 if(diskinfo.Drive_Control_Data[i].Drive_Handle == partctrl.Partition_Array[0].Drive_Handle) { 498 //win32 base = 0, os2 base = 1 499 pVolExtent->Extents[0].DiskNumber = diskinfo.Drive_Control_Data[i].Drive_Number - 1; 500 #ifdef DEBUG 501 if(diskinfo.Drive_Control_Data[i].Drive_Number == 0) DebugInt3(); 502 #endif 503 break; 504 } 505 } 506 if(i == diskinfo.Count) { 507 ret = FALSE; 508 } 475 509 dprintf(("pVolExtent->NumberOfDiskExtents %d", pVolExtent->NumberOfDiskExtents)); 476 510 dprintf(("pVolExtent->Extents[0].DiskNumber %d", pVolExtent->Extents[0].DiskNumber)); … … 478 512 dprintf(("pVolExtent->Extents[0].ExtentLength %08x%08x", pVolExtent->Extents[0].ExtentLength.u.HighPart, pVolExtent->Extents[0].ExtentLength.u.LowPart)); 479 513 480 //find number of disk on which this volume is located481 diskinfo = Get_Drive_Control_Data(&lasterror);482 if(lasterror != LVM_ENGINE_NO_ERROR) {483 return FALSE;484 }485 for(int i=0;i<diskinfo.Count;i++) {486 if(diskinfo.Drive_Control_Data[i].Drive_Handle == partctrl.Partition_Array[0].Drive_Handle) {487 pVolExtent->Extents[0].DiskNumber = diskinfo.Drive_Control_Data[i].Drive_Number;488 break;489 }490 }491 if(i == diskinfo.Count) {492 ret = FALSE;493 }494 514 if(pfLVMVolume) { 495 515 *pfLVMVolume = (volinfo.Compatibility_Volume == FALSE); … … 655 675 //****************************************************************************** 656 676 //****************************************************************************** 657 677 BOOL OSLibLVMGetDiskGeometry(DWORD dwDiskNr, PDISK_GEOMETRY pGeom) 678 { 679 Drive_Control_Array driveinfo; 680 Drive_Control_Record *pDriveRec; 681 CARDINAL32 lasterror; 682 BOOL ret = FALSE; 683 int i; 684 685 driveinfo = Get_Drive_Control_Data(&lasterror); 686 if(lasterror != LVM_ENGINE_NO_ERROR) { 687 DebugInt3(); 688 return FALSE; 689 } 690 pDriveRec = driveinfo.Drive_Control_Data; 691 if(pDriveRec == NULL) { 692 DebugInt3(); 693 return FALSE; 694 } 695 if(dwDiskNr > driveinfo.Count) { 696 DebugInt3(); 697 ret = FALSE; 698 goto endfunc; 699 } 700 for(i=0;i<driveinfo.Count;i++) { 701 if(pDriveRec->Drive_Number == dwDiskNr) { 702 pGeom->Cylinders.u.LowPart = pDriveRec->Cylinder_Count; 703 pGeom->Cylinders.u.HighPart = 0; 704 pGeom->TracksPerCylinder = pDriveRec->Heads_Per_Cylinder; 705 pGeom->SectorsPerTrack = pDriveRec->Sectors_Per_Track; 706 pGeom->BytesPerSector = 512; 707 pGeom->MediaType = FixedMedia; 708 709 ret = TRUE; 710 break; 711 } 712 } 713 endfunc: 714 Free_Engine_Memory((ULONG)driveinfo.Drive_Control_Data); 715 return ret; 716 } 717 //****************************************************************************** 718 //****************************************************************************** -
trunk/src/kernel32/osliblvm.h
r8401 r9298 1 /* $Id: osliblvm.h,v 1. 2 2002-05-10 14:55:13sandervl Exp $ */1 /* $Id: osliblvm.h,v 1.3 2002-09-26 16:06:07 sandervl Exp $ */ 2 2 /* 3 3 * OS/2 LVM (Logical Volume Management) functions … … 343 343 344 344 BOOL OSLibLVMStripVolumeName(LPCSTR lpszWin32VolumeName, LPSTR lpszOS2VolumeName, DWORD cchBufferLength); 345 BOOL OSLibLVMGetDiskGeometry(DWORD dwDiskNr, PDISK_GEOMETRY pGeom); 345 346 346 347 #endif //__OSLIBLVM_H__
Note:
See TracChangeset
for help on using the changeset viewer.