Changeset 8401 for trunk/src/kernel32/osliblvm.cpp
- Timestamp:
- May 10, 2002, 4:55:13 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/osliblvm.cpp
r8397 r8401 1 /* $Id: osliblvm.cpp,v 1. 1 2002-05-09 13:55:34sandervl Exp $ */1 /* $Id: osliblvm.cpp,v 1.2 2002-05-10 14:55:13 sandervl Exp $ */ 2 2 3 3 /* … … 329 329 //****************************************************************************** 330 330 //****************************************************************************** 331 static Volume_Information_Record OSLibLVMFindVolume FromDriveLetter(ULONG driveLetter,332 333 331 static Volume_Information_Record OSLibLVMFindVolumeByDriveLetter(ULONG driveLetter, 332 Volume_Control_Record *pVolRec, 333 CARDINAL32 *lasterror) 334 334 { 335 335 Volume_Control_Array *volctrl; … … 367 367 //****************************************************************************** 368 368 //****************************************************************************** 369 static Volume_Information_Record OSLibLVMFindVolume FromName(LPSTR pszVolName,370 371 369 static Volume_Information_Record OSLibLVMFindVolumeByName(LPSTR pszVolName, 370 Volume_Control_Record *pVolRec, 371 CARDINAL32 *lasterror) 372 372 { 373 373 Volume_Control_Array *volctrl; … … 405 405 //****************************************************************************** 406 406 //****************************************************************************** 407 BOOL OSLibLVMGetPartitionInfo(ULONG driveLetter, PPARTITION_INFORMATION pPartition)407 BOOL OSLibLVMGetPartitionInfo(ULONG driveLetter, LPSTR lpszVolumeName, PPARTITION_INFORMATION pPartition) 408 408 { 409 409 Volume_Information_Record volinfo; … … 412 412 CARDINAL32 lasterror; 413 413 414 volinfo = OSLibLVMFindVolumeFromDriveLetter(driveLetter, &volctrl, &lasterror); 415 if(lasterror != LVM_ENGINE_NO_ERROR) { 416 DebugInt3(); 417 return FALSE; 418 } 419 420 //We will not return information about LVM volumes (too dangerous as 421 //they contain extra information in the volume and can be spanned) 422 if(volinfo.Compatibility_Volume == FALSE) { 414 if(lpszVolumeName && lpszVolumeName[0]) { 415 volinfo = OSLibLVMFindVolumeByName(lpszVolumeName, &volctrl, &lasterror); 416 } 417 else volinfo = OSLibLVMFindVolumeByDriveLetter(driveLetter, &volctrl, &lasterror); 418 if(lasterror != LVM_ENGINE_NO_ERROR) { 419 DebugInt3(); 423 420 return FALSE; 424 421 } 425 422 426 423 partctrl = Get_Partitions(volctrl.Volume_Handle, &lasterror); 427 if(lasterror != LVM_ENGINE_NO_ERROR ) {424 if(lasterror != LVM_ENGINE_NO_ERROR || partctrl.Count == 0) { 428 425 return FALSE; 429 426 } … … 445 442 //****************************************************************************** 446 443 //****************************************************************************** 447 BOOL OSLibLVMGetVolumeExtents(ULONG driveLetter, PVOLUME_DISK_EXTENTS pVolExtent) 444 BOOL OSLibLVMGetVolumeExtents(ULONG driveLetter, LPSTR lpszVolumeName, PVOLUME_DISK_EXTENTS pVolExtent, 445 BOOL *pfLVMVolume) 448 446 { 449 447 Volume_Information_Record volinfo; 450 448 Volume_Control_Record volctrl; 449 Drive_Control_Array diskinfo; 451 450 Partition_Information_Array partctrl; 452 451 CARDINAL32 lasterror; 453 454 volinfo = OSLibLVMFindVolumeFromDriveLetter(driveLetter, &volctrl, &lasterror); 455 if(lasterror != LVM_ENGINE_NO_ERROR) { 456 DebugInt3(); 457 return FALSE; 458 } 459 //We will not return information about LVM volumes (too dangerous as 460 //they contain extra information in the volume and can be spanned) 461 if(volinfo.Compatibility_Volume == FALSE) { 452 BOOL ret = TRUE; 453 454 if(lpszVolumeName && lpszVolumeName[0]) { 455 volinfo = OSLibLVMFindVolumeByName(lpszVolumeName, &volctrl, &lasterror); 456 } 457 else volinfo = OSLibLVMFindVolumeByDriveLetter(driveLetter, &volctrl, &lasterror); 458 if(lasterror != LVM_ENGINE_NO_ERROR) { 459 DebugInt3(); 462 460 return FALSE; 463 461 } 464 462 465 463 partctrl = Get_Partitions(volctrl.Volume_Handle, &lasterror); 466 if(lasterror != LVM_ENGINE_NO_ERROR ) {464 if(lasterror != LVM_ENGINE_NO_ERROR || partctrl.Count == 0) { 467 465 return FALSE; 468 466 } … … 475 473 pVolExtent->Extents[0].ExtentLength.u.LowPart = partctrl.Partition_Array[0].Usable_Partition_Size << 9; 476 474 475 dprintf(("pVolExtent->NumberOfDiskExtents %d", pVolExtent->NumberOfDiskExtents)); 476 dprintf(("pVolExtent->Extents[0].DiskNumber %d", pVolExtent->Extents[0].DiskNumber)); 477 dprintf(("pVolExtent->Extents[0].StartingOffset %08x%08x", pVolExtent->Extents[0].StartingOffset.u.HighPart, pVolExtent->Extents[0].StartingOffset.u.LowPart)); 478 dprintf(("pVolExtent->Extents[0].ExtentLength %08x%08x", pVolExtent->Extents[0].ExtentLength.u.HighPart, pVolExtent->Extents[0].ExtentLength.u.LowPart)); 479 480 //find number of disk on which this volume is located 481 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 if(pfLVMVolume) { 495 *pfLVMVolume = (volinfo.Compatibility_Volume == FALSE); 496 } 497 Free_Engine_Memory((ULONG)diskinfo.Drive_Control_Data); 477 498 Free_Engine_Memory((ULONG)partctrl.Partition_Array); 478 return TRUE;499 return ret; 479 500 } 480 501 //****************************************************************************** … … 487 508 CARDINAL32 lasterror; 488 509 489 volinfo = OSLibLVMFindVolume FromName((char *)lpszVolume, &volctrl, &lasterror);510 volinfo = OSLibLVMFindVolumeByName((char *)lpszVolume, &volctrl, &lasterror); 490 511 if(lasterror != LVM_ENGINE_NO_ERROR) { 491 512 DebugInt3(); … … 512 533 } 513 534 //****************************************************************************** 535 // OSLibLVMQueryDriveFromVolumeName 536 // 537 // Returns: 538 // - drive letter corresponding to volume name 539 // - -1 if volume wasn't found 540 // - 0 if volume is present, but not mounted 541 // 514 542 //****************************************************************************** 515 543 CHAR OSLibLVMQueryDriveFromVolumeName(LPCSTR lpszVolume) … … 519 547 CARDINAL32 lasterror; 520 548 521 volinfo = OSLibLVMFindVolume FromName((char *)lpszVolume, NULL, &lasterror);522 if(lasterror != LVM_ENGINE_NO_ERROR) { 523 DebugInt3(); 524 return 0;549 volinfo = OSLibLVMFindVolumeByName((char *)lpszVolume, NULL, &lasterror); 550 if(lasterror != LVM_ENGINE_NO_ERROR) { 551 DebugInt3(); 552 return -1; //not found 525 553 } 526 554 return volinfo.Current_Drive_Letter; … … 533 561 CARDINAL32 lasterror; 534 562 535 volinfo = OSLibLVMFindVolume FromName(lpszVolume, NULL, &lasterror);563 volinfo = OSLibLVMFindVolumeByName(lpszVolume, NULL, &lasterror); 536 564 if(lasterror != LVM_ENGINE_NO_ERROR) { 537 565 DebugInt3(); … … 551 579 int i; 552 580 553 volinfo = OSLibLVMFindVolume FromName(lpszVolume, &volctrl, &lasterror);581 volinfo = OSLibLVMFindVolumeByName(lpszVolume, &volctrl, &lasterror); 554 582 if(lasterror != LVM_ENGINE_NO_ERROR) { 555 583 DebugInt3(); … … 576 604 //We only support drive letters as mountpoint names 577 605 if('A' <= *lpszVolumeMountPoint && *lpszVolumeMountPoint <= 'Z') { 578 drive = *lpszVolumeMountPoint - 'A' + 1;606 drive = *lpszVolumeMountPoint - 'A'; 579 607 } 580 608 else 581 609 if('a' <= *lpszVolumeMountPoint && *lpszVolumeMountPoint <= 'z') { 582 drive = *lpszVolumeMountPoint - 'a' + 1;610 drive = *lpszVolumeMountPoint - 'a'; 583 611 } 584 612 else { … … 592 620 CARDINAL32 lasterror; 593 621 594 volinfo = OSLibLVMFindVolume FromDriveLetter(drive, NULL, &lasterror);622 volinfo = OSLibLVMFindVolumeByDriveLetter(drive, NULL, &lasterror); 595 623 if(lasterror != LVM_ENGINE_NO_ERROR) { 596 624 DebugInt3(); … … 603 631 //****************************************************************************** 604 632 //****************************************************************************** 605 633 BOOL OSLibLVMStripVolumeName(LPCSTR lpszWin32VolumeName, LPSTR lpszOS2VolumeName, DWORD cchBufferLength) 634 { 635 int length; 636 637 //strip volume name prefix (\\\\?\\Volume\\) 638 length = strlen(lpszWin32VolumeName); 639 640 strncpy(lpszOS2VolumeName, &lpszWin32VolumeName[sizeof(VOLUME_NAME_PREFIX)-1+1], cchBufferLength-1); //-zero term + starting '{' 641 length -= sizeof(VOLUME_NAME_PREFIX)-1+1; 642 if(lpszOS2VolumeName[length-2] == '}') 643 { 644 lpszOS2VolumeName[length-2] = 0; 645 return TRUE; 646 } 647 else 648 if(lpszOS2VolumeName[length-1] == '}') 649 { 650 lpszOS2VolumeName[length-1] = 0; 651 return TRUE; 652 } 653 return FALSE; 654 } 655 //****************************************************************************** 656 //****************************************************************************** 657
Note:
See TracChangeset
for help on using the changeset viewer.