ReactOS  0.4.14-dev-358-gbef841c
alloc.cpp File Reference
#include "udf.h"
Include dependency graph for alloc.cpp:

Go to the source code of this file.

Macros

#define UDF_BUG_CHECK_ID   UDF_FILE_UDF_INFO_ALLOC
 
#define BIT_C   (sizeof(Vcb->BSBM_Bitmap[0])*8)
 

Functions

uint32 UDFPhysLbaToPart (IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
 
uint32 __fastcall UDFPartLbaToPhys (IN PVCB Vcb, IN lb_addr *Addr)
 
uint32 __fastcall UDFGetPartNumByPhysLba (IN PVCB Vcb, IN uint32 Lba)
 
uint32 __fastcall UDFPartStart (PVCB Vcb, uint32 PartNum)
 
uint32 __fastcall UDFPartEnd (PVCB Vcb, uint32 PartNum)
 
uint32 __fastcall UDFPartLen (PVCB Vcb, uint32 PartNum)
 
SIZE_T __stdcall UDFGetBitmapLen (uint32 *Bitmap, SIZE_T Offs, SIZE_T Lim)
 
SIZE_T UDFFindMinSuitableExtent (IN PVCB Vcb, IN uint32 Length, IN uint32 SearchStart, IN uint32 SearchLim, OUT uint32 *MaxExtLen, IN uint8 AllocFlags)
 
void UDFMarkBadSpaceAsUsed (IN PVCB Vcb, IN lba_t lba, IN ULONG len)
 
void UDFMarkSpaceAsXXXNoProtect_ (IN PVCB Vcb, IN PEXTENT_MAP Map, IN uint32 asXXX)
 
void UDFMarkSpaceAsXXX_ (IN PVCB Vcb, IN PEXTENT_MAP Map, IN uint32 asXXX)
 
OSSTATUS UDFAllocFreeExtent_ (IN PVCB Vcb, IN int64 Length, IN uint32 SearchStart, IN uint32 SearchLim, OUT PEXTENT_INFO ExtInfo, IN uint8 AllocFlags)
 
uint32 __fastcall UDFGetPartFreeSpace (IN PVCB Vcb, IN uint32 partNum)
 
int64 __fastcall UDFGetFreeSpace (IN PVCB Vcb)
 
int64 __fastcall UDFGetTotalSpace (IN PVCB Vcb)
 
uint32 UDFIsBlockAllocated (IN void *_Vcb, IN uint32 Lba)
 

Variables

static const int8 bit_count_tab []
 

Macro Definition Documentation

◆ BIT_C

#define BIT_C   (sizeof(Vcb->BSBM_Bitmap[0])*8)

◆ UDF_BUG_CHECK_ID

#define UDF_BUG_CHECK_ID   UDF_FILE_UDF_INFO_ALLOC

Definition at line 20 of file alloc.cpp.

Function Documentation

◆ UDFAllocFreeExtent_()

OSSTATUS UDFAllocFreeExtent_ ( IN PVCB  Vcb,
IN int64  Length,
IN uint32  SearchStart,
IN uint32  SearchLim,
OUT PEXTENT_INFO  ExtInfo,
IN uint8  AllocFlags 
)

Definition at line 963 of file alloc.cpp.

975 {
976  EXTENT_AD Ext;
977  PEXTENT_MAP Map = NULL;
978  uint32 len, LBS, BSh, blen;
979 
980  LBS = Vcb->LBlockSize;
981  BSh = Vcb->BlockSizeBits;
982  blen = (uint32)(((Length+LBS-1) & ~((int64)LBS-1)) >> BSh);
983  ExtInfo->Mapping = NULL;
984  ExtInfo->Offset = 0;
985 
986  ASSERT(blen <= (uint32)(UDF_MAX_EXTENT_LENGTH >> BSh));
987 
988  UDFAcquireResourceExclusive(&(Vcb->BitMapResource1),TRUE);
989 
990  if(blen > (SearchLim - SearchStart)) {
991  goto no_free_space_err;
992  }
993  // walk through the free space bitmap & find a single extent or a set of
994  // frags giving in sum the Length specified
995  while(blen) {
996  Ext.extLocation = UDFFindMinSuitableExtent(Vcb, blen, SearchStart,
997  SearchLim, &len, AllocFlags);
998 
999 // ASSERT(len <= (uint32)(UDF_MAX_EXTENT_LENGTH >> BSh));
1000  if(len >= blen) {
1001  // complete search
1002  Ext.extLength = blen<<BSh;
1003  blen = 0;
1004  } else if(len) {
1005  // we need still some frags to complete request &
1006  // probably we have the opportunity to do it
1007  Ext.extLength = len<<BSh;
1008  blen -= len;
1009  } else {
1010 no_free_space_err:
1011  // no more free space. abort
1012  if(ExtInfo->Mapping) {
1013  UDFMarkSpaceAsXXXNoProtect(Vcb, 0, ExtInfo->Mapping, AS_DISCARDED); // free
1014  MyFreePool__(ExtInfo->Mapping);
1015  ExtInfo->Mapping = NULL;
1016  }
1017  UDFReleaseResource(&(Vcb->BitMapResource1));
1018  ExtInfo->Length = 0;//UDFGetExtentLength(ExtInfo->Mapping);
1019  AdPrint((" DISK_FULL\n"));
1020  return STATUS_DISK_FULL;
1021  }
1022  // append the frag found to mapping
1023  ASSERT(!(Ext.extLength >> 30));
1024  ASSERT(Ext.extLocation);
1025 
1026  // mark newly allocated blocks as zero-filled
1027  UDFSetZeroBits(Vcb->ZSBM_Bitmap, Ext.extLocation, (Ext.extLength & UDF_EXTENT_LENGTH_MASK) >> BSh);
1028 
1029  if(AllocFlags & EXTENT_FLAG_VERIFY) {
1030  if(!UDFCheckArea(Vcb, Ext.extLocation, Ext.extLength >> BSh)) {
1031  AdPrint(("newly allocated extent contains BB\n"));
1032  UDFMarkSpaceAsXXXNoProtect(Vcb, 0, ExtInfo->Mapping, AS_DISCARDED); // free
1033  UDFMarkBadSpaceAsUsed(Vcb, Ext.extLocation, Ext.extLength >> BSh); // bad -> bad+used
1034  // roll back
1035  blen += Ext.extLength>>BSh;
1036  continue;
1037  }
1038  }
1039 
1040  Ext.extLength |= EXTENT_NOT_RECORDED_ALLOCATED << 30;
1041  if(!(ExtInfo->Mapping)) {
1042  // create new
1043 #ifdef UDF_TRACK_ALLOC_FREE_EXTENT
1044  ExtInfo->Mapping = UDFExtentToMapping_(&Ext, src, line);
1045 #else // UDF_TRACK_ALLOC_FREE_EXTENT
1046  ExtInfo->Mapping = UDFExtentToMapping(&Ext);
1047 #endif // UDF_TRACK_ALLOC_FREE_EXTENT
1048  if(!ExtInfo->Mapping) {
1049  BrutePoint();
1050  UDFReleaseResource(&(Vcb->BitMapResource1));
1051  ExtInfo->Length = 0;
1053  }
1054  UDFMarkSpaceAsXXXNoProtect(Vcb, 0, ExtInfo->Mapping, AS_USED); // used
1055  } else {
1056  // update existing
1057  Map = UDFExtentToMapping(&Ext);
1058  if(!Map) {
1059  BrutePoint();
1060  UDFReleaseResource(&(Vcb->BitMapResource1));
1061  ExtInfo->Length = UDFGetExtentLength(ExtInfo->Mapping);
1063  }
1064  UDFMarkSpaceAsXXXNoProtect(Vcb, 0, Map, AS_USED); // used
1065  ExtInfo->Mapping = UDFMergeMappings(ExtInfo->Mapping, Map);
1066  MyFreePool__(Map);
1067  }
1068  if(!ExtInfo->Mapping) {
1069  BrutePoint();
1070  UDFReleaseResource(&(Vcb->BitMapResource1));
1071  ExtInfo->Length = 0;
1073  }
1074  }
1075  UDFReleaseResource(&(Vcb->BitMapResource1));
1076  ExtInfo->Length = Length;
1077  return STATUS_SUCCESS;
1078 } // end UDFAllocFreeExtent_()
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
#define EXTENT_FLAG_VERIFY
Definition: udf_rel.h:81
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
unsigned int uint32
Definition: types.h:32
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
long long int64
Definition: platform.h:13
void UDFMarkBadSpaceAsUsed(IN PVCB Vcb, IN lba_t lba, IN ULONG len)
Definition: alloc.cpp:761
#define UDFSetZeroBits(arr, bit, bc)
Definition: udf_info.h:1210
SIZE_T UDFFindMinSuitableExtent(IN PVCB Vcb, IN uint32 Length, IN uint32 SearchStart, IN uint32 SearchLim, OUT uint32 *MaxExtLen, IN uint8 AllocFlags)
Definition: alloc.cpp:556
smooth NULL
Definition: ftsmooth.c:416
#define UDFMarkSpaceAsXXXNoProtect(Vcb, FileInfo, Map, asXXX)
Definition: udf_info.h:302
PEXTENT_MAP __fastcall UDFExtentToMapping_(IN PEXTENT_AD Extent)
Definition: extent.cpp:189
Definition: parser.c:48
int64 UDFGetExtentLength(IN PEXTENT_MAP Extent)
Definition: extent.cpp:142
PEXTENT_MAP __fastcall UDFMergeMappings(IN PEXTENT_MAP Extent, IN PEXTENT_MAP Extent2)
Definition: extent.cpp:266
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define BrutePoint()
Definition: env_spec_w32.h:504
#define EXTENT_NOT_RECORDED_ALLOCATED
Definition: ecma_167.h:368
#define UDFExtentToMapping(e)
Definition: udf_info.h:181
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static struct proto Ext[]
Definition: mkg3states.c:87
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define UDF_MAX_EXTENT_LENGTH
Definition: udf_rel.h:511
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
#define AS_USED
Definition: udf_info.h:327
#define AS_DISCARDED
Definition: udf_info.h:328
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155
return STATUS_SUCCESS
Definition: btrfs.c:2938
BOOLEAN __fastcall UDFCheckArea(IN PVCB Vcb, IN lba_t LBA, IN uint32 BCount)
Definition: remap.cpp:763
#define UDF_EXTENT_LENGTH_MASK
Definition: osta_misc.h:148

◆ UDFFindMinSuitableExtent()

SIZE_T UDFFindMinSuitableExtent ( IN PVCB  Vcb,
IN uint32  Length,
IN uint32  SearchStart,
IN uint32  SearchLim,
OUT uint32 MaxExtLen,
IN uint8  AllocFlags 
)

Definition at line 556 of file alloc.cpp.

564 {
565  SIZE_T i, len;
566  uint32* cur;
567  SIZE_T best_lba=0;
568  SIZE_T best_len=0;
569  SIZE_T max_lba=0;
570  SIZE_T max_len=0;
571  BOOLEAN align = FALSE;
572  SIZE_T PS = Vcb->WriteBlockSize >> Vcb->BlockSizeBits;
573 
575 
576  // we'll try to allocate packet-aligned block at first
577  if(!(Length & (PS-1)) && !Vcb->CDR_Mode && (Length >= PS*2))
578  align = TRUE;
579  if(AllocFlags & EXTENT_FLAG_ALLOC_SEQUENTIAL)
580  align = TRUE;
581  if(Length > (uint32)(UDF_MAX_EXTENT_LENGTH >> Vcb->BlockSizeBits))
582  Length = (UDF_MAX_EXTENT_LENGTH >> Vcb->BlockSizeBits);
583  // align Length according to _Logical_ block size & convert it to BCount
584  i = (1<<Vcb->LB2B_Bits)-1;
585  Length = (Length+i) & ~i;
586  cur = (uint32*)(Vcb->FSBM_Bitmap);
587 
588 retry_no_align:
589 
590  i=SearchStart;
591  // scan Bitmap
592  while(i<SearchLim) {
593  ASSERT(i <= SearchLim);
594  if(align) {
595  i = (i+PS-1) & ~(PS-1);
596  ASSERT(i <= SearchLim);
597  if(i >= SearchLim)
598  break;
599  }
600  len = UDFGetBitmapLen(cur, i, SearchLim);
601  if(UDFGetFreeBit(cur, i)) { // is the extent found free or used ?
602  // wow! it is free!
603  if(len >= Length) {
604  // minimize extent length
605  if(!best_len || (best_len > len)) {
606  best_lba = i;
607  best_len = len;
608  }
609  if(len == Length)
610  break;
611  } else {
612  // remember max extent
613  if(max_len < len) {
614  max_lba = i;
615  max_len = len;
616  }
617  }
618  // if this is CD-R mode, we should not think about fragmentation
619  // due to CD-R nature file will be fragmented in any case
620  if(Vcb->CDR_Mode) break;
621  }
622  i += len;
623  }
624  // if we can't find suitable Packet-size aligned block,
625  // retry without any alignment requirements
626  if(!best_len && align) {
627  align = FALSE;
628  goto retry_no_align;
629  }
630  if(best_len) {
631  // minimal suitable block
632  (*MaxExtLen) = best_len;
633  return best_lba;
634  }
635  // maximal available
636  (*MaxExtLen) = max_len;
637  return max_lba;
638 } // end UDFFindMinSuitableExtent()
#define TRUE
Definition: types.h:120
unsigned int uint32
Definition: types.h:32
int align(int length, int align)
Definition: dsound8.c:36
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
Definition: glfuncs.h:248
unsigned char BOOLEAN
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define UDF_MAX_EXTENT_LENGTH
Definition: udf_rel.h:511
GLenum GLsizei len
Definition: glext.h:6722
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define UDF_CHECK_BITMAP_RESOURCE(Vcb)
Definition: udffs.h:264
#define UDFGetFreeBit(arr, bit)
Definition: udf_info.h:1199
#define EXTENT_FLAG_ALLOC_SEQUENTIAL
Definition: udf_rel.h:77
SIZE_T __stdcall UDFGetBitmapLen(uint32 *Bitmap, SIZE_T Offs, SIZE_T Lim)
Definition: alloc.cpp:496

Referenced by UDFAllocFreeExtent_().

◆ UDFGetBitmapLen()

SIZE_T __stdcall UDFGetBitmapLen ( uint32 Bitmap,
SIZE_T  Offs,
SIZE_T  Lim 
)

Definition at line 496 of file alloc.cpp.

501 {
502  ASSERT(Offs <= Lim);
503  if(Offs >= Lim) {
504  return 0;//(Offs == Lim);
505  }
506 
507  BOOLEAN bit = UDFGetBit(Bitmap, Offs);
508  SIZE_T i=Offs>>5;
509  SIZE_T len=0;
510  uint8 j=(uint8)(Offs&31);
511  uint8 lLim=(uint8)(Lim&31);
512 
513  Lim = Lim>>5;
514 
515  ASSERT((bit == 0) || (bit == 1));
516 
517  uint32 a;
518 
519  a = Bitmap[i] >> j;
520 
521  while(i<=Lim) {
522 
523  while( j < ((i<Lim) ? 32 : lLim) ) {
524  if( ((BOOLEAN)(a&1)) != bit)
525  return len;
526  len++;
527  a>>=1;
528  j++;
529  }
530  j=0;
531 While_3:
532  i++;
533  a = Bitmap[i];
534 
535  if(i<Lim) {
536  if((bit && (a==0xffffffff)) ||
537  (!bit && !a)) {
538  len+=32;
539  goto While_3;
540  }
541  }
542  }
543 
544  return len;
545 
546 #endif // _X86_
547 
548 } // end UDFGetBitmapLen()
unsigned int uint32
Definition: types.h:32
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
Definition: glfuncs.h:248
#define a
Definition: ke_i.h:78
unsigned char BOOLEAN
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
Definition: glfuncs.h:250
unsigned char uint8
Definition: types.h:28
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
GLenum GLsizei len
Definition: glext.h:6722
ULONG_PTR SIZE_T
Definition: typedefs.h:78
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define UDFGetBit(arr, bit)
Definition: udf_info.h:1180

Referenced by UDFAddXSpaceBitmap(), UDFFindMinSuitableExtent(), and UDFResizeExtent().

◆ UDFGetFreeSpace()

int64 __fastcall UDFGetFreeSpace ( IN PVCB  Vcb)

Definition at line 1105 of file alloc.cpp.

1108 {
1109  int64 s=0;
1110  uint32 i;
1111 // uint32* cur = (uint32*)(Vcb->FSBM_Bitmap);
1112 
1113  if(!Vcb->CDR_Mode &&
1114  !(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK)) {
1115  for(i=0;i<Vcb->PartitionMaps;i++) {
1116 /* lim = UDFPartEnd(Vcb,i);
1117  for(j=UDFPartStart(Vcb,i); j<lim && len; ) {
1118  len = UDFGetBitmapLen(cur, j, lim);
1119  if(UDFGetFreeBit(cur, j)) // is the extent found free or used ?
1120  s+=len;
1121  j+=len;
1122  }*/
1123  s += UDFGetPartFreeSpace(Vcb, i);
1124  }
1125  } else {
1126  ASSERT(Vcb->LastPossibleLBA >= max(Vcb->NWA, Vcb->LastLBA));
1127  s = Vcb->LastPossibleLBA - max(Vcb->NWA, Vcb->LastLBA);
1128  //if(s & ((int64)1 << 64)) s=0;
1129  }
1130  return s >> Vcb->LB2B_Bits;
1131 } // end UDFGetFreeSpace()
#define max(a, b)
Definition: svc.c:63
unsigned int uint32
Definition: types.h:32
long long int64
Definition: platform.h:13
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
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
Definition: glfuncs.h:248
uint32 __fastcall UDFGetPartFreeSpace(IN PVCB Vcb, IN uint32 partNum)
Definition: alloc.cpp:1086
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
GLdouble s
Definition: gl.h:2039

Referenced by UDFEjectReqWaiter(), UDFMountVolume(), UDFQueryFsFullSizeInfo(), UDFQueryFsSizeInfo(), and UDFSetAllocationInformation().

◆ UDFGetPartFreeSpace()

uint32 __fastcall UDFGetPartFreeSpace ( IN PVCB  Vcb,
IN uint32  partNum 
)

Definition at line 1086 of file alloc.cpp.

1090 {
1091  uint32 lim/*, len=1*/;
1092  uint32 s=0;
1093  uint32 j;
1094  PUCHAR cur = (PUCHAR)(Vcb->FSBM_Bitmap);
1095 
1096  lim = (UDFPartEnd(Vcb,partNum)+7)/8;
1097  for(j=(UDFPartStart(Vcb,partNum)+7)/8; j<lim/* && len*/; j++) {
1098  s+=bit_count_tab[cur[j]];
1099  }
1100  return s;
1101 } // end UDFGetPartFreeSpace()
unsigned int uint32
Definition: types.h:32
unsigned char * PUCHAR
Definition: retypes.h:3
uint32 __fastcall UDFPartStart(PVCB Vcb, uint32 PartNum)
Definition: alloc.cpp:222
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
Definition: glfuncs.h:250
#define Vcb
Definition: cdprocs.h:1425
static const int8 bit_count_tab[]
Definition: alloc.cpp:22
GLdouble s
Definition: gl.h:2039
uint32 __fastcall UDFPartEnd(PVCB Vcb, uint32 PartNum)
Definition: alloc.cpp:242

Referenced by UDFGetFreeSpace(), and UDFUpdateLogicalVolInt().

◆ UDFGetPartNumByPhysLba()

uint32 __fastcall UDFGetPartNumByPhysLba ( IN PVCB  Vcb,
IN uint32  Lba 
)

Definition at line 201 of file alloc.cpp.

205 {
206  uint32 i=Vcb->PartitionMaps-1, root;
207  PUDFPartMap pm = &(Vcb->Partitions[i]);
208  // walk through the partition maps to find suitable one
209  for(;i!=0xffffffff;i--,pm--) {
210  if( ((root = pm->PartitionRoot) <= Lba) &&
211  ((root + pm->PartitionLen) > Lba) ) return (uint16)pm->PartitionNum;
212  }
213  return LBA_OUT_OF_EXTENT; // Lba doesn't belong to any partition
214 } // end UDFGetPartNumByPhysLba()
unsigned int uint32
Definition: types.h:32
struct _root root
static LPMONITOREX pm
Definition: localmon.c:45
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
Definition: glfuncs.h:248
#define Vcb
Definition: cdprocs.h:1425
unsigned short uint16
Definition: types.h:30
#define LBA_OUT_OF_EXTENT
Definition: udf_rel.h:426

Referenced by UDFCloseFile__(), UDFConvertFEToNonInICB(), UDFCreateFile__(), UDFCreateStreamDir__(), UDFFlushFile__(), UDFIndexDirectory(), UDFMarkNotAllocatedAsAllocated(), UDFMarkSpaceAsXXXNoProtect_(), UDFPackDirectory__(), UDFRecordDirectory__(), UDFRenameMoveFile__(), UDFResizeFile__(), UDFReTagDirectory(), UDFUpdateNonAllocated(), UDFUpdateVAT(), and UDFWriteFile__().

◆ UDFGetTotalSpace()

int64 __fastcall UDFGetTotalSpace ( IN PVCB  Vcb)

Definition at line 1138 of file alloc.cpp.

1141 {
1142  int64 s=0;
1143  uint32 i;
1144 
1145  if(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK) {
1146  s= Vcb->LastPossibleLBA;
1147  } else if(!Vcb->CDR_Mode) {
1148  for(i=0;i<Vcb->PartitionMaps;i++) {
1149  s+=Vcb->Partitions[i].PartitionLen;
1150  }
1151  } else {
1152  if(s & ((int64)1 << 63)) s=0; /* FIXME ReactOS this shift value was 64, which is undefiened behavior. */
1153  s= Vcb->LastPossibleLBA - Vcb->Partitions[0].PartitionRoot;
1154  }
1155  return s >> Vcb->LB2B_Bits;
1156 } // end UDFGetTotalSpace()
unsigned int uint32
Definition: types.h:32
long long int64
Definition: platform.h:13
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
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
Definition: glfuncs.h:248
#define Vcb
Definition: cdprocs.h:1425
GLdouble s
Definition: gl.h:2039

Referenced by UDFMountVolume(), UDFQueryFsFullSizeInfo(), and UDFQueryFsSizeInfo().

◆ UDFIsBlockAllocated()

uint32 UDFIsBlockAllocated ( IN void _Vcb,
IN uint32  Lba 
)

Definition at line 1164 of file alloc.cpp.

1168 {
1169  ULONG ret_val = 0;
1170  uint32* bm;
1171 // return TRUE;
1172  if(!(((PVCB)_Vcb)->VCBFlags & UDF_VCB_ASSUME_ALL_USED)) {
1173  // check used
1174  if((bm = (uint32*)(((PVCB)_Vcb)->FSBM_Bitmap)))
1175  ret_val = (UDFGetUsedBit(bm, Lba) ? WCACHE_BLOCK_USED : 0);
1176  // check zero-filled
1177  if((bm = (uint32*)(((PVCB)_Vcb)->ZSBM_Bitmap)))
1178  ret_val |= (UDFGetZeroBit(bm, Lba) ? WCACHE_BLOCK_ZERO : 0);
1179  } else {
1180  ret_val = WCACHE_BLOCK_USED;
1181  }
1182  // check bad block
1183 
1184  // WCache works with LOGICAL addresses, not PHYSICAL, BB check must be performed UNDER cache
1185 /*
1186  if(bm = (uint32*)(((PVCB)_Vcb)->BSBM_Bitmap)) {
1187  ret_val |= (UDFGetBadBit(bm, Lba) ? WCACHE_BLOCK_BAD : 0);
1188  if(ret_val & WCACHE_BLOCK_BAD) {
1189  UDFPrint(("Marked BB @ %#x\n", Lba));
1190  }
1191  }
1192 */
1193  return ret_val;
1194 } // end UDFIsBlockAllocated()
unsigned int uint32
Definition: types.h:32
#define WCACHE_BLOCK_USED
Definition: wcache_lib.h:54
Definition: cdstruc.h:504
#define WCACHE_BLOCK_ZERO
Definition: wcache_lib.h:55
#define UDF_VCB_ASSUME_ALL_USED
Definition: udf_common.h:474
#define UDFGetUsedBit(arr, bit)
Definition: udf_info.h:1198
#define UDFGetZeroBit(arr, bit)
Definition: udf_info.h:1207
unsigned int ULONG
Definition: retypes.h:1

Referenced by UDFMountVolume(), and UDFVerifyVolume().

◆ UDFMarkBadSpaceAsUsed()

void UDFMarkBadSpaceAsUsed ( IN PVCB  Vcb,
IN lba_t  lba,
IN ULONG  len 
)

Definition at line 761 of file alloc.cpp.

766 {
767  uint32 j;
768 #define BIT_C (sizeof(Vcb->BSBM_Bitmap[0])*8)
769  len = (lba+len+BIT_C-1)/BIT_C;
770  if(Vcb->BSBM_Bitmap) {
771  for(j=lba/BIT_C; j<len; j++) {
772  Vcb->FSBM_Bitmap[j] &= ~Vcb->BSBM_Bitmap[j];
773  }
774  }
775 #undef BIT_C
776 } // UDFMarkBadSpaceAsUsed()
unsigned int uint32
Definition: types.h:32
#define lba
#define BIT_C
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
Definition: glfuncs.h:250
#define Vcb
Definition: cdprocs.h:1425
GLenum GLsizei len
Definition: glext.h:6722

Referenced by UDFAllocFreeExtent_(), and UDFMarkSpaceAsXXXNoProtect_().

◆ UDFMarkSpaceAsXXX_()

void UDFMarkSpaceAsXXX_ ( IN PVCB  Vcb,
IN PEXTENT_MAP  Map,
IN uint32  asXXX 
)

Definition at line 928 of file alloc.cpp.

938 {
939  if(!Map) return;
940  if(!Map[0].extLength) {
941 #ifdef UDF_DBG
942  ASSERT(!Map[0].extLocation);
943 #endif // UDF_DBG
944  return;
945  }
946 
947  UDFAcquireResourceExclusive(&(Vcb->BitMapResource1),TRUE);
948 #ifdef UDF_TRACK_ONDISK_ALLOCATION
949  UDFMarkSpaceAsXXXNoProtect_(Vcb, Map, asXXX, FE_lba, BugCheckId, Line);
950 #else //UDF_TRACK_ONDISK_ALLOCATION
951  UDFMarkSpaceAsXXXNoProtect_(Vcb, Map, asXXX);
952 #endif //UDF_TRACK_ONDISK_ALLOCATION
953  UDFReleaseResource(&(Vcb->BitMapResource1));
954 
955 } // end UDFMarkSpaceAsXXX_()
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
#define TRUE
Definition: types.h:120
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ncftp.h:79
void UDFMarkSpaceAsXXXNoProtect_(IN PVCB Vcb, IN PEXTENT_MAP Map, IN uint32 asXXX)
Definition: alloc.cpp:782

◆ UDFMarkSpaceAsXXXNoProtect_()

void UDFMarkSpaceAsXXXNoProtect_ ( IN PVCB  Vcb,
IN PEXTENT_MAP  Map,
IN uint32  asXXX 
)

Definition at line 782 of file alloc.cpp.

792 {
793  uint32 i=0;
794  uint32 lba, j, len, BS, BSh;
795  uint32 root;
796  BOOLEAN asUsed = (asXXX == AS_USED || (asXXX & AS_BAD));
797 #ifdef UDF_TRACK_ONDISK_ALLOCATION
798  BOOLEAN bit_before, bit_after;
799 #endif //UDF_TRACK_ONDISK_ALLOCATION
800 
802 
803  if(!Map) return;
804 
805  BS = Vcb->BlockSize;
806  BSh = Vcb->BlockSizeBits;
807  Vcb->BitmapModified = TRUE;
809  // walk through all frags in data area specified
810  while(Map[i].extLength & UDF_EXTENT_LENGTH_MASK) {
811  if((Map[i].extLength >> 30) == EXTENT_NOT_RECORDED_NOT_ALLOCATED) {
812  // skip unallocated frags
813  i++;
814  continue;
815  }
816  ASSERT(Map[i].extLocation);
817 
818 #ifdef UDF_TRACK_ONDISK_ALLOCATION
819  AdPrint(("Alloc:%x:%s:%x:@:%x:File:%x:Line:%d\n",
820  FE_lba,
821  asUsed ? ((asXXX & AS_BAD) ? "B" : "U") : "F",
822  (Map[i].extLength & UDF_EXTENT_LENGTH_MASK) >> Vcb->BlockSizeBits,
823  Map[i].extLocation,
824  BugCheckId,
825  Line
826  ));
827 #endif //UDF_TRACK_ONDISK_ALLOCATION
828 
829 #ifdef UDF_DBG
830 #ifdef UDF_CHECK_EXTENT_SIZE_ALIGNMENT
831  ASSERT(!(Map[i].extLength & (BS-1)));
832 #endif //UDF_CHECK_EXTENT_SIZE_ALIGNMENT
833 // len = ((Map[i].extLength & UDF_EXTENT_LENGTH_MASK)+BS-1) >> BSh;
834 #else // UDF_DBG
835 // len = (Map[i].extLength & UDF_EXTENT_LENGTH_MASK) >> BSh;
836 #endif // UDF_DBG
837  len = ((Map[i].extLength & UDF_EXTENT_LENGTH_MASK)+BS-1) >> BSh;
838  lba = Map[i].extLocation;
839  if((lba+len) > Vcb->LastPossibleLBA) {
840  // skip blocks beyond media boundary
841  if(lba > Vcb->LastPossibleLBA) {
842  ASSERT(FALSE);
843  i++;
844  continue;
845  }
846  len = Vcb->LastPossibleLBA - lba;
847  }
848 
849 #ifdef UDF_TRACK_ONDISK_ALLOCATION
850  if(lba)
851  bit_before = UDFGetBit(Vcb->FSBM_Bitmap, lba-1);
852  bit_after = UDFGetBit(Vcb->FSBM_Bitmap, lba+len);
853 #endif //UDF_TRACK_ONDISK_ALLOCATION
854 
855  // mark frag as XXX (see asUsed parameter)
856  if(asUsed) {
857 /* for(j=0;j<len;j++) {
858  UDFSetUsedBit(Vcb->FSBM_Bitmap, lba+j);
859  }*/
860  ASSERT(len);
861  UDFSetUsedBits(Vcb->FSBM_Bitmap, lba, len);
862 #ifdef UDF_TRACK_ONDISK_ALLOCATION
863  for(j=0;j<len;j++) {
864  ASSERT(UDFGetUsedBit(Vcb->FSBM_Bitmap, lba+j));
865  }
866 #endif //UDF_TRACK_ONDISK_ALLOCATION
867 
868  if(Vcb->Vat) {
869  // mark logical blocks in VAT as used
870  for(j=0;j<len;j++) {
872  if((Vcb->Vat[lba-root+j] == UDF_VAT_FREE_ENTRY) &&
873  (lba > Vcb->LastLBA)) {
874  Vcb->Vat[lba-root+j] = 0x7fffffff;
875  }
876  }
877  }
878  } else {
879 /* for(j=0;j<len;j++) {
880  UDFSetFreeBit(Vcb->FSBM_Bitmap, lba+j);
881  }*/
882  ASSERT(len);
883  UDFSetFreeBits(Vcb->FSBM_Bitmap, lba, len);
884 #ifdef UDF_TRACK_ONDISK_ALLOCATION
885  for(j=0;j<len;j++) {
886  ASSERT(UDFGetFreeBit(Vcb->FSBM_Bitmap, lba+j));
887  }
888 #endif //UDF_TRACK_ONDISK_ALLOCATION
889  if(asXXX & AS_BAD) {
890  UDFSetBits(Vcb->BSBM_Bitmap, lba, len);
891  }
893 
894  if(asXXX & AS_DISCARDED) {
896  WCacheDiscardBlocks__(&(Vcb->FastCache), Vcb, lba, len);
897  UDFSetZeroBits(Vcb->ZSBM_Bitmap, lba, len);
898  }
899  if(Vcb->Vat) {
900  // mark logical blocks in VAT as free
901  // this operation can decrease resulting VAT size
902  for(j=0;j<len;j++) {
904  Vcb->Vat[lba-root+j] = UDF_VAT_FREE_ENTRY;
905  }
906  }
907  // mark discarded extent as Not-Alloc-Not-Rec to
908  // prevent writes there
909  Map[i].extLength = (len << BSh) | (EXTENT_NOT_RECORDED_NOT_ALLOCATED << 30);
910  Map[i].extLocation = 0;
911  }
912 
913 #ifdef UDF_TRACK_ONDISK_ALLOCATION
914  if(lba)
915  ASSERT(bit_before == UDFGetBit(Vcb->FSBM_Bitmap, lba-1));
916  ASSERT(bit_after == UDFGetBit(Vcb->FSBM_Bitmap, lba+len));
917 #endif //UDF_TRACK_ONDISK_ALLOCATION
918 
919  i++;
920  }
921 } // end UDFMarkSpaceAsXXXNoProtect_()
#define TRUE
Definition: types.h:120
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
unsigned int uint32
Definition: types.h:32
struct _root root
#define lba
void UDFMarkBadSpaceAsUsed(IN PVCB Vcb, IN lba_t lba, IN ULONG len)
Definition: alloc.cpp:761
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
Definition: glfuncs.h:248
#define UDF_VAT_FREE_ENTRY
Definition: osta_misc.h:71
#define UDFSetZeroBits(arr, bit, bc)
Definition: udf_info.h:1210
struct _ACPI_EFI_BOOT_SERVICES * BS
#define UDFSetBits(arr, bit, bc)
Definition: udf_info.h:1184
unsigned char BOOLEAN
#define EXTENT_NOT_RECORDED_NOT_ALLOCATED
Definition: ecma_167.h:369
uint32 __fastcall UDFPartStart(PVCB Vcb, uint32 PartNum)
Definition: alloc.cpp:222
#define AS_BAD
Definition: udf_info.h:329
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
Definition: glfuncs.h:250
#define UDFSetUsedBits(arr, bit, bc)
Definition: udf_info.h:1202
VOID WCacheDiscardBlocks__(IN PW_CACHE Cache, IN PVOID Context, IN lba_t ReqLba, IN ULONG BCount)
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ncftp.h:79
GLenum GLsizei len
Definition: glext.h:6722
#define AS_USED
Definition: udf_info.h:327
#define UDFSetFreeBits(arr, bit, bc)
Definition: udf_info.h:1203
VOID UDFSetModified(IN PVCB Vcb)
Definition: misc_common.cpp:9
#define AS_DISCARDED
Definition: udf_info.h:328
#define UDFGetUsedBit(arr, bit)
Definition: udf_info.h:1198
OSSTATUS __fastcall UDFUnmapRange(IN PVCB Vcb, IN uint32 Lba, IN uint32 BCount)
Definition: remap.cpp:894
#define UDF_CHECK_BITMAP_RESOURCE(Vcb)
Definition: udffs.h:264
#define UDFGetFreeBit(arr, bit)
Definition: udf_info.h:1199
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
Definition: alloc.cpp:201
#define UDFGetBit(arr, bit)
Definition: udf_info.h:1180
#define UDF_EXTENT_LENGTH_MASK
Definition: osta_misc.h:148

Referenced by UDFMarkSpaceAsXXX_().

◆ UDFPartEnd()

uint32 __fastcall UDFPartEnd ( PVCB  Vcb,
uint32  PartNum 
)

Definition at line 242 of file alloc.cpp.

246 {
247  uint32 i;
248  if(PartNum == (uint32)-1) return Vcb->LastLBA;
249  if(PartNum == (uint32)-2) PartNum = Vcb->PartitionMaps-1;
250  for(i=PartNum; i<Vcb->PartitionMaps; i++) {
251  if(Vcb->Partitions[i].PartitionNum == PartNum)
252  return (Vcb->Partitions[i].PartitionRoot +
253  Vcb->Partitions[i].PartitionLen);
254  }
255  return (Vcb->Partitions[i-1].PartitionRoot +
256  Vcb->Partitions[i-1].PartitionLen);
257 } // end UDFPartEnd()
unsigned int uint32
Definition: types.h:32
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
Definition: glfuncs.h:248
#define Vcb
Definition: cdprocs.h:1425

Referenced by UDFAllocateFESpace(), UDFGetPartFreeSpace(), UDFMarkNotAllocatedAsAllocated(), UDFPartLen(), UDFPrepareXSpaceBitmap(), and UDFResizeExtent().

◆ UDFPartLbaToPhys()

uint32 __fastcall UDFPartLbaToPhys ( IN PVCB  Vcb,
IN lb_addr Addr 
)

Definition at line 114 of file alloc.cpp.

118 {
119  uint32 i, a;
120  if(Addr->partitionReferenceNum >= Vcb->PartitionMaps) {
121  AdPrint(("UDFPartLbaToPhys: part %x, lbn %x (err)\n",
122  Addr->partitionReferenceNum, Addr->logicalBlockNum));
123  if(Vcb->PartitionMaps &&
124  (Vcb->CompatFlags & UDF_VCB_IC_INSTANT_COMPAT_ALLOC_DESCS)) {
125  AdPrint(("UDFPartLbaToPhys: try to recover: part %x -> %x\n",
126  Addr->partitionReferenceNum, Vcb->PartitionMaps-1));
127  Addr->partitionReferenceNum = (USHORT)(Vcb->PartitionMaps-1);
128  } else {
129  return LBA_OUT_OF_EXTENT;
130  }
131  }
132  // walk through partition maps & transform relative address
133  // to physical
134  for(i=Addr->partitionReferenceNum; i<Vcb->PartitionMaps; i++) {
135  if(Vcb->Partitions[i].PartitionNum == Addr->partitionReferenceNum) {
136  a = Vcb->Partitions[i].PartitionRoot +
137  (Addr->logicalBlockNum << Vcb->LB2B_Bits);
138  if(a > Vcb->LastPossibleLBA) {
139  AdPrint(("UDFPartLbaToPhys: root %x, lbn %x, lba %x (err1)\n",
140  Vcb->Partitions[i].PartitionRoot, Addr->logicalBlockNum, a));
141  BrutePoint();
142  return LBA_OUT_OF_EXTENT;
143  }
144  return a;
145  }
146  }
147  a = Vcb->Partitions[i-1].PartitionRoot +
148  (Addr->logicalBlockNum << Vcb->LB2B_Bits);
149  if(a > Vcb->LastPossibleLBA) {
150  AdPrint(("UDFPartLbaToPhys: i %x, root %x, lbn %x, lba %x (err2)\n",
151  i, Vcb->Partitions[i-1].PartitionRoot, Addr->logicalBlockNum, a));
152  BrutePoint();
153  return LBA_OUT_OF_EXTENT;
154  }
155  return a;
156 } // end UDFPartLbaToPhys()
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
unsigned int uint32
Definition: types.h:32
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
Definition: glfuncs.h:248
#define a
Definition: ke_i.h:78
#define Vcb
Definition: cdprocs.h:1425
#define BrutePoint()
Definition: env_spec_w32.h:504
#define UDF_VCB_IC_INSTANT_COMPAT_ALLOC_DESCS
Definition: udf_common.h:513
unsigned short USHORT
Definition: pedump.c:61
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define LBA_OUT_OF_EXTENT
Definition: udf_rel.h:426

Referenced by UDFAddXSpaceBitmap(), UDFBuildFreeSpaceBitmap(), UDFExtAllocDescToMapping(), UDFFindLastFileSet(), UDFIndexDirectory(), UDFLoadExtInfo(), UDFLongAllocDescToMapping(), UDFOpenFile__(), UDFOpenRootFile__(), UDFPhysLbaToPart(), UDFPrepareXSpaceBitmap(), UDFReadFileEntry(), UDFShortAllocDescToMapping(), UDFVerifyFreeSpaceBitmap(), and UDFVerifyXSpaceBitmap().

◆ UDFPartLen()

uint32 __fastcall UDFPartLen ( PVCB  Vcb,
uint32  PartNum 
)

Definition at line 265 of file alloc.cpp.

269 {
270 
271  if(PartNum == (uint32)-2) return UDFPartEnd(Vcb, -2) - UDFPartStart(Vcb, -2);
272 /*#ifdef _X86_
273  uint32 ret_val;
274  __asm {
275  mov ebx,Vcb
276  mov eax,PartNum
277  cmp eax,-1
278  jne short NOT_last_gpl
279  mov eax,[ebx]Vcb.LastLBA
280  jmp short EO_gpl
281 NOT_last_gpl:
282  mov esi,eax
283  xor eax,eax
284  mov ecx,[ebx]Vcb.PartitionMaps
285  jecxz EO_gpl
286 
287  mov eax,esi
288  mov edx,size UDFTrackMap
289  mul edx
290  add ebx,eax
291  mov eax,esi
292 gpl_loop:
293  cmp [ebx]Vcb.PartitionMaps.PartitionNum,ax
294  je short EO_gpl_1
295  add ebx,size UDFTrackMap
296  inc eax
297  cmp eax,ecx
298  jb short gpl_loop
299  sub ebx,size UDFTrackMap
300 EO_gpl_1:
301  mov eax,[ebx]Vcb.PartitionMaps.PartitionLen
302  add eax,[ebx]Vcb.PartitionMaps.PartitionRoot
303 EO_gpl:
304  mov ret_val,eax
305  }
306  return ret_val;
307 #else // NO X86 optimization , use generic C/C++*/
308  uint32 i;
309  if(PartNum == (uint32)-1) return Vcb->LastLBA;
310  for(i=PartNum; i<Vcb->PartitionMaps; i++) {
311  if(Vcb->Partitions[i].PartitionNum == PartNum)
312  return Vcb->Partitions[i].PartitionLen;
313  }
314  return (Vcb->Partitions[i-1].PartitionRoot +
315  Vcb->Partitions[i-1].PartitionLen);
316 /*#endif // _X86_*/
317 } // end UDFPartLen()
unsigned int uint32
Definition: types.h:32
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
Definition: glfuncs.h:248
uint32 __fastcall UDFPartStart(PVCB Vcb, uint32 PartNum)
Definition: alloc.cpp:222
#define Vcb
Definition: cdprocs.h:1425
uint32 __fastcall UDFPartEnd(PVCB Vcb, uint32 PartNum)
Definition: alloc.cpp:242

Referenced by UDFPrepareXSpaceBitmap(), UDFRecordVAT(), UDFUpdateNonAllocated(), and UDFUpdateXSpaceBitmaps().

◆ UDFPartStart()

uint32 __fastcall UDFPartStart ( PVCB  Vcb,
uint32  PartNum 
)

Definition at line 222 of file alloc.cpp.

226 {
227  uint32 i;
228  if(PartNum == (uint32)-1) return 0;
229  if(PartNum == (uint32)-2) return Vcb->Partitions[0].PartitionRoot;
230  for(i=PartNum; i<Vcb->PartitionMaps; i++) {
231  if(Vcb->Partitions[i].PartitionNum == PartNum) return Vcb->Partitions[i].PartitionRoot;
232  }
233  return 0;
234 } // end UDFPartStart(
unsigned int uint32
Definition: types.h:32
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
Definition: glfuncs.h:248
#define Vcb
Definition: cdprocs.h:1425

Referenced by UDFAddXSpaceBitmap(), UDFAllocateFESpace(), UDFGetPartFreeSpace(), UDFMarkNotAllocatedAsAllocated(), UDFMarkSpaceAsXXXNoProtect_(), UDFPartLen(), UDFPrepareXSpaceBitmap(), UDFRecordVAT(), UDFResizeExtent(), UDFUpdateNonAllocated(), and UDFUpdateXSpaceBitmaps().

◆ UDFPhysLbaToPart()

uint32 UDFPhysLbaToPart ( IN PVCB  Vcb,
IN uint32  PartNum,
IN uint32  Addr 
)

Definition at line 46 of file alloc.cpp.

51 {
52  PUDFPartMap pm = Vcb->Partitions;
53 #if defined (_X86_) && defined (_MSC_VER) && !defined(__clang__)
54  uint32 retval;
55  __asm {
56  push ebx
57  push ecx
58  push edx
59 
60  mov ebx,Vcb
61  mov edx,[ebx]Vcb.PartitionMaps
62  mov ebx,pm
63  mov ecx,PartNum
64  xor eax,eax
65 loop_pl2p:
66  cmp ecx,edx
67  jae short EO_pl2p
68  cmp [ebx]pm.PartitionNum,cx
69  jne short cont_pl2p
70  mov eax,Addr
71  sub eax,[ebx]pm.PartitionRoot
72  mov ecx,Vcb
73  mov ecx,[ecx]Vcb.LB2B_Bits
74  shr eax,cl
75  jmp short EO_pl2p
76 cont_pl2p:
78  inc ecx
79  jmp short loop_pl2p
80 EO_pl2p:
81  mov retval,eax
82 
83  pop edx
84  pop ecx
85  pop ebx
86  }
87 #ifdef UDF_DBG
88  {
89  // validate return value
90  lb_addr locAddr;
91  locAddr.logicalBlockNum = retval;
92  locAddr.partitionReferenceNum = (uint16)PartNum;
93  UDFPartLbaToPhys(Vcb, &locAddr);
94  }
95 #endif // UDF_DBG
96  return retval;
97 #else // NO X86 optimization , use generic C/C++
98  uint32 i;
99  // walk through partition maps to find suitable one...
100  for(i=PartNum; i<Vcb->PartitionMaps; i++, pm++) {
101  if(pm->PartitionNum == PartNum)
102  // wow! return relative address
103  return (Addr - pm->PartitionRoot) >> Vcb->LB2B_Bits;
104  }
105  return 0;
106 #endif // _X86_
107 } // end UDFPhysLbaToPart()
int add
Definition: i386-dis.c:3122
static void xor(unsigned char *dst, const unsigned char *a, const unsigned char *b, const int count)
Definition: crypt_des.c:251
unsigned int uint32
Definition: types.h:32
static LPMONITOREX pm
Definition: localmon.c:45
#define cmp(status, error)
Definition: error.c:114
static calc_node_t * pop(void)
Definition: rpn_ieee.c:90
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
Definition: glfuncs.h:248
uint32 __fastcall UDFPartLbaToPhys(IN PVCB Vcb, IN lb_addr *Addr)
Definition: alloc.cpp:114
GLsizeiptr size
Definition: glext.h:5919
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
#define Vcb
Definition: cdprocs.h:1425
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl ebx
Definition: synth_sse3d.h:83
unsigned short uint16
Definition: types.h:30
uint32 logicalBlockNum
Definition: ecma_167.h:362
uint16 partitionReferenceNum
Definition: ecma_167.h:363
_Out_opt_ int * cx
Definition: commctrl.h:581
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx
Definition: synth_sse3d.h:85
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
jmp_buf jmp
Definition: mach.c:35

Referenced by UDFBuildFileEntry(), UDFBuildLongAllocDescs(), UDFBuildShortAllocDescs(), UDFCloseFile__(), UDFCreateFile__(), UDFCreateRootFile__(), UDFCreateStreamDir__(), UDFFlushFE(), UDFFlushFI(), UDFIndexDirectory(), UDFLoadVAT(), UDFPackDirectory__(), UDFPrepareXSpaceBitmap(), UDFRecordDirectory__(), UDFRecordVAT(), and UDFReTagDirectory().

Variable Documentation

◆ bit_count_tab

const int8 bit_count_tab[]
static
Initial value:
= {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
}

Definition at line 22 of file alloc.cpp.

Referenced by UDFGetPartFreeSpace().