20#define UDF_BUG_CHECK_ID UDF_FILE_UDF_INFO_EXTENT
51 (*Flags) = (
Extent->extLength >> 30);
65 (*SectorOffset) = Offs & (
Vcb->BlockSize-1);
67 (*AvailLength) =
l - Offs;
69 (*Flags) = (
Extent->extLength >> 30);
75 return Extent->extLocation + BOffset;
99 (*Flags) = (
Extent->extLength >> 30);
105 (*Flags) = (
Extent->extLength >> 30);
109 return Extent->extLocation;
149#if defined(_X86_) && defined(_MSC_VER) && !defined(__clang__)
173 while(
Extent->extLength) {
191#ifdef UDF_TRACK_EXTENT_TO_MAPPING
199#ifdef UDF_TRACK_EXTENT_TO_MAPPING
200#define UDF_EXT_MAP_MULT 4
202#define UDF_EXT_MAP_MULT 2
207 if(!Map)
return NULL;
211#ifdef UDF_TRACK_EXTENT_TO_MAPPING
230#if defined(_X86_) && defined(_MSC_VER) && !defined(__clang__)
249 while(
Extent->extLength) {
283 ExtPrint((
"UDFMergeMappings failed\n"));
313 ExtPrint((
"UDFShortAllocDescToMapping: len=%x\n", AllocDescLength));
326 type = AllocDesc[
i].extLength >> 30;
328 ExtPrint((
"ShExt: type %x, loc %x, len %x\n",
type, AllocDesc[
i].extPosition,
len));
359 if(!AllocLoc->Mapping ||
373 UDFPrint((
"Integrity check failed\n"));
374 UDFPrint((
"NextAllocDesc->descTag.tagIdent = %x\n", NextAllocDesc->descTag.tagIdent));
375 UDFPrint((
"NextAllocDesc->lengthAllocDescs = %x\n", NextAllocDesc->lengthAllocDescs));
382 NextAllocLoc.
Flags = 0;
384 NextAllocDesc->lengthAllocDescs, SubCallCount+1, AllocLoc);
405#ifdef UDF_CHECK_EXTENT_SIZE_ALIGNMENT
408 if(
len & (
Vcb->LBlockSize-1)) {
473 ExtPrint((
"UDFLongAllocDescToMapping: len=%x\n", AllocDescLength));
485 type = AllocDesc[
i].extLength >> 30;
488 AllocDesc[
i].extLocation.partitionReferenceNum, AllocDesc[
i].extLocation.logicalBlockNum,
519 if(!AllocLoc->Mapping ||
533 UDFPrint((
"Integrity check failed\n"));
534 UDFPrint((
"NextAllocDesc->descTag.tagIdent = %x\n", NextAllocDesc->descTag.tagIdent));
535 UDFPrint((
"NextAllocDesc->lengthAllocDescs = %x\n", NextAllocDesc->lengthAllocDescs));
543 NextAllocDesc->lengthAllocDescs, SubCallCount+1, AllocLoc);
558#ifdef UDF_CHECK_EXTENT_SIZE_ALIGNMENT
611 ExtPrint((
"UDFExtAllocDescToMapping: len=%x\n", AllocDescLength));
623 type = AllocDesc[
i].extLength >> 30;
655 if(!AllocLoc->Mapping ||
669 UDFPrint((
"Integrity check failed\n"));
676 NextAllocDesc->lengthAllocDescs, SubCallCount+1, AllocLoc);
695#ifdef UDF_CHECK_EXTENT_SIZE_ALIGNMENT
784 AllocLoc->Length=
len;
806 AllocLoc->Mapping=
NULL;
811 ExtPrint((
"UDFReadMappingFromXEntry: mode %x, loc %x, len %x\n", AllocMode,
812 AllocLoc->Mapping ? AllocLoc->Mapping[0].extLocation : -1,
len));
819#ifndef UDF_READ_ONLY_BUILD
842#ifdef UDF_ALLOW_FRAG_AD
849 uint32 TagLoc, prevTagLoc;
856 ExtPrint((
"UDFBuildShortAllocDescs: FE %x\n",
FileInfo->Dloc->FELoc.Mapping[0].extLocation));
859 ExtPrint((
"bShExt: type %x, loc %x, len %x\n",
875 ExtPrint((
"bShExt: cut tail -> %x\n",
885 if(!(
FileInfo->Dloc->AllocLoc.Mapping)) {
887 if(!(
FileInfo->Dloc->AllocLoc.Mapping)) {
896 FileInfo->Dloc->AllocLoc.Length = 0;
898 FileInfo->Dloc->AllocLoc.Mapping[1].extLength =
899 FileInfo->Dloc->AllocLoc.Mapping[1].extLocation = 0;
904 AdPrint((
"in-ICB AllocDescs, j=%x\n",
j));
909#ifndef UDF_ALLOW_FRAG_AD
913 AdPrint((
"multi-block AllocDescs, j=%x\n",
j));
915 TagLoc = prevTagLoc = 0;
923 NewLen = ( ((
j -
len + ac - 1) / ac) << LBSh) + InitSz +
sizeof(
SHORT_AD);
942 ExtOffs = AllocExtent->
Offset;
944 saved_NewLen = NewLen;
983 ((
PSHORT_AD)((*Buff)+BufOffs))->extLength = len2 |
985 ((
PSHORT_AD)((*Buff)+BufOffs))->extPosition = TagLoc =
988 ExtOffs+BufOffs+
sizeof(
SHORT_AD)+ts,
994 ( (
PALLOC_EXT_DESC) ((*Buff)+BufOffs))->previousAllocExtLocation = prevTagLoc;
995 Tag = (
tag*)((*Buff)+BufOffs);
1029#ifdef UDF_ALLOW_FRAG_AD
1031 uint32 TagLoc, prevTagLoc;
1042 ExtPrint((
"UDFBuildLongAllocDescs: FE %x\n",
FileInfo->Dloc->FELoc.Mapping[0].extLocation));
1046 ExtPrint((
"bLnExt: type %x, loc %x, len %x\n",
1055 Alloc[
i].extLocation.partitionReferenceNum = (
uint16)PartNum;
1060 (
Vcb->LBlockSize-1);
1061 ExtPrint((
"bLnExt: cut tail -> %x\n",
1070 if(!(
FileInfo->Dloc->AllocLoc.Mapping)) {
1072 if(!(
FileInfo->Dloc->AllocLoc.Mapping)) {
1080 FileInfo->Dloc->AllocLoc.Length = 0;
1082 FileInfo->Dloc->AllocLoc.Mapping[1].extLength =
1083 FileInfo->Dloc->AllocLoc.Mapping[1].extLocation = 0;
1092#ifndef UDF_ALLOW_FRAG_AD
1097 TagLoc = prevTagLoc = 0;
1105 NewLen = ( ((
j -
len + ac - 1) / ac) << LBSh) + InitSz +
sizeof(
LONG_AD);
1120 ExtOffs = AllocExtent->
Offset;
1123 saved_Alloc =
Alloc;
1146 prevTagLoc = TagLoc;
1159 ((
PLONG_AD)((*Buff)+BufOffs))->extLength = len2 |
1161 ((
PLONG_AD)((*Buff)+BufOffs))->extLocation.logicalBlockNum = TagLoc =
1164 ExtOffs+BufOffs+
sizeof(
LONG_AD)+ts,
1166 ((
PLONG_AD)((*Buff)+BufOffs))->extLocation.partitionReferenceNum = (
uint16)PartNum;
1168 BufOffs += ts+
sizeof(
LONG_AD);
1171 ( (
PALLOC_EXT_DESC) ((*Buff)+BufOffs))->previousAllocExtLocation = prevTagLoc;
1172 Tag = (
tag*)((*Buff)+BufOffs);
1335#ifdef UDF_FE_ALLOCATION_CHARGE
1355 ASSERT(!Dloc->DirIndex->FECharge.Mapping);
1374 switch(AllocClass) {
1376 UDFPrint((
"AllocationCache FE:\n"));
1377 pAllocCache = &(
Vcb->FEChargeCache);
1378 plim = &(
Vcb->FEChargeCacheMaxSize);
1382 UDFPrint((
"AllocationCache DIR:\n"));
1383 pAllocCache = &(
Vcb->PreallocCache);
1384 plim = &(
Vcb->PreallocCacheMaxSize);
1394 (*pAllocCache) = AllocCache =
1402 for(
i=0;
i<lim;
i++) {
1408 AllocCache = (*pAllocCache);
1411 (*_AllocCache) = AllocCache;
1436 UDFPrint((
"Get AllocationCache for %x\n", ParentLocation));
1438 for(
i=0;
i<lim;
i++) {
1439 if(AllocCache[
i].ParentLocation == ParentLocation) {
1440 (*Ext) = AllocCache[
i].
Ext;
1443 (*Items) = AllocCache[
i].
Items;
1476 UDFPrint((
"Store AllocationCache for %x, map %x\n", ParentLocation,
Ext->Mapping));
1478 for(
i=0;
i<lim;
i++) {
1481 AllocCache[
i].
Ext = (*Ext);
1482 AllocCache[
i].
Items = Items;
1489 AdPrint((
" drop map %x (%x)\n", AllocCache[lim-1].
Ext.Mapping, lim-1));
1490 switch(AllocClass) {
1499 AllocCache[0].
Ext = (*Ext);
1500 AllocCache[0].
Items = Items;
1517 UDFPrint((
"Flush AllocationCache\n"));
1526 for(
i=0;
i<lim;
i++) {
1528 switch(AllocClass) {
1539 switch(AllocClass) {
1542 Vcb->FEChargeCacheMaxSize = 0;
1546 Vcb->PreallocCacheMaxSize = 0;
1571#ifdef UDF_FE_ALLOCATION_CHARGE
1596 if(!DirInfo || !DirInfo->Dloc->DirIndex ||
1601#ifdef UDF_FE_ALLOCATION_CHARGE
1603 Ext = &(DirInfo->Dloc->DirIndex->FECharge);
1615 fe_loc = DirInfo->Dloc->FELoc.Mapping[0].extLocation;
1621 if(
Vcb->LowFreeSpace) {
1624 UDFPrint((
"FE @ %x (1)\n", FEExtInfo->Mapping[0].extLocation ));
1628 if(fe_loc > p_start + 512*16) {
1629 l1 = fe_loc - 512*16;
1633 if(fe_loc + 512*16 < p_end) {
1634 l2 = fe_loc + 512*16;
1650 UDFPrint((
"allocate single FE entry\n"));
1654 UDFPrint((
"FE @ %x (2)\n", FEExtInfo->Mapping[0].extLocation ));
1667 for(
i=0;
i<lim;
i++) {
1672 Extent.extLocation =
Ext->Mapping[
i].extLocation;
1674 if(
Vcb->BSBM_Bitmap) {
1677 UDFPrint((
"Remove BB @ %x from FE charge\n",
lba));
1679 Ext->Mapping[
i].extLocation = 0;
1685 if(!FEExtInfo->Mapping) {
1690 UDFPrint((
"FE @ %x (3)\n", FEExtInfo->Mapping[0].extLocation ));
1691 FEExtInfo->Length =
Len;
1692 FEExtInfo->Offset = 0;
1693 FEExtInfo->Modified =
TRUE;
1698 if(
Vcb->LowFreeSpace) {
1702 UDFPrint((
"FE @ %x (4)\n", FEExtInfo->Mapping[0].extLocation ));
1731#ifdef UDF_FE_ALLOCATION_CHARGE
1738 if(DirInfo && DirInfo->Dloc->DirIndex &&
1739 (
Ext = &(DirInfo->Dloc->DirIndex->FECharge))->Mapping) {
1740 if(!FEExtInfo->Mapping)
1742 Lba = FEExtInfo->Mapping[0].extLocation;
1745 for(
i=0;
i<lim;
i++) {
1746 if(
Ext->Mapping[
i].extLocation == Lba) {
1751 if(!
Ext->Mapping[
i].extLocation) {
1757 Ext->Mapping[
i].extLocation = Lba;
1765 FEExtInfo->Mapping[0].extLocation = 0;
1782#ifdef UDF_FE_ALLOCATION_CHARGE
1786 if(!(
Mapping = Dloc->DirIndex->FECharge.Mapping))
1794 Dloc->FELoc.Mapping[0].extLocation,
1796 Dloc->DirIndex->FECharge.Mapping =
NULL;
1800 Dloc->DirIndex->FECharge.Mapping =
NULL;
1803 ASSERT(!Dloc->DirIndex->FECharge.Mapping);
1808#ifndef UDF_READ_ONLY_BUILD
1837 ASSERT(!(check_size & (LBS-1)));
1839 AdPrint((
"Alloc->Rec ExtInfo %x, Extent %x\n", ExtInfo,
Extent));
1848 ExtInfo->Modified =
TRUE;
1862 AdPrint((
"Alloc->Rec (1) new %x\n", ExtInfo->Mapping));
1866 AdPrint((
"Alloc->Rec: ExtInfo %x, Extent %x\n", ExtInfo, ExtInfo->Mapping));
1879 NewExtent[
i].extLocation =
Extent[
i].extLocation;
1880 NewExtent[
i].extLength = (
lba -
Extent[
i].extLocation) << BSh;
1881 NewExtent[
i+1].extLength = (
Length+
BS-1) & ~(
BS-1);
1882 NewExtent[
i+1].extLocation =
lba;
1883 NewExtent[
i+2].extLength =
Extent[
i].extLength - NewExtent[
i].extLength - NewExtent[
i+1].extLength;
1884 NewExtent[
i+2].extLocation =
lba + ((
Length+
BS-1) >> BSh);
1885 ASSERT(!(NewExtent[
i].extLength >> 30));
1886 ASSERT(!(NewExtent[
i+2].extLength >> 30));
1890 AdPrint((
"Alloc->Rec (2) new %x\n", NewExtent));
1899 NewExtent[
i].extLocation =
Extent[
i].extLocation;
1900 NewExtent[
i].extLength = (
lba -
Extent[
i].extLocation) << BSh;
1901 NewExtent[
i+1].extLength =
Extent[
i].extLength - NewExtent[
i].extLength;
1902 NewExtent[
i+1].extLocation =
lba;
1903 ASSERT(!(NewExtent[
i].extLength >> 30));
1905 AdPrint((
"Alloc->Rec (3) new %x\n", NewExtent));
1915 NewExtent[
i].extLocation =
Extent[
i].extLocation;
1917 NewExtent[
i+1].extLength =
Extent[
i].extLength - NewExtent[
i].extLength;
1918 NewExtent[
i+1].extLocation =
Extent[
i].extLocation + (NewExtent[
i].extLength >> BSh);
1919 ASSERT(!(NewExtent[
i+1].extLength >> 30));
1921 AdPrint((
"Alloc->Rec (4) new %x\n", NewExtent));
1929 ExtInfo->Modified =
TRUE;
1930 ExtInfo->Mapping = NewExtent;
1935 ASSERT(!(check_size & (LBS-1)));
1938 AdPrint((
"Alloc->Rec: ExtInfo %x, Extent %x\n", ExtInfo, ExtInfo->Mapping));
1970 AdPrint((
"Not->Alloc ExtInfo %x, Extent %x\n", ExtInfo,
Extent));
1988 &TmpExtInf, ExtInfo->
Flags );
1991 goto try_alloc_anywhere;
1998 &TmpExtInf, ExtInfo->
Flags );
2002 AdPrint((
"Not->Alloc no free\n"));
2009 for(
j=0;
j<
i;
j++) {
2024 AdPrint((
"Not->Alloc (1) new %x\n", NewExtent));
2038 NewExtent[
i].extLocation = 0;
2039 NewExtent[
i].extLength = (BOffs -
l) << BSh;
2040 NewExtent[
i+
d+1].extLength =
Extent[
i].extLength - NewExtent[
i].extLength - aLen;
2041 NewExtent[
i+
d+1].extLocation = 0;
2044 AdPrint((
"Not->Alloc (2) new %x\n", NewExtent));
2055 NewExtent[
i].extLocation = 0;
2056 NewExtent[
i].extLength = (BOffs -
l) << BSh;
2058 AdPrint((
"Not->Alloc (3) new %x\n", NewExtent));
2071 NewExtent[
i+
d].extLocation = 0;
2073 AdPrint((
"Not->Alloc (4) new %x\n", NewExtent));
2076 AdPrint((
"Free Extent %x, TmpExtInf.Mapping, (new %x)\n",
Extent, TmpExtInf.
Mapping, NewExtent));
2079 ExtInfo->Modified =
TRUE;
2080 ExtInfo->Mapping = NewExtent;
2082 AdPrint((
"Not->Alloc: ExtInfo %x, Extent %x\n", ExtInfo, ExtInfo->Mapping));
2112 uint32 target_flags = Deallocate ?
2126 AdPrint((
"Alloc->Not ExtInfo %x, Extent %x\n", ExtInfo,
Extent));
2152 for(
j=0;
j<
i;
j++) {
2162 AdPrint((
"Alloc->Not (1) NewExtent = Extent = %x\n", NewExtent));
2174 NewExtent[
i].extLength = (BOffs -
l) << BSh;
2175 NewExtent[
i].extLength |=
flags;
2176 NewExtent[
i+1].extLocation = 0;
2177 NewExtent[
i+1].extLength = aLen | (target_flags << 30);
2180 NewExtent[
i+2].extLocation =
Extent[
i].extLocation +
2181 (NewExtent[
i+2].extLength >> BSh);
2182 NewExtent[
i+2].extLength |=
flags;
2183 AdPrint((
"Alloc->Not (2) new %x\n", NewExtent));
2192 NewExtent[
i].extLength = ((BOffs -
l) << BSh) |
flags;
2193 NewExtent[
i+1].extLocation = 0;
2194 NewExtent[
i+1].extLength = aLen | (target_flags << 30);
2195 AdPrint((
"Alloc->Not (3) new %x\n", NewExtent));
2206 NewExtent[
i+1].extLength |=
flags;
2207 NewExtent[
i].extLocation = 0;
2208 NewExtent[
i].extLength = aLen | (target_flags << 30);
2209 AdPrint((
"Alloc->Not (4) new %x\n", NewExtent));
2215 ExtInfo->Modified =
TRUE;
2216 ExtInfo->Mapping = NewExtent;
2218 AdPrint((
"Alloc->Not: ExtInfo %x, Extent %x\n", ExtInfo, ExtInfo->Mapping));
2252 BSh =
Vcb->BlockSizeBits;
2253 PS =
Vcb->WriteBlockSize >>
Vcb->BlockSizeBits;
2259 ExtPrint((
"Resize ExtInfo %x, %I64x -> %I64x\n", ExtInfo, ExtInfo->Length,
Length));
2262 AdPrint((
" cut preallocated\n"));
2264 if(ExtInfo->Length ==
Length) {
2268 MaxGrow &= ~(
Vcb->WriteBlockSize-1);
2273 if(ExtInfo->Offset) {
2274 if(ExtInfo->Offset +
Length <= LBS) {
2276 ExtInfo->Length =
Length;
2280 ExtInfo->Offset = LBS;
2281 Length += ExtInfo->Offset;
2284 if(ExtInfo->Length <
Length) {
2288 AdPrint((
"Resize found cached(1)\n"));
2294 ExtInfo->Length =
Length;
2295 AdPrint((
"Resize do nothing (1)\n"));
2298 Length -= ExtInfo->Offset;
2299 if( (
l % MaxGrow) &&
2300 (
Length-1)/MaxGrow != (
l-1)/MaxGrow) {
2301 AdPrint((
"Crossing MAX_FRAG boundary...\n"));
2302 int64 l2 = ((
l-1)/MaxGrow + 1)*MaxGrow;
2305 UDFPrint((
"Sub-call to UDFResizeExtent() failed (%x)\n",
status));
2308 l = ExtInfo->Length;
2311 while((
Length -
l) > MaxGrow) {
2314 UDFPrint((
"Sub-call (2) to UDFResizeExtent() failed (%x)\n",
status));
2317 l = ExtInfo->Length;
2319 Length += ExtInfo->Offset;
2321#ifndef UDF_ALLOW_FRAG_AD
2335 if(!AlwaysInIcb && !(ExtInfo->Offset) &&
2336 (
Length -
l >= (
Vcb->SparseThreshold << BSh))) {
2338 AdPrint((
"Resize sparse (2)\n"));
2353 if(
i>1 && !(ExtInfo->Offset)) {
2360 AdPrint((
"Resize grow sparse (3)\n"));
2361 ExtInfo->Mapping[
i].extLength +=
2366 AdPrint((
"Resize grow Not-Rec (3)\n"));
2370 lba = ExtInfo->Mapping[
i].extLocation +
s;
2380 ((
l + LBS - 1) & ~(LBS-1)) ) >> BSh);
2401 AdPrint((
"Resize grow last Not-Rec (4)\n"));
2417 AdPrint((
"Resize reloc last Not-Rec (5)\n"));
2421 UDFPrint((
"UDFResizeExtent: !TmpExtInf.Mapping\n"));
2428 TmpExtInf.
Offset = ExtInfo->Offset;
2431 ASSERT(
i || !ExtInfo->Offset);
2434 (*ExtInfo) = TmpExtInf;
2443 lba = ExtInfo->Mapping[
i].extLocation +
s;
2453 ((
l + LBS - 1) & ~(LBS-1)) ) >> BSh);
2473 AdPrint((
"Resize grow last Rec (6)\n"));
2483 AdPrint((
"Resize part-grow last Rec (6)\n"));
2493 AdPrint((
"Can't grow last Rec (6)\n"));
2497 AdPrint((
"Max frag length reached (6)\n"));
2503 AdPrint((
"Resize add new frag (7)\n"));
2504 if(l < LBS && Length >= LBS &&
2506 AdPrint((
"Resize tune for SEQUENTIAL i/o\n"));
2514 UDFPrint((
"UDFResizeExtent: UDFAllocFreeExtent() failed (%x)\n",
status));
2525 AdPrint((
"Resize cut (8)\n"));
2531 if(ExtInfo->Mapping[
i].extLength) {
2535 AdPrint((
"Resize try save cutted (8)\n"));
2542 AdPrint((
"Resize save cutted (8)\n"));
2545 ExtInfo->Mapping[
i].extLength = 0;
2546 ExtInfo->Mapping[
i].extLocation = 0;
2554 if((lim-1 >= LBS) &&
2562 ClrMap[0].
extLocation = ExtInfo->Mapping[
i-1].extLocation +
2570 ExtInfo->Mapping[
i-1].extLength =
s | (
flags << 30);
2576 AdPrint((
"ResizeExtent: MyReallocPool__(8) failed\n"));
2578 ExtInfo->Mapping[
i].extLength =
2579 ExtInfo->Mapping[
i].extLocation = 0;
2581 AdPrint((
"Resize zero (9)\n"));
2582 ASSERT(!ExtInfo->Offset);
2587 AdPrint((
"ResizeExtent: MyReallocPool__(9) failed\n"));
2590 ExtInfo->Mapping[0].extLocation =
2591 ExtInfo->Mapping[1].extLength =
2592 ExtInfo->Mapping[1].extLocation = 0;
2594 if(ExtInfo->Offset) {
2602 AdPrint((
"ResizeExtent: MyReallocPool__(10) failed\n"));
2604 Length -= ExtInfo->Offset;
2605 ExtInfo->Offset = 0;
2607 Length -= ExtInfo->Offset;
2610 ExtInfo->Length =
Length;
2614 ExtPrint((
"Resized Ext: type %x, loc %x, len %x\n",
2615 ExtInfo->Mapping[
i].extLength >> 30, ExtInfo->Mapping[
i].extLocation, ExtInfo->Mapping[
i].extLength &
UDF_EXTENT_LENGTH_MASK));
2643 AdPrint((
"BuildAllocDesc\n"));
2645 InitSz =
Vcb->LBlockSize -
FileInfo->Dloc->FileEntryLen;
2649 AdPrint((
"BuildAllocDesc: cant alloc %x bytes for Allocs\n", InitSz));
2686 *AllocData = Allocs;
2702 if(
FileInfo->Dloc->DataLoc.Offset) {
2704 if(
FileInfo->Dloc->DataLoc.Mapping) {
2706 FileInfo->Dloc->DataLoc.Mapping[0].extLocation);
2708 FileInfo->Dloc->DataLoc.Mapping[1].extLocation =
2709 FileInfo->Dloc->DataLoc.Mapping[1].extLength = 0;
2710 FileInfo->Dloc->DataLoc.Mapping[0].extLocation = 0;
2713 if(
FileInfo->Dloc->AllocLoc.Mapping) {
2715 FileInfo->Dloc->AllocLoc.Mapping[0].extLocation);
2717 FileInfo->Dloc->AllocLoc.Mapping[1].extLocation =
2718 FileInfo->Dloc->AllocLoc.Mapping[1].extLength = 0;
2719 FileInfo->Dloc->AllocLoc.Mapping[0].extLocation = 0;
2724 if(
FileInfo->Dloc->AllocLoc.Mapping) {
2726 FileInfo->Dloc->AllocLoc.Mapping[0].extLocation);
2728 FileInfo->Dloc->AllocLoc.Mapping[1].extLocation =
2729 FileInfo->Dloc->AllocLoc.Mapping[1].extLength = 0;
2730 FileInfo->Dloc->AllocLoc.Mapping[0].extLocation = 0;
2737 FileInfo->Dloc->AllocLoc.Modified =
2754 uint32 LastLba, LastType, OldLen;
2760 AdPrint((
"Pack ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
2761 AdPrint((
" Length %x\n", ExtInfo->Length));
2763 OldMap = ExtInfo->Mapping;
2771 ASSERT(!(check_size & (2048-1)));
2777 if((LastType == (OldMap[
i].extLength >> 30))
2779 ((OldMap[
i].extLocation == LastLba + OldLen) ||
2800 AdPrint((
"Pack ExtInfo %x, Mapping %x, realloc\n", ExtInfo, ExtInfo->Mapping));
2807 NewMap[0] = OldMap[0];
2813 ExtPrint((
"oShExt: type %x, loc %x, len %x\n",
2816 if((LastType == (OldMap[
i].extLength >> 30))
2818 ((OldMap[
i].extLocation == LastLba + OldLen) ||
2825 NewMap[
j] = OldMap[
i];
2828 ExtPrint((
"nShExt: type %x, loc %x, len %x\n",
2846 AdPrint((
"Pack ExtInfo %x, NewMap %x, OldMap %x\n", ExtInfo, NewMap, OldMap));
2848 ExtInfo->Mapping = NewMap;
2851 AdPrint((
"Pack ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
2852 AdPrint((
" Length %x\n", ExtInfo->Length));
2877 d = LBS >>
Vcb->BlockSizeBits;
2881 for(;
l>=(
LONG)LBS;
j++) {
2892 ExtInfo->Mapping = NewMapping;
2932 if(!ExtInfo || !ExtInfo->Mapping)
goto EO_IsCached;
2939 if(
Offset > ExtInfo->Length)
goto EO_IsCached;
2941 Offset += ExtInfo->Offset;
2951 retstat = UDFIsDataCached(
Vcb, Lba, (
to_read+sect_offs+
Vcb->BlockSize-1)>>
Vcb->BlockSizeBits);
2952 if(!retstat)
goto EO_IsCached;
2953 }
else if(ForWrite) {
3035 AdPrint((
"Read ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
3045 Offset += ExtInfo->Offset;
3052 Extent += (_ReadBytes + 1);
3057 (*ReadBytes) += _ReadBytes;
3093 if(!ExtInfo || !ExtInfo->Mapping)
3100 int32 SubExtInfoSz = *_SubExtInfoSz;
3105 (*_SubExtInfo) =
NULL;
3106 (*_SubExtInfoSz) = 0;
3109 if(
Offset >= ExtInfo->Length)
3112 Offset += ExtInfo->Offset;
3116 (*_SubExtInfo) = SubExtInfo;
3121 while(
Length && SubExtInfoSz) {
3127 Extent += (Skip_MapEntries + 1);
3135 ASSERT(!(Lba & 0x80000000));
3153 (*_NextOffset) = NextOffset;
3158#pragma warning(push)
3159#pragma warning(disable:4035)
3181#ifndef UDF_READ_ONLY_BUILD
3197 if(!ExtInfo || !ExtInfo->Mapping)
3203 SIZE_T to_write, _WrittenBytes;
3208 AdPrint((
"Write ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
3210 Offset += ExtInfo->Offset;
3238 Extent = ExtInfo->Mapping;
3271 Extent = ExtInfo->Mapping;
3292 if((sect_offs || (sect_offs + to_write < Vcb->LBlockSize) )
3297 Vcb->LBlockSize, Direct,
Vcb->ZBuffer, &_WrittenBytes);
3302 if((sect_offs + to_write >
Vcb->LBlockSize) &&
3303 (sect_offs + to_write) & (
Vcb->LBlockSize - 1)) {
3305 (( ((
uint64)Lba) <<
Vcb->BlockSizeBits) + sect_offs + to_write) & ~((
int64)(
Vcb->LBlockSize)-1),
3306 Vcb->LBlockSize, Direct,
Vcb->ZBuffer, &_WrittenBytes);
3317 *WrittenBytes += _WrittenBytes;
3328 AdPrint((
"Write: ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
3348 if(!ExtInfo || !ExtInfo->Mapping)
3354 SIZE_T to_write, _WrittenBytes;
3357 AdPrint((
"Zero ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
3359 Offset += ExtInfo->Offset;
3372 *WrittenBytes += to_write;
3380 Extent = ExtInfo->Mapping;
3381 *WrittenBytes += to_write;
3386 min(to_write, LBS-sect_offs),
3387 Direct,
Vcb->ZBuffer, &_WrittenBytes);
3388 *WrittenBytes += _WrittenBytes;
3393 to_write -= _WrittenBytes;
3400 if(to_write >= LBS) {
3402 sect_offs = to_write & ~(LBS - 1);
3411 Extent = ExtInfo->Mapping;
3414 *WrittenBytes += sect_offs;
3415 to_write -= sect_offs;
3424 *WrittenBytes += _WrittenBytes;
3427 ASSERT(to_write == _WrittenBytes);
3430 AdPrint((
"Zero... ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
3435 AdPrint((
"Zero: ExtInfo %x, Mapping %x\n", ExtInfo, ExtInfo->Mapping));
uint32 __fastcall UDFPartEnd(PVCB Vcb, uint32 PartNum)
uint32 __fastcall UDFPartStart(PVCB Vcb, uint32 PartNum)
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
SIZE_T __stdcall UDFGetBitmapLen(uint32 *Bitmap, SIZE_T Offs, SIZE_T Lim)
uint32 __fastcall UDFPartLbaToPhys(IN PVCB Vcb, IN lb_addr *Addr)
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
static void xor(unsigned char *dst, const unsigned char *a, const unsigned char *b, const int count)
struct _EXTENDED_FILE_ENTRY EXTENDED_FILE_ENTRY
struct _EXTENT_AD * PEXTENT_AD
struct _ALLOC_EXT_DESC ALLOC_EXT_DESC
struct _SHORT_AD * PSHORT_AD
#define EXTENT_NOT_RECORDED_ALLOCATED
struct _ALLOC_EXT_DESC * PALLOC_EXT_DESC
#define TID_EXTENDED_FILE_ENTRY
struct _SHORT_AD SHORT_AD
#define ICB_FLAG_AD_SHORT
#define EXTENT_NOT_RECORDED_NOT_ALLOCATED
#define EXTENT_NEXT_EXTENT_ALLOCDESC
#define EXTENT_RECORDED_ALLOCATED
struct _EXTENT_AD EXTENT_AD
struct _EXTENDED_FILE_ENTRY * PEXTENDED_FILE_ENTRY
#define TID_ALLOC_EXTENT_DESC
struct _FILE_ENTRY * PFILE_ENTRY
#define ICB_FLAG_AD_IN_ICB
#define ICB_FLAG_ALLOC_MASK
#define ICB_FLAG_AD_EXTENDED
static PVOID Mapping[EMS_PHYSICAL_PAGES]
#define UDFReleaseResource(Resource)
#define ValidateFileInfo(fi)
#define UDFAcquireResourceExclusive(Resource, CanWait)
OSSTATUS UDFRelocateExtent(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN uint32 ExtBlock, IN uint32 Lba, IN uint32 BC)
OSSTATUS UDFBuildAllocDescs(IN PVCB Vcb, IN uint32 PartNum, IN OUT PUDF_FILE_INFO FileInfo, OUT int8 **AllocData)
PEXTENT_MAP UDFShortAllocDescToMapping(IN PVCB Vcb, IN uint32 PartNum, IN PSHORT_AD AllocDesc, IN uint32 AllocDescLength, IN uint32 SubCallCount, OUT PEXTENT_INFO AllocLoc)
OSSTATUS UDFMarkNotAllocatedAsAllocated(IN PVCB Vcb, IN int64 Offset, IN uint32 Length, IN PEXTENT_INFO ExtInfo)
void UDFDiscardFESpace(IN PVCB Vcb, IN PEXTENT_MAP Mapping, IN uint32 lim)
uint32 UDFNextExtentToLba(IN PVCB Vcb, IN PEXTENT_MAP Extent, OUT PSIZE_T AvailLength, OUT uint32 *Flags, OUT uint32 *Index)
PEXTENT_MAP UDFExtAllocDescToMapping(IN PVCB Vcb, IN PEXT_AD AllocDesc, IN uint32 AllocDescLength, IN uint32 SubCallCount, OUT PEXTENT_INFO AllocLoc)
PEXTENT_MAP UDFLongAllocDescToMapping(IN PVCB Vcb, IN PLONG_AD AllocDesc, IN uint32 AllocDescLength, IN uint32 SubCallCount, OUT PEXTENT_INFO AllocLoc)
int64 UDFGetExtentLength(IN PEXTENT_MAP Extent)
OSSTATUS __fastcall UDFUnPackMapping(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo)
OSSTATUS UDFReadExtentLocation(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN int64 Offset, OUT PEXTENT_MAP *_SubExtInfo, IN OUT uint32 *_SubExtInfoSz, OUT int64 *_NextOffset)
OSSTATUS UDFInitAllocationCache(IN PVCB Vcb, IN uint32 AllocClass, OUT PUDF_ALLOCATION_CACHE_ITEM *_AllocCache, OUT uint32 *_lim, IN BOOLEAN Init)
OSSTATUS UDFReadExtent(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, OUT int8 *Buffer, OUT PSIZE_T ReadBytes)
PEXTENT_MAP __fastcall UDFExtentToMapping_(IN PEXTENT_AD Extent)
OSSTATUS UDFAllocateFESpace(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN uint32 PartNum, IN PEXTENT_INFO FEExtInfo, IN uint32 Len)
void UDFFlushFESpace(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc, IN BOOLEAN Discard)
uint32 UDFGetZeroLength(IN int8 *Buffer, IN uint32 Length)
OSSTATUS UDFFlushAllCachedAllocations(IN PVCB Vcb, IN uint32 AllocClass)
OSSTATUS UDFMarkAllocatedAsRecorded(IN PVCB Vcb, IN int64 Offset, IN uint32 Length, IN PEXTENT_INFO ExtInfo)
OSSTATUS UDFMarkAllocatedAsNotXXX(IN PVCB Vcb, IN int64 Offset, IN uint32 Length, IN PEXTENT_INFO ExtInfo, IN BOOLEAN Deallocate)
OSSTATUS UDFStoreCachedAllocation(IN PVCB Vcb, IN uint32 ParentLocation, IN PEXTENT_INFO Ext, IN uint32 Items, IN uint32 AllocClass)
uint32 UDFExtentOffsetToLba(IN PVCB Vcb, IN PEXTENT_MAP Extent, IN int64 Offset, OUT uint32 *SectorOffset, OUT PSIZE_T AvailLength, OUT uint32 *Flags, OUT uint32 *Index)
void __fastcall UDFPackMapping(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo)
void UDFFreeFESpace(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN PEXTENT_INFO FEExtInfo)
PEXTENT_MAP UDFReadMappingFromXEntry(IN PVCB Vcb, IN uint32 PartNum, IN tag *XEntry, IN OUT uint32 *Offset, OUT PEXTENT_INFO AllocLoc)
OSSTATUS UDFBuildShortAllocDescs(IN PVCB Vcb, IN uint32 PartNum, OUT int8 **Buff, IN uint32 InitSz, IN OUT PUDF_FILE_INFO FileInfo)
OSSTATUS UDFZeroExtent(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Deallocate, IN BOOLEAN Direct, OUT PSIZE_T WrittenBytes)
BOOLEAN UDFIsExtentCached(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN int64 Offset, IN uint32 Length, IN BOOLEAN ForWrite)
OSSTATUS UDFResizeExtent(IN PVCB Vcb, IN uint32 PartNum, IN int64 Length, IN BOOLEAN AlwaysInIcb, OUT PEXTENT_INFO ExtInfo)
void UDFFreeFileAllocation(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN PUDF_FILE_INFO FileInfo)
PEXTENT_MAP __fastcall UDFMergeMappings(IN PEXTENT_MAP Extent, IN PEXTENT_MAP Extent2)
ULONG UDFLocateLbaInExtent(IN PVCB Vcb, IN PEXTENT_MAP Extent, IN lba_t lba)
OSSTATUS UDFBuildLongAllocDescs(IN PVCB Vcb, IN uint32 PartNum, OUT int8 **Buff, IN uint32 InitSz, IN OUT PUDF_FILE_INFO FileInfo)
OSSTATUS UDFGetCachedAllocation(IN PVCB Vcb, IN uint32 ParentLocation, OUT PEXTENT_INFO Ext, OUT uint32 *Items, IN uint32 AllocClass)
OSSTATUS UDFWriteExtent(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
uint32 UDFGetMappingLength(IN PEXTENT_MAP Extent)
_Must_inspect_result_ _In_ USHORT NewSize
GLuint GLuint GLsizei GLenum type
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static struct proto Ext[]
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define UDF_EXTENT_FLAG_MASK
#define UDF_EXTENT_LENGTH_MASK
OSSTATUS UDFWriteData(IN PVCB Vcb, IN BOOLEAN Translate, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
OSSTATUS UDFReadData(IN PVCB Vcb, IN BOOLEAN Translate, IN LONGLONG Offset, IN ULONG Length, IN BOOLEAN Direct, OUT PCHAR Buffer, OUT PSIZE_T ReadBytes)
static calc_node_t * pop(void)
static void push(calc_node_t *op)
#define STATUS_END_OF_FILE
uint32 lengthExtendedAttr
uint32 lengthExtendedAttr
uint16 partitionReferenceNum
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl ebx
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esi
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define UDF_VCB_IC_W2K_COMPAT_ALLOC_DESCS
void UDFSetUpTag(IN PVCB Vcb, IN tag *Tag, IN uint16 DataLen, IN uint32 TagLoc)
#define UDFAllocFreeExtent(v, l, ss, sl, e, af)
#define UDFMarkSpaceAsXXXNoProtect(Vcb, FileInfo, Map, asXXX)
#define UDFMarkAllocatedAsNotAllocated(Vcb, Off, Len, Ext)
#define UDFExtentToMapping(e)
#define UDF_PREALLOC_CLASS_DIR
#define UDF_PREALLOC_CLASS_FE
#define UDFGetFreeBit(arr, bit)
#define UDFMarkRecordedAsAllocated(Vcb, Off, Len, Ext)
#define UDFGetBadBit(arr, bit)
#define UDFCheckSpaceAllocation(Vcb, FileInfo, Map, asXXX)
#define UDFMarkSpaceAsXXX(Vcb, FileInfo, Map, asXXX)
#define ALLOC_DESC_MAX_RECURSE
#define EXTENT_FLAG_2K_COMPAT
#define LBA_NOT_ALLOCATED
#define MEM_ALLOCDESC_TAG
#define EXTENT_FLAG_CUT_PREALLOCATED
#define UDF_FE_FLAG_IS_SDIR
File is a StreamDir.
#define EXTENT_FLAG_VERIFY
#define EXTENT_FLAG_ALLOC_MASK
#define EXTENT_FLAG_PREALLOCATED
#define UDF_MAX_EXTENT_LENGTH
#define MEM_ALLOC_CACHE_TAG
struct _UDF_ALLOCATION_CACHE_ITEM * PUDF_ALLOCATION_CACHE_ITEM
#define LBA_OUT_OF_EXTENT
#define EXTENT_FLAG_ALLOC_SEQUENTIAL
#define PACK_MAPPING_THRESHOLD
#define STATUS_ACCESS_DENIED
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
OSSTATUS WCacheStartDirect__(IN PW_CACHE Cache, IN PVOID Context, IN BOOLEAN Exclusive)
OSSTATUS WCacheEODirect__(IN PW_CACHE Cache, IN PVOID Context)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_Must_inspect_result_ _In_ ULONG Flags