Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

vmcbsup.c File Reference

#include "UdfProcs.h"

Go to the source code of this file.

Defines

#define BugCheckFileId   (UDFS_BUG_CHECK_VMCBSUP)
#define Dbg   (UDFS_DEBUG_LEVEL_VMCBSUP)
#define VMCB_WRITE_SUPPORT   0
#define PageAlign(V, L)   ((((L)+((PAGE_SIZE/(V)->SectorSize)-1))/(PAGE_SIZE/(V)->SectorSize))*(PAGE_SIZE/(V)->SectorSize))

Functions

BOOLEAN UdfVmcbLookupMcbEntry (IN PMCB Mcb, IN VBN Vbn, OUT PLBN Lbn, OUT PULONG SectorCount OPTIONAL, OUT PULONG Index OPTIONAL)
VOID UdfInitializeVmcb (IN PVMCB Vmcb, IN POOL_TYPE PoolType, IN ULONG MaximumLbn, IN ULONG SectorSize)
VOID UdfUninitializeVmcb (IN PVMCB Vmcb)
VOID UdfResetVmcb (IN PVMCB Vmcb)
VOID UdfSetMaximumLbnVmcb (IN PVMCB Vmcb, IN ULONG MaximumLbn)
BOOLEAN UdfVmcbVbnToLbn (IN PVMCB Vmcb, IN VBN Vbn, IN PLBN Lbn, OUT PULONG SectorCount OPTIONAL)
BOOLEAN UdfVmcbLbnToVbn (IN PVMCB Vmcb, IN LBN Lbn, OUT PVBN Vbn, OUT PULONG SectorCount OPTIONAL)
BOOLEAN UdfAddVmcbMapping (IN PVMCB Vmcb, IN LBN Lbn, IN ULONG SectorCount, IN BOOLEAN ExactEnd, OUT PVBN Vbn, OUT PULONG AlignedSectorCount)
VOID UdfRemoveVmcbMapping (IN PVMCB Vmcb, IN VBN Vbn, IN ULONG SectorCount)


Define Documentation

#define BugCheckFileId   (UDFS_BUG_CHECK_VMCBSUP)
 

Definition at line 103 of file vmcbsup.c.

#define Dbg   (UDFS_DEBUG_LEVEL_VMCBSUP)
 

Definition at line 109 of file vmcbsup.c.

#define PageAlign V,
 )     ((((L)+((PAGE_SIZE/(V)->SectorSize)-1))/(PAGE_SIZE/(V)->SectorSize))*(PAGE_SIZE/(V)->SectorSize))
 

Definition at line 127 of file vmcbsup.c.

Referenced by UdfAddVmcbMapping().

#define VMCB_WRITE_SUPPORT   0
 

Definition at line 115 of file vmcbsup.c.


Function Documentation

BOOLEAN UdfAddVmcbMapping IN PVMCB  Vmcb,
IN LBN  Lbn,
IN ULONG  SectorCount,
IN BOOLEAN  ExactEnd,
OUT PVBN  Vbn,
OUT PULONG  AlignedSectorCount
 

Definition at line 637 of file vmcbsup.c.

References ASSERT, Dbg, DebugTrace, DebugUnwind, Executive, FALSE, FsRtlAddMcbEntry(), FsRtlLookupLastMcbEntry(), FsRtlRemoveMcbEntry(), KeReleaseMutex(), KernelMode, KeWaitForSingleObject(), LBN, NULL, PageAlign, PAGED_CODE, TRUE, try_leave, UdfRemoveVmcbMapping(), UdfVmcbLookupMcbEntry(), VBN, and VOID().

Referenced by UdfLookupMetaVsnOfExtent().

00648 : 00649 00650 This routine adds a new LBN to VBN mapping to the VMCB structure. When 00651 a new LBN is added to the structure it does it only on page aligned 00652 boundaries. 00653 00654 If pool is not available to store the information this routine will 00655 raise a status value indicating insufficient resources. 00656 00657 Arguments: 00658 00659 Vmcb - Supplies the VMCB being updated. 00660 00661 Lbn - Supplies the starting LBN to add to VMCB. 00662 00663 SectorCount - Supplies the number of Sectors in the run 00664 00665 ExactEnd - Indicates that instead of aligning to map sectors beyond 00666 the end of the request, use a hole. Implies trying to look at 00667 these sectors could be undesireable. 00668 00669 Vbn - Receives the assigned VBN 00670 00671 AlignedSectorCount - Receives the actual sector count created in the 00672 Vmcb for page alignment purposes. Vbn+AlignedSectorCount-1 == LastVbn. 00673 00674 Return Value: 00675 00676 BOOLEAN - TRUE if this is a new mapping and FALSE if the mapping 00677 for the LBN already exists. If it already exists then the 00678 sector count for this new addition must already be in the 00679 VMCB structure 00680 00681 --*/ 00682 00683 { 00684 00685 BOOLEAN Result; 00686 00687 BOOLEAN VbnMcbAdded; 00688 BOOLEAN LbnMcbAdded; 00689 00690 LBN LocalLbn; 00691 VBN LocalVbn; 00692 ULONG LocalCount; 00693 00694 PAGED_CODE(); 00695 00696 DebugTrace(( +1, Dbg, "UdfAddVmcbMapping, Lbn = %08x\n", Lbn )); 00697 DebugTrace(( 0, Dbg, " SectorCount = %08x\n", SectorCount )); 00698 00699 ASSERT( SectorCount != 0 ); 00700 00701 VbnMcbAdded = FALSE; 00702 LbnMcbAdded = FALSE; 00703 00704 // 00705 // Now grab the mutex for the vmcb 00706 // 00707 00708 (VOID)KeWaitForSingleObject( &Vmcb->Mutex, 00709 Executive, 00710 KernelMode, 00711 FALSE, 00712 (PLARGE_INTEGER) NULL ); 00713 00714 try { 00715 00716 // 00717 // Check if the Lbn is already mapped, which means we find an entry 00718 // with a non zero mapping Vbn value. 00719 // 00720 00721 if (UdfVmcbLookupMcbEntry( &Vmcb->LbnIndexed, 00722 Lbn, 00723 Vbn, 00724 &LocalCount, 00725 NULL )) { 00726 00727 // 00728 // It is already mapped so now the sector count must not exceed 00729 // the count already in the run 00730 // 00731 00732 if (SectorCount <= LocalCount) { 00733 00734 try_leave( Result = FALSE ); 00735 } 00736 } 00737 00738 // 00739 // At this point, we did not find a full existing mapping for the 00740 // Lbn and count. But there might be some overlapping runs that we'll 00741 // need to now remove from the vmcb structure. So for each Lbn in 00742 // the range we're after, check to see if it is mapped and remove the 00743 // mapping. We only need to do this test if the sector count is less 00744 // than or equal to a page size. Because those are the only 00745 // structures that we know we'll try an remove/overwrite. 00746 // 00747 00748 if (SectorCount <= PageAlign(Vmcb, 1)) { 00749 00750 if (UdfVmcbLookupMcbEntry( &Vmcb->LbnIndexed, 00751 Lbn, 00752 Vbn, 00753 &LocalCount, 00754 NULL )) { 00755 00756 UdfRemoveVmcbMapping( Vmcb, *Vbn, PageAlign(Vmcb, 1) ); 00757 } 00758 } 00759 00760 // 00761 // We need to add this new run at the end of the Vbns. To do this we 00762 // need to look up the last mcb entry or use a vbn for the second 00763 // page, if the mcb is empty. We'll also special case the situation 00764 // where the last lbn of the mapping and the mapping we're adding 00765 // simply flow into each other in which case we'll not bother bumping 00766 // the vbn to a page alignment 00767 // 00768 00769 if (FsRtlLookupLastMcbEntry( &Vmcb->VbnIndexed, &LocalVbn, &LocalLbn )) { 00770 00771 if (LocalLbn + 1 == Lbn) { 00772 00773 LocalVbn = LocalVbn + 1; 00774 LocalLbn = LocalLbn + 1; 00775 00776 } else { 00777 00778 // 00779 // Get the next available Vbn Page, and calculate the 00780 // Lbn for the page containing the Lbn 00781 // 00782 00783 LocalVbn = PageAlign( Vmcb, LocalVbn + 1 ); 00784 LocalLbn = PageAlign( Vmcb, Lbn + 1 ) - PageAlign( Vmcb, 1 ); 00785 } 00786 00787 } else { 00788 00789 // 00790 // Get the first available Vbn page, and calculate the 00791 // Lbn for the page containing the Lbn. 00792 // 00793 00794 00795 LocalVbn = 0; 00796 LocalLbn = PageAlign( Vmcb, Lbn + 1 ) - PageAlign( Vmcb, 1 ); 00797 } 00798 00799 // 00800 // Calculate the number of sectors that we need to map to keep 00801 // everything on a page granularity. 00802 // 00803 00804 LocalCount = PageAlign( Vmcb, SectorCount + (Lbn - LocalLbn) ); 00805 00806 // 00807 // See if we should use a hole to map the alignment at the end of the request. 00808 // 00809 00810 if (ExactEnd && Lbn + SectorCount < LocalLbn + LocalCount) { 00811 00812 LocalCount = SectorCount + (Lbn - LocalLbn); 00813 } 00814 00815 // 00816 // Add the double mapping 00817 // 00818 00819 FsRtlAddMcbEntry( &Vmcb->VbnIndexed, 00820 LocalVbn, 00821 LocalLbn, 00822 LocalCount ); 00823 00824 VbnMcbAdded = TRUE; 00825 00826 FsRtlAddMcbEntry( &Vmcb->LbnIndexed, 00827 LocalLbn, 00828 LocalVbn, 00829 LocalCount ); 00830 00831 LbnMcbAdded = TRUE; 00832 00833 *Vbn = LocalVbn + (Lbn - LocalLbn); 00834 *AlignedSectorCount = LocalCount - (Lbn - LocalLbn); 00835 00836 try_leave( Result = TRUE ); 00837 00838 } finally { 00839 00840 // 00841 // If this is an abnormal termination then clean up any mcb's that we 00842 // might have modified. 00843 // 00844 00845 if (AbnormalTermination()) { 00846 00847 if (VbnMcbAdded) { FsRtlRemoveMcbEntry( &Vmcb->VbnIndexed, LocalVbn, LocalCount ); } 00848 if (LbnMcbAdded) { FsRtlRemoveMcbEntry( &Vmcb->LbnIndexed, LocalLbn, LocalCount ); } 00849 } 00850 00851 (VOID) KeReleaseMutex( &Vmcb->Mutex, FALSE ); 00852 00853 DebugUnwind("UdfAddVmcbMapping"); 00854 DebugTrace(( 0, Dbg, " LocalVbn = %08x\n", LocalVbn )); 00855 DebugTrace(( 0, Dbg, " LocalLbn = %08x\n", LocalLbn )); 00856 DebugTrace(( 0, Dbg, " LocalCount = %08x\n", LocalCount )); 00857 DebugTrace(( 0, Dbg, " *Vbn = %08x\n", *Vbn )); 00858 DebugTrace(( 0, Dbg, " *AlignedSectorCount = %08x\n", *AlignedSectorCount )); 00859 DebugTrace((-1, Dbg, "UdfAddVmcbMapping -> %08x\n", Result )); 00860 } 00861 00862 return Result; 00863 }

VOID UdfInitializeVmcb IN PVMCB  Vmcb,
IN POOL_TYPE  PoolType,
IN ULONG  MaximumLbn,
IN ULONG  SectorSize
 

Definition at line 219 of file vmcbsup.c.

References Dbg, DebugTrace, DebugUnwind, FALSE, FsRtlInitializeMcb(), FsRtlUninitializeMcb(), KeInitializeMutex(), PAGED_CODE, RtlInitializeGenericTable(), SectorSize, and TRUE.

Referenced by UdfUpdateVcbPhase0().

00228 : 00229 00230 This routine initializes a new Vmcb Structure. The caller must 00231 supply the memory for the structure. This must precede all other calls 00232 that set/query the volume file mapping. 00233 00234 If pool is not available this routine will raise a status value 00235 indicating insufficient resources. 00236 00237 Arguments: 00238 00239 Vmcb - Supplies a pointer to the volume file structure to initialize. 00240 00241 PoolType - Supplies the pool type to use when allocating additional 00242 internal structures. 00243 00244 MaximumLbn - Supplies the maximum Lbn value that is valid for this 00245 volume. 00246 00247 LbSize - Size of a sector on this volume 00248 00249 Return Value: 00250 00251 None 00252 00253 --*/ 00254 00255 { 00256 BOOLEAN VbnInitialized; 00257 BOOLEAN LbnInitialized; 00258 00259 PAGED_CODE(); 00260 00261 DebugTrace(( +1, Dbg, "UdfInitializeVmcb, Vmcb = %08x\n", Vmcb )); 00262 00263 VbnInitialized = FALSE; 00264 LbnInitialized = FALSE; 00265 00266 try { 00267 00268 // 00269 // Initialize the fields in the vmcb structure 00270 // 00271 00272 KeInitializeMutex( &Vmcb->Mutex, 0 ); 00273 00274 FsRtlInitializeMcb( &Vmcb->VbnIndexed, PoolType ); 00275 VbnInitialized = TRUE; 00276 00277 FsRtlInitializeMcb( &Vmcb->LbnIndexed, PoolType ); 00278 LbnInitialized = TRUE; 00279 00280 Vmcb->MaximumLbn = MaximumLbn; 00281 00282 Vmcb->SectorSize = SectorSize; 00283 00284 #if VMCB_WRITE_SUPPORT 00285 00286 // 00287 // For the dirty table we store in the table context field the pool 00288 // type to use for allocating additional structures 00289 // 00290 00291 RtlInitializeGenericTable( &Vmcb->DirtyTable, 00292 PbCompareDirtyVmcb, 00293 PbAllocateDirtyVmcb, 00294 PbDeallocateDirtyVmcb, 00295 (PVOID)PoolType ); 00296 00297 #endif // VMCB_WRITE_SUPPORT 00298 00299 } finally { 00300 00301 // 00302 // If this is an abnormal termination then check if we need to 00303 // uninitialize the mcb structures 00304 // 00305 00306 if (AbnormalTermination()) { 00307 00308 if (VbnInitialized) { FsRtlUninitializeMcb( &Vmcb->VbnIndexed ); } 00309 if (LbnInitialized) { FsRtlUninitializeMcb( &Vmcb->LbnIndexed ); } 00310 } 00311 00312 DebugUnwind("UdfInitializeVmcb"); 00313 DebugTrace(( -1, Dbg, "UdfInitializeVmcb -> VOID\n" )); 00314 } 00315 00316 // 00317 // And return to our caller 00318 // 00319 00320 return; 00321 }

VOID UdfRemoveVmcbMapping IN PVMCB  Vmcb,
IN VBN  Vbn,
IN ULONG  SectorCount
 

Definition at line 867 of file vmcbsup.c.

References Dbg, DebugTrace, DebugUnwind, Executive, FALSE, FsRtlRemoveMcbEntry(), KeReleaseMutex(), KernelMode, KeWaitForSingleObject(), LBN, NULL, PAGED_CODE, UdfBugCheck, UdfVmcbLookupMcbEntry(), and VOID().

Referenced by UdfAddVmcbMapping(), and UdfLookupMetaVsnOfExtent().

00875 : 00876 00877 This routine removes a Vmcb mapping. 00878 00879 If pool is not available to store the information this routine will 00880 raise a status value indicating insufficient resources. 00881 00882 Arguments: 00883 00884 Vmcb - Supplies the Vmcb being updated. 00885 00886 Vbn - Supplies the VBN to remove 00887 00888 SectorCount - Supplies the number of sectors to remove. 00889 00890 Return Value: 00891 00892 None. 00893 00894 --*/ 00895 00896 { 00897 LBN Lbn; 00898 ULONG LocalCount; 00899 ULONG i; 00900 00901 PAGED_CODE(); 00902 00903 DebugTrace((+1, Dbg, "UdfRemoveVmcbMapping, Vbn = %08x\n", Vbn )); 00904 DebugTrace(( 0, Dbg, " SectorCount = %08x\n", SectorCount )); 00905 00906 // 00907 // Now grab the mutex for the vmcb 00908 // 00909 00910 (VOID)KeWaitForSingleObject( &Vmcb->Mutex, 00911 Executive, 00912 KernelMode, 00913 FALSE, 00914 (PLARGE_INTEGER) NULL ); 00915 00916 try { 00917 00918 for (i = 0; i < SectorCount; i += 1) { 00919 00920 // 00921 // Lookup the Vbn so we can get its current Lbn mapping 00922 // 00923 00924 if (!UdfVmcbLookupMcbEntry( &Vmcb->VbnIndexed, 00925 Vbn + i, 00926 &Lbn, 00927 &LocalCount, 00928 NULL )) { 00929 00930 UdfBugCheck( 0, 0, 0 ); 00931 } 00932 00933 FsRtlRemoveMcbEntry( &Vmcb->VbnIndexed, 00934 Vbn + i, 00935 1 ); 00936 00937 FsRtlRemoveMcbEntry( &Vmcb->LbnIndexed, 00938 Lbn, 00939 1 ); 00940 } 00941 00942 { 00943 DebugTrace(( 0, Dbg, "VbnIndex:\n", 0 )); 00944 DebugTrace(( 0, Dbg, "LbnIndex:\n", 0 )); 00945 } 00946 00947 } finally { 00948 00949 (VOID) KeReleaseMutex( &Vmcb->Mutex, FALSE ); 00950 00951 DebugUnwind( "UdfRemoveVmcbMapping" ); 00952 DebugTrace(( -1, Dbg, "UdfRemoveVmcbMapping -> VOID\n" )); 00953 } 00954 00955 return; 00956 }

VOID UdfResetVmcb IN PVMCB  Vmcb  ) 
 

Definition at line 370 of file vmcbsup.c.

References Dbg, DebugTrace, FsRtlResetLargeMcb(), PAGED_CODE, PLARGE_MCB, and TRUE.

Referenced by UdfUpdateVcbPhase0().

00376 : 00377 00378 This routine resets the mappings in an existing VMCB structure. 00379 00380 Arguments: 00381 00382 Vmcb - Supplies a pointer to the VMCB structure to reset. 00383 00384 Return Value: 00385 00386 None. 00387 00388 --*/ 00389 00390 { 00391 PAGED_CODE(); 00392 00393 DebugTrace(( +1, Dbg, "UdfResetVmcb, Vmcb = %08x\n", Vmcb )); 00394 00395 // 00396 // Unitialize the fields in the Vmcb structure 00397 // 00398 00399 FsRtlResetLargeMcb( (PLARGE_MCB) &Vmcb->VbnIndexed, TRUE ); 00400 FsRtlResetLargeMcb( (PLARGE_MCB) &Vmcb->LbnIndexed, TRUE ); 00401 00402 // 00403 // And return to our caller 00404 // 00405 00406 DebugTrace(( -1, Dbg, "UdfResetVmcb -> VOID\n" )); 00407 00408 return; 00409 }

VOID UdfSetMaximumLbnVmcb IN PVMCB  Vmcb,
IN ULONG  MaximumLbn
 

Definition at line 413 of file vmcbsup.c.

References Dbg, DebugTrace, and PAGED_CODE.

00420 : 00421 00422 This routine sets/resets the maximum allowed LBN for the specified 00423 Vmcb structure. The Vmcb structure must already have been initialized 00424 by calling UdfInitializeVmcb. 00425 00426 Arguments: 00427 00428 Vmcb - Supplies a pointer to the volume file structure to initialize. 00429 00430 MaximumLbn - Supplies the maximum Lbn value that is valid for this 00431 volume. 00432 00433 Return Value: 00434 00435 None 00436 00437 --*/ 00438 00439 { 00440 PAGED_CODE(); 00441 00442 DebugTrace(( +1, Dbg, "UdfSetMaximumLbnVmcb, Vmcb = %08x\n", Vmcb )); 00443 00444 // 00445 // Set the field 00446 // 00447 00448 Vmcb->MaximumLbn = MaximumLbn; 00449 00450 // 00451 // And return to our caller 00452 // 00453 00454 DebugTrace(( -1, Dbg, "UdfSetMaximumLbnVmcb -> VOID\n" )); 00455 00456 return; 00457 }

VOID UdfUninitializeVmcb IN PVMCB  Vmcb  ) 
 

Definition at line 325 of file vmcbsup.c.

References Dbg, DebugTrace, FsRtlUninitializeMcb(), and PAGED_CODE.

Referenced by UdfDeleteFcb().

00331 : 00332 00333 This routine uninitializes an existing VMCB structure. After calling 00334 this routine the input VMCB structure must be re-initialized before 00335 being used again. 00336 00337 Arguments: 00338 00339 Vmcb - Supplies a pointer to the VMCB structure to uninitialize. 00340 00341 Return Value: 00342 00343 None. 00344 00345 --*/ 00346 00347 { 00348 PAGED_CODE(); 00349 00350 DebugTrace(( +1, Dbg, "UdfUninitializeVmcb, Vmcb = %08x\n", Vmcb )); 00351 00352 // 00353 // Unitialize the fields in the Vmcb structure 00354 // 00355 00356 FsRtlUninitializeMcb( &Vmcb->VbnIndexed ); 00357 FsRtlUninitializeMcb( &Vmcb->LbnIndexed ); 00358 00359 // 00360 // And return to our caller 00361 // 00362 00363 DebugTrace(( -1, Dbg, "UdfUninitializeVmcb -> VOID\n" )); 00364 00365 return; 00366 }

BOOLEAN UdfVmcbLbnToVbn IN PVMCB  Vmcb,
IN LBN  Lbn,
OUT PVBN  Vbn,
OUT PULONG SectorCount  OPTIONAL
 

Definition at line 553 of file vmcbsup.c.

References Dbg, DebugTrace, DebugUnwind, Executive, FALSE, KeReleaseMutex(), KernelMode, KeWaitForSingleObject(), NULL, PAGED_CODE, UdfVmcbLookupMcbEntry(), and VOID().

Referenced by UdfLookupMetaVsnOfExtent().

00562 : 00563 00564 This routine translates an LBN to a VBN. 00565 00566 Arguments: 00567 00568 Vmcb - Supplies the VMCB structure being queried. 00569 00570 Lbn - Supplies the LBN to translate from. 00571 00572 Vbn - Recieves the VBN mapped by the input LBN. This value is 00573 only valid if the function result is TRUE. 00574 00575 SectorCount - Optionally receives the number of sectors corresponding 00576 to the run. 00577 00578 Return Value: 00579 00580 BOOLEAN - TRUE if the mapping is valid and FALSE otherwise. 00581 00582 --*/ 00583 00584 { 00585 BOOLEAN Result; 00586 00587 PAGED_CODE(); 00588 00589 DebugTrace(( +1, Dbg, "UdfVmcbLbnToVbn, Lbn = %08x\n", Lbn )); 00590 00591 // 00592 // If the requested Lbn is greater than the maximum allowed Lbn 00593 // then the result is FALSE 00594 // 00595 00596 if (Lbn > Vmcb->MaximumLbn) { 00597 00598 DebugTrace(( -1, Dbg, "Lbn too large, UdfVmcbLbnToVbn -> FALSE\n" )); 00599 00600 return FALSE; 00601 } 00602 00603 // 00604 // Now grab the mutex for the vmcb 00605 // 00606 00607 (VOID)KeWaitForSingleObject( &Vmcb->Mutex, 00608 Executive, 00609 KernelMode, 00610 FALSE, 00611 (PLARGE_INTEGER) NULL ); 00612 00613 try { 00614 00615 Result = UdfVmcbLookupMcbEntry( &Vmcb->LbnIndexed, 00616 Lbn, 00617 Vbn, 00618 SectorCount, 00619 NULL ); 00620 00621 DebugTrace(( 0, Dbg, "*Vbn = %08x\n", *Vbn )); 00622 00623 } finally { 00624 00625 (VOID) KeReleaseMutex( &Vmcb->Mutex, FALSE ); 00626 00627 00628 DebugUnwind("UdfVmcbLbnToVbn"); 00629 DebugTrace(( -1, Dbg, "UdfVmcbLbnToVbn -> Result = %08x\n", Result )); 00630 } 00631 00632 return Result; 00633 }

BOOLEAN UdfVmcbLookupMcbEntry IN PMCB  Mcb,
IN VBN  Vbn,
OUT PLBN  Lbn,
OUT PULONG SectorCount  OPTIONAL,
OUT PULONG Index  OPTIONAL
 

Definition at line 964 of file vmcbsup.c.

References FALSE, FsRtlLookupLargeMcbEntry(), Index, and NULL.

Referenced by UdfAddVmcbMapping(), UdfRemoveVmcbMapping(), UdfVmcbLbnToVbn(), and UdfVmcbVbnToLbn().

00974 : 00975 00976 This routine retrieves the mapping of a Vbn to an Lbn from an Mcb. 00977 It indicates if the mapping exists and the size of the run. 00978 00979 The only difference betweent this and the regular FsRtlLookupMcbEntry 00980 is that we undo the behavior of returning TRUE in holes in the allocation. 00981 This is because we don't want to avoid mapping at Lbn 0, which is how the 00982 emulated behavior of the small Mcb package tells callers that there is no 00983 mapping at that location in a hole. We have holes all over our Vbn space 00984 in the VbnIndexed map. 00985 00986 The small Mcb package was able to get away with this because Lbn 0 was the 00987 boot sector (or similar magic location) on the disc. In our metadata stream, 00988 we wish to use Vbn 0 (remember this is a double map). 00989 00990 Arguments: 00991 00992 Mcb - Supplies the Mcb being examined. 00993 00994 Vbn - Supplies the Vbn to lookup. 00995 00996 Lbn - Receives the Lbn corresponding to the Vbn. A value of -1 is 00997 returned if the Vbn does not have a corresponding Lbn. 00998 00999 SectorCount - Receives the number of sectors that map from the Vbn to 01000 contiguous Lbn values beginning with the input Vbn. 01001 01002 Index - Receives the index of the run found. 01003 01004 Return Value: 01005 01006 BOOLEAN - TRUE if the Vbn is within the range of VBNs mapped by the 01007 MCB (not if it corresponds to a hole in the mapping), and FALSE 01008 if the Vbn is beyond the range of the MCB's mapping. 01009 01010 For example, if an MCB has a mapping for VBNs 5 and 7 but not for 01011 6, then a lookup on Vbn 5 or 7 will yield a non zero Lbn and a sector 01012 count of 1. A lookup for Vbn 6 will return FALSE with an Lbn value of 01013 0, and lookup for Vbn 8 or above will return FALSE. 01014 01015 --*/ 01016 01017 { 01018 BOOLEAN Results; 01019 LONGLONG LiLbn; 01020 LONGLONG LiSectorCount; 01021 01022 Results = FsRtlLookupLargeMcbEntry( (PLARGE_MCB)Mcb, 01023 (LONGLONG)(Vbn), 01024 &LiLbn, 01025 ARGUMENT_PRESENT(SectorCount) ? &LiSectorCount : NULL, 01026 NULL, 01027 NULL, 01028 Index ); 01029 01030 if ((ULONG)LiLbn == -1) { 01031 01032 *Lbn = 0; 01033 Results = FALSE; 01034 01035 } else { 01036 01037 *Lbn = (ULONG)LiLbn; 01038 } 01039 01040 if (ARGUMENT_PRESENT(SectorCount)) { *SectorCount = ((ULONG)LiSectorCount); } 01041 01042 return Results; 01043 }

BOOLEAN UdfVmcbVbnToLbn IN PVMCB  Vmcb,
IN VBN  Vbn,
IN PLBN  Lbn,
OUT PULONG SectorCount  OPTIONAL
 

Definition at line 461 of file vmcbsup.c.

References Dbg, DebugTrace, DebugUnwind, Executive, FALSE, KeReleaseMutex(), KernelMode, KeWaitForSingleObject(), NULL, try_leave, UdfVmcbLookupMcbEntry(), and VOID().

Referenced by UdfLookupAllocation().

00470 : 00471 00472 This routine translates a VBN to an LBN. 00473 00474 Arguments: 00475 00476 Vmcb - Supplies the VMCB structure being queried. 00477 00478 Vbn - Supplies the VBN to translate from. 00479 00480 Lbn - Receives the LBN mapped by the input Vbn. This value is only valid 00481 if the function result is TRUE. 00482 00483 SectorCount - Optionally receives the number of sectors corresponding 00484 to the run. 00485 00486 Return Value: 00487 00488 BOOLEAN - TRUE if he Vbn has a valid mapping and FALSE otherwise. 00489 00490 --*/ 00491 00492 { 00493 BOOLEAN Result; 00494 00495 DebugTrace(( +1, Dbg, "UdfVmcbVbnToLbn, Vbn = %08x\n", Vbn )); 00496 00497 // 00498 // Now grab the mutex for the vmcb 00499 // 00500 00501 (VOID)KeWaitForSingleObject( &Vmcb->Mutex, 00502 Executive, 00503 KernelMode, 00504 FALSE, 00505 (PLARGE_INTEGER) NULL ); 00506 00507 try { 00508 00509 Result = UdfVmcbLookupMcbEntry( &Vmcb->VbnIndexed, 00510 Vbn, 00511 Lbn, 00512 SectorCount, 00513 NULL ); 00514 00515 DebugTrace(( 0, Dbg, "*Lbn = %08x\n", *Lbn )); 00516 00517 // 00518 // If the returned Lbn is greater than the maximum allowed Lbn 00519 // then return FALSE 00520 // 00521 00522 if (Result && (*Lbn > Vmcb->MaximumLbn)) { 00523 00524 try_leave( Result = FALSE ); 00525 } 00526 00527 // 00528 // If the last returned Lbn is greater than the maximum allowed Lbn 00529 // then bring in the sector count 00530 // 00531 00532 if (Result && 00533 ARGUMENT_PRESENT(SectorCount) && 00534 (*Lbn+*SectorCount-1 > Vmcb->MaximumLbn)) { 00535 00536 *SectorCount = (Vmcb->MaximumLbn - *Lbn + 1); 00537 } 00538 00539 } finally { 00540 00541 (VOID) KeReleaseMutex( &Vmcb->Mutex, FALSE ); 00542 00543 DebugUnwind("UdfVmcbVbnToLbn"); 00544 DebugTrace(( -1, Dbg, "UdfVmcbVbnToLbn -> Result = %08x\n", Result )); 00545 } 00546 00547 00548 return Result; 00549 }


Generated on Sat May 15 19:46:08 2004 for test by doxygen 1.3.7