ReactOS 0.4.16-dev-329-g9223134
dirtree.cpp File Reference
#include "udf.h"
Include dependency graph for dirtree.cpp:

Go to the source code of this file.

Macros

#define UDF_BUG_CHECK_ID   UDF_FILE_UDF_INFO_DIR
 
#define MEM_USDIRHASH_TAG   "USDirHash"
 
#define UDF_DUMP_DIRTREE
 
#define DirPrint(x)   UDFPrint(x)
 
#define UDFFindNextFI(a, b, c)   0
 

Functions

PDIR_INDEX_HDR UDFDirIndexAlloc (IN uint_di i)
 
void UDFDirIndexFree (PDIR_INDEX_HDR hDirNdx)
 
OSSTATUS UDFDirIndexGrow (IN PDIR_INDEX_HDR *_hDirNdx, IN uint_di d)
 
OSSTATUS UDFDirIndexTrunc (IN PDIR_INDEX_HDR *_hDirNdx, IN uint_di d)
 
PDIR_INDEX_ITEM UDFDirIndexGetFrame (IN PDIR_INDEX_HDR hDirNdx, IN uint32 Frame, OUT uint32 *FrameLen, OUT uint_di *Index, IN uint_di Rel)
 
BOOLEAN UDFDirIndexInitScan (IN PUDF_FILE_INFO DirInfo, OUT PUDF_DIR_SCAN_CONTEXT Context, IN uint_di Index)
 
PDIR_INDEX_ITEM UDFDirIndexScan (PUDF_DIR_SCAN_CONTEXT Context, PUDF_FILE_INFO *_FileInfo)
 
uint8 UDFBuildHashEntry (IN PVCB Vcb, IN PUNICODE_STRING Name, OUT PHASH_ENTRY hashes, IN uint8 Mask)
 
OSSTATUS UDFIndexDirectory (IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFPackDirectory__ (IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFReTagDirectory (IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFFindFile (IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN BOOLEAN NotDeleted, IN PUNICODE_STRING Name, IN PUDF_FILE_INFO DirInfo, IN OUT uint_di *Index)
 
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo (IN PUDF_FILE_INFO FileInfo)
 
LONG UDFFindDloc (IN PVCB Vcb, IN uint32 Lba)
 
LONG UDFFindDlocInMem (IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
 
LONG UDFFindFreeDloc (IN PVCB Vcb, IN uint32 Lba)
 
OSSTATUS UDFAcquireDloc (IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
 
OSSTATUS UDFReleaseDloc (IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
 
OSSTATUS UDFStoreDloc (IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN uint32 Lba)
 
OSSTATUS UDFRemoveDloc (IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
 
OSSTATUS UDFUnlinkDloc (IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
 
void UDFFreeDloc (IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
 
void UDFRelocateDloc (IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc, IN uint32 NewLba)
 
void UDFReleaseDlocList (IN PVCB Vcb)
 
PUDF_FILE_INFO UDFLocateParallelFI (PUDF_FILE_INFO di, uint_di i, PUDF_FILE_INFO fi)
 
PUDF_FILE_INFO UDFLocateAnyParallelFI (PUDF_FILE_INFO fi)
 
void UDFInsertLinkedFile (PUDF_FILE_INFO fi, PUDF_FILE_INFO fi2)
 

Macro Definition Documentation

◆ DirPrint

#define DirPrint (   x)    UDFPrint(x)

Definition at line 34 of file dirtree.cpp.

◆ MEM_USDIRHASH_TAG

#define MEM_USDIRHASH_TAG   "USDirHash"

Definition at line 30 of file dirtree.cpp.

◆ UDF_BUG_CHECK_ID

#define UDF_BUG_CHECK_ID   UDF_FILE_UDF_INFO_DIR

Definition at line 28 of file dirtree.cpp.

◆ UDF_DUMP_DIRTREE

#define UDF_DUMP_DIRTREE

Definition at line 32 of file dirtree.cpp.

◆ UDFFindNextFI

#define UDFFindNextFI (   a,
  b,
  c 
)    0

Definition at line 500 of file dirtree.cpp.

Function Documentation

◆ UDFAcquireDloc()

OSSTATUS UDFAcquireDloc ( IN PVCB  Vcb,
IN PUDF_DATALOC_INFO  Dloc 
)

Definition at line 1206 of file dirtree.cpp.

1210{
1211 UDFAcquireResourceExclusive(&(Vcb->DlocResource2),TRUE);
1212 if(Dloc->FE_Flags & UDF_FE_FLAG_UNDER_INIT) {
1213 UDFReleaseResource(&(Vcb->DlocResource2));
1214 return STATUS_SHARING_PAUSED;
1215 }
1216 Dloc->FE_Flags |= UDF_FE_FLAG_UNDER_INIT;
1217 UDFReleaseResource(&(Vcb->DlocResource2));
1218 return STATUS_SUCCESS;
1219} // end UDFAcquireDloc()
#define TRUE
Definition: types.h:120
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
#define Vcb
Definition: cdprocs.h:1415
#define STATUS_SUCCESS
Definition: shellext.h:65
#define UDF_FE_FLAG_UNDER_INIT
Dloc is being initialized, don't touch it now.
Definition: udf_rel.h:335
#define STATUS_SHARING_PAUSED
Definition: udferr_usr.h:165

Referenced by UDFStoreDloc().

◆ UDFBuildHashEntry()

uint8 UDFBuildHashEntry ( IN PVCB  Vcb,
IN PUNICODE_STRING  Name,
OUT PHASH_ENTRY  hashes,
IN uint8  Mask 
)

Definition at line 429 of file dirtree.cpp.

435{
436 UNICODE_STRING UName;
437 WCHAR ShortNameBuffer[13];
438 uint8 RetFlags = 0;
439
440 if(!Name->Buffer) return 0;
441
442 if(Mask & HASH_POSIX)
443 hashes->hPosix = crc32((uint8*)(Name->Buffer), Name->Length);
444
445 if(Mask & HASH_ULFN) {
446/* if(OS_SUCCESS(MyInitUnicodeString(&UName, L"")) &&
447 OS_SUCCESS(MyAppendUnicodeStringToStringTag(&UName, Name, MEM_USDIRHASH_TAG))) {*/
448 if(OS_SUCCESS(MyCloneUnicodeString(&UName, Name))) {
449 RtlUpcaseUnicodeString(&UName, &UName, FALSE);
450 /* if(!RtlCompareUnicodeString(Name, &UName, FALSE)) {
451 RetFlags |= UDF_FI_FLAG_LFN;
452 }*/
453 hashes->hLfn = crc32((uint8*)(UName.Buffer), UName.Length);
454 } else {
455 BrutePoint();
456 }
457 MyFreePool__(UName.Buffer);
458 }
459
460 if(Mask & HASH_DOS) {
461 UName.Buffer = (PWCHAR)(&ShortNameBuffer);
462 UName.MaximumLength = 13*sizeof(WCHAR);
463 UDFDOSName(Vcb, &UName, Name, (Mask & HASH_KEEP_NAME) ? TRUE : FALSE);
464 if(!RtlCompareUnicodeString(Name, &UName, TRUE)) {
465 RetFlags |= UDF_FI_FLAG_DOS;
466 }
467 hashes->hDos = crc32((uint8*)(UName.Buffer), UName.Length);
468 }
469 return RetFlags;
470} // UDFBuildHashEntry()
NTSTATUS MyCloneUnicodeString(IN PUNICODE_STRING Str1, IN PUNICODE_STRING Str2)
unsigned char uint8
Definition: types.h:28
#define FALSE
Definition: types.h:117
#define crc32(crc, buf, len)
Definition: inflate.c:1081
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
#define BrutePoint()
Definition: env_spec_w32.h:504
unsigned int Mask
Definition: fpcontrol.c:82
#define MyFreePool__(addr)
Definition: mem_tools.h:152
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWCHAR
Definition: typedefs.h:56
void __fastcall UDFDOSName(IN PVCB Vcb, IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)
Definition: udf_info.cpp:427
#define HASH_ULFN
Definition: udf_info.h:76
#define HASH_KEEP_NAME
Definition: udf_info.h:79
#define HASH_DOS
Definition: udf_info.h:77
#define HASH_POSIX
Definition: udf_info.h:75
#define UDF_FI_FLAG_DOS
Definition: udf_rel.h:225
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by UDFBlankMount(), UDFCreateFile__(), UDFFindFile(), UDFIndexDirectory(), UDFQueryDirectory(), and UDFRenameMoveFile__().

◆ UDFDirIndexAlloc()

PDIR_INDEX_HDR UDFDirIndexAlloc ( IN uint_di  i)

Definition at line 43 of file dirtree.cpp.

46{
47 uint_di j,k;
48 PDIR_INDEX_HDR hDirNdx;
49 PDIR_INDEX_ITEM* FrameList;
50
51 if(!i)
52 return NULL;
53#ifdef UDF_LIMIT_DIR_SIZE
55 return NULL;
56#endif //UDF_LIMIT_DIR_SIZE
57
60
62 if(!hDirNdx) return NULL;
63 RtlZeroMemory(hDirNdx, sizeof(DIR_INDEX_HDR));
64
65 FrameList = (PDIR_INDEX_ITEM*)(hDirNdx+1);
66 for(k=0; k<j; k++, FrameList++) {
68 if(!(*FrameList)) {
69free_hdi:
70 // item pointet by FrameList is NULL, it could not be allocated
71 while(k) {
72 k--;
73 FrameList--;
74 MyFreePool__(*FrameList);
75 }
76 MyFreePool__(hDirNdx);
77 return NULL;
78 }
80 }
81 if(i) {
83 if(!(*FrameList))
84 goto free_hdi;
85 RtlZeroMemory((*FrameList), i*sizeof(DIR_INDEX_ITEM));
86 }
87
88 hDirNdx->FrameCount = j+(i!=0);
90
91 return hDirNdx;
92} // UDFDirIndexAlloc()
#define NULL
Definition: types.h:112
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
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 MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
int k
Definition: mpi.c:3369
uint_di FrameCount
Definition: udf_rel.h:137
uint_di LastFrameCount
Definition: udf_rel.h:138
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define UDF_DIR_INDEX_FRAME_SH
Definition: udf_info.h:1084
#define AlignDirIndex(n)
Definition: udf_info.h:1093
#define UDF_DIR_INDEX_FRAME
Definition: udf_info.h:1089
struct _DIR_INDEX_HDR * PDIR_INDEX_HDR
#define UDF_DIR_INDEX_MT
Definition: udf_rel.h:125
#define MEM_DIR_HDR_TAG
Definition: udf_rel.h:479
uint32 uint_di
Definition: udf_rel.h:29
struct _DIR_INDEX_ITEM * PDIR_INDEX_ITEM
#define MEM_DIR_NDX_TAG
Definition: udf_rel.h:480
struct _DIR_INDEX_ITEM DIR_INDEX_ITEM

Referenced by UDFBlankMount(), and UDFIndexDirectory().

◆ UDFDirIndexFree()

void UDFDirIndexFree ( PDIR_INDEX_HDR  hDirNdx)

Definition at line 98 of file dirtree.cpp.

101{
102 uint32 k;
103 PDIR_INDEX_ITEM* FrameList;
104
105 FrameList = (PDIR_INDEX_ITEM*)(hDirNdx+1);
106 if(!hDirNdx) return;
107 for(k=0; k<hDirNdx->FrameCount; k++, FrameList++) {
108 if(*FrameList) MyFreePool__(*FrameList);
109 }
110 MyFreePool__(hDirNdx);
111} // UDFDirIndexFree();
unsigned int uint32
Definition: types.h:32

Referenced by UDFCleanUpFile__(), and UDFIndexDirectory().

◆ UDFDirIndexGetFrame()

PDIR_INDEX_ITEM UDFDirIndexGetFrame ( IN PDIR_INDEX_HDR  hDirNdx,
IN uint32  Frame,
OUT uint32 FrameLen,
OUT uint_di Index,
IN uint_di  Rel 
)

Definition at line 316 of file dirtree.cpp.

323{
324 if(Frame >= hDirNdx->FrameCount)
325 return NULL;
326 if(Index) {
327#ifdef UDF_LIMIT_DIR_SIZE
328 (*Index) = Rel;
329// if(FrameLen)
330 (*FrameLen) = hDirNdx->LastFrameCount;
331#else //UDF_LIMIT_DIR_SIZE
332 (*Index) = Frame*UDF_DIR_INDEX_FRAME+Rel;
333// if(FrameLen)
334 (*FrameLen) = (Frame < (hDirNdx->FrameCount-1)) ? UDF_DIR_INDEX_FRAME :
335 hDirNdx->LastFrameCount;
336#endif //UDF_LIMIT_DIR_SIZE
337 }
338 return ((PDIR_INDEX_ITEM*)(hDirNdx+1))[Frame]+Rel;
339} // end UDFDirIndexGetFrame()
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by UDFDirIndexInitScan(), and UDFDirIndexScan().

◆ UDFDirIndexGrow()

OSSTATUS UDFDirIndexGrow ( IN PDIR_INDEX_HDR _hDirNdx,
IN uint_di  d 
)

Definition at line 117 of file dirtree.cpp.

121{
122 uint_di j,k;
123 PDIR_INDEX_HDR hDirNdx = *_hDirNdx;
124 PDIR_INDEX_ITEM* FrameList;
125
128
129 j = hDirNdx->LastFrameCount+d;
130
131 if(j > UDF_DIR_INDEX_FRAME) {
132#ifndef UDF_LIMIT_DIR_SIZE // release
133 // Grow header
134 k = hDirNdx->FrameCount;
135 if(!MyReallocPool__((int8*)hDirNdx, sizeof(DIR_INDEX_HDR) + k*sizeof(PDIR_INDEX_ITEM),
136 (int8**)(&hDirNdx), sizeof(DIR_INDEX_HDR) + (k+1)*sizeof(PDIR_INDEX_ITEM) ) )
138 FrameList = (PDIR_INDEX_ITEM*)(hDirNdx+1);
139 // Grow last frame
140 if(!MyReallocPool__((int8*)(FrameList[k-1]), AlignDirIndex(hDirNdx->LastFrameCount)*sizeof(DIR_INDEX_ITEM),
141 (int8**)(&(FrameList[k-1])), UDF_DIR_INDEX_FRAME*sizeof(DIR_INDEX_ITEM) ) )
143 RtlZeroMemory(&(FrameList[k-1][hDirNdx->LastFrameCount]),
144 (UDF_DIR_INDEX_FRAME-hDirNdx->LastFrameCount)*sizeof(DIR_INDEX_ITEM));
145 hDirNdx->LastFrameCount = UDF_DIR_INDEX_FRAME;
146 // Allocate new frame
148 if(!FrameList[k])
150 hDirNdx->FrameCount++;
151 RtlZeroMemory(FrameList[k], (j-UDF_DIR_INDEX_FRAME)*sizeof(DIR_INDEX_ITEM));
152 hDirNdx->LastFrameCount = j-UDF_DIR_INDEX_FRAME;
153 (*_hDirNdx) = hDirNdx;
154#else // UDF_LIMIT_DIR_SIZE
156#endif // UDF_LIMIT_DIR_SIZE
157 } else {
158 k = hDirNdx->FrameCount;
159 FrameList = (PDIR_INDEX_ITEM*)(hDirNdx+1);
160 if(!MyReallocPool__((int8*)(FrameList[k-1]), AlignDirIndex(hDirNdx->LastFrameCount)*sizeof(DIR_INDEX_ITEM),
161 (int8**)(&(FrameList[k-1])), AlignDirIndex(j)*sizeof(DIR_INDEX_ITEM) ) )
163 RtlZeroMemory(&(FrameList[k-1][hDirNdx->LastFrameCount]),
164 (j-hDirNdx->LastFrameCount)*sizeof(DIR_INDEX_ITEM));
165 hDirNdx->LastFrameCount = j;
166 }
167 return STATUS_SUCCESS;
168} // end UDFDirIndexGrow()
char int8
Definition: platform.h:10
#define d
Definition: ke_i.h:81
ULONG MyReallocPool__(PCHAR addr, ULONG len, PCHAR *pnewaddr, ULONG newlen)
Definition: mem_tools.h:230
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by UDFCreateFile__().

◆ UDFDirIndexInitScan()

BOOLEAN UDFDirIndexInitScan ( IN PUDF_FILE_INFO  DirInfo,
OUT PUDF_DIR_SCAN_CONTEXT  Context,
IN uint_di  Index 
)

Definition at line 347 of file dirtree.cpp.

352{
353 Context->DirInfo = DirInfo;
354 Context->hDirNdx = DirInfo->Dloc->DirIndex;
355 if( (Context->frame = (Index >> UDF_DIR_INDEX_FRAME_SH)) >=
356 Context->hDirNdx->FrameCount) {
357 return FALSE;
358 }
359 if( (Context->j = Index & (UDF_DIR_INDEX_FRAME-1)) >=
360 ((Context->frame < (Context->hDirNdx->FrameCount-1))
361 ?
362 UDF_DIR_INDEX_FRAME : Context->hDirNdx->LastFrameCount) ) {
363 return FALSE;
364 }
365 Context->DirNdx = UDFDirIndexGetFrame(Context->hDirNdx,
366 Context->frame,
367 &(Context->d),
368 &(Context->i),
369 Context->j);
370 Context->i--;
371 Context->j--;
372 Context->DirNdx--;
373
374 return TRUE;
375} // end UDFDirIndexInitScan()
PDIR_INDEX_ITEM UDFDirIndexGetFrame(IN PDIR_INDEX_HDR hDirNdx, IN uint32 Frame, OUT uint32 *FrameLen, OUT uint_di *Index, IN uint_di Rel)
Definition: dirtree.cpp:316

Referenced by UDFBuildTreeItemsList(), UDFCreateFile__(), UDFFindFile(), UDFFlushADirectory(), UDFMarkStreamsForDeletion(), UDFPackDirectory__(), and UDFReTagDirectory().

◆ UDFDirIndexScan()

PDIR_INDEX_ITEM UDFDirIndexScan ( PUDF_DIR_SCAN_CONTEXT  Context,
PUDF_FILE_INFO _FileInfo 
)

Definition at line 378 of file dirtree.cpp.

382{
384 PUDF_FILE_INFO ParFileInfo;
385
386 Context->i++;
387 Context->j++;
388 Context->DirNdx++;
389
390 if(Context->j >= Context->d) {
391 Context->j=0;
392 Context->frame++;
393 Context->DirNdx = UDFDirIndexGetFrame(Context->hDirNdx,
394 Context->frame,
395 &(Context->d),
396 &(Context->i),
397 Context->j);
398 }
399 if(!Context->DirNdx) {
400 if(_FileInfo)
401 (*_FileInfo) = NULL;
402 return NULL;
403 }
404
405 if(_FileInfo) {
406 if((FileInfo = Context->DirNdx->FileInfo)) {
407 if(FileInfo->ParentFile != Context->DirInfo) {
408 ParFileInfo = UDFLocateParallelFI(Context->DirInfo,
409 Context->i,
410 FileInfo);
411#ifdef UDF_DBG
412 if(ParFileInfo->ParentFile != Context->DirInfo) {
413 BrutePoint();
414 }
415#endif // UDF_DBG
416 FileInfo = ParFileInfo;
417 }
418 }
419 (*_FileInfo) = FileInfo;
420 }
421
422 return (Context->DirNdx);
423} // end UDFDirIndexScan()
PUDF_FILE_INFO UDFLocateParallelFI(PUDF_FILE_INFO di, uint_di i, PUDF_FILE_INFO fi)
Definition: dirtree.cpp:1417
struct _UDF_FILE_INFO * ParentFile
Definition: udf_rel.h:381

Referenced by UDFBuildTreeItemsList(), UDFCreateFile__(), UDFFindFile(), UDFFlushADirectory(), UDFMarkStreamsForDeletion(), UDFPackDirectory__(), and UDFReTagDirectory().

◆ UDFDirIndexTrunc()

OSSTATUS UDFDirIndexTrunc ( IN PDIR_INDEX_HDR _hDirNdx,
IN uint_di  d 
)

Definition at line 174 of file dirtree.cpp.

178{
179 uint_di j,k;
180
181 if(d > UDF_DIR_INDEX_FRAME) {
183 while(d) {
185 if(!OS_SUCCESS(status = UDFDirIndexTrunc(_hDirNdx, k))) {
186 return status;
187 }
188 d -= k;
189 }
190 return STATUS_SUCCESS;
191 }
192
193 PDIR_INDEX_HDR hDirNdx = *_hDirNdx;
194 PDIR_INDEX_ITEM* FrameList;
195
197 FrameList = (PDIR_INDEX_ITEM*)(hDirNdx+1);
198 k = hDirNdx->FrameCount-1;
199
200 if(j <= UDF_DIR_INDEX_FRAME) {
201 // free last frame
202 if(!k && (j < 2)) {
203 // someone tries to trunc. residual entries...
205 }
206 MyFreePool__(FrameList[k]);
207 FrameList[k] = NULL;
209 hDirNdx->FrameCount--;
210 // Truncate new last frame
211 if(!MyReallocPool__((int8*)(FrameList[k-1]), UDF_DIR_INDEX_FRAME*sizeof(DIR_INDEX_ITEM),
212 (int8**)(&(FrameList[k-1])), AlignDirIndex(j)*sizeof(DIR_INDEX_ITEM) ) )
214 hDirNdx->LastFrameCount = j;
215 // Truncate header
216 if(!MyReallocPool__((int8*)hDirNdx, sizeof(DIR_INDEX_HDR) + (k+1)*sizeof(PDIR_INDEX_ITEM),
217 (int8**)(&hDirNdx), sizeof(DIR_INDEX_HDR) + k*sizeof(PDIR_INDEX_ITEM) ) )
219
220 (*_hDirNdx) = hDirNdx;
221
222 } else {
223
225 if(!k && (j < 2)) {
226 // someone tries to trunc. residual entries...
228 }
229
230 if(!MyReallocPool__((int8*)(FrameList[k]), AlignDirIndex(hDirNdx->LastFrameCount)*sizeof(DIR_INDEX_ITEM),
231 (int8**)(&(FrameList[k])), AlignDirIndex(j)*sizeof(DIR_INDEX_ITEM) ) )
233 hDirNdx->LastFrameCount = j;
234 }
235 return STATUS_SUCCESS;
236} // end UDFDirIndexTrunc()
OSSTATUS UDFDirIndexTrunc(IN PDIR_INDEX_HDR *_hDirNdx, IN uint_di d)
Definition: dirtree.cpp:174
#define OSSTATUS
Definition: env_spec_w32.h:57
Definition: ps.c:97

Referenced by UDFDirIndexTrunc(), and UDFPackDirectory__().

◆ UDFFindDloc()

LONG UDFFindDloc ( IN PVCB  Vcb,
IN uint32  Lba 
)

Definition at line 1127 of file dirtree.cpp.

1131{
1132 PUDF_DATALOC_INDEX DlocList;
1133 uint32 l;
1134
1135 if(!(DlocList = Vcb->DlocList) || !Lba) return (-1);
1136 // scan FE location cache
1137 l = Vcb->DlocCount;
1138 for(uint32 i=0; i<l; i++, DlocList++) {
1139 if(DlocList->Lba == Lba)
1140 return i;
1141 }
1142 return (-1);
1143} // end UDFFindDloc()
r l[0]
Definition: byte_order.h:168

Referenced by UDFBuildFileEntry(), and UDFStoreDloc().

◆ UDFFindDlocInMem()

LONG UDFFindDlocInMem ( IN PVCB  Vcb,
IN PUDF_DATALOC_INFO  Dloc 
)

Definition at line 1149 of file dirtree.cpp.

1153{
1154 PUDF_DATALOC_INDEX DlocList;
1155 uint32 l;
1156
1157 if(!(DlocList = Vcb->DlocList) || !Dloc) return (-1);
1158 // scan FE location cache
1159 l = Vcb->DlocCount;
1160 for(uint32 i=0; i<l; i++, DlocList++) {
1161 if(DlocList->Dloc == Dloc)
1162 return i;
1163 }
1164 return (-1);
1165} // end UDFFindDlocInMem()
PUDF_DATALOC_INFO Dloc
Definition: udf_rel.h:437

Referenced by UDFFreeDloc(), UDFRelocateDloc(), UDFRemoveDloc(), and UDFUnlinkDloc().

◆ UDFFindFile()

OSSTATUS UDFFindFile ( IN PVCB  Vcb,
IN BOOLEAN  IgnoreCase,
IN BOOLEAN  NotDeleted,
IN PUNICODE_STRING  Name,
IN PUDF_FILE_INFO  DirInfo,
IN OUT uint_di Index 
)

Definition at line 982 of file dirtree.cpp.

990{
991// PDIR_INDEX_HDR hDirIndex = DirInfo->Dloc->DirIndex;
993 WCHAR ShortNameBuffer[13];
994 PDIR_INDEX_ITEM DirNdx;
995 UDF_DIR_SCAN_CONTEXT ScanContext;
996 uint_di j=(-1), k=(-1);
997 HASH_ENTRY hashes;
998 BOOLEAN CanBe8d3;
999
1001
1002 if((CanBe8d3 = UDFCanNameBeA8dot3(Name))) {
1003 ShortName.MaximumLength = 13 * sizeof(WCHAR);
1004 ShortName.Buffer = (PWCHAR)&ShortNameBuffer;
1005 }
1006
1007 if(!UDFDirIndexInitScan(DirInfo, &ScanContext, (*Index)))
1009
1010 if(!IgnoreCase && !CanBe8d3) {
1011 // perform case sensetive sequential directory scan
1012
1013 while((DirNdx = UDFDirIndexScan(&ScanContext, NULL))) {
1014 if( (DirNdx->hashes.hPosix == hashes.hPosix) &&
1015 DirNdx->FName.Buffer &&
1016 (!RtlCompareUnicodeString(&(DirNdx->FName), Name, FALSE)) &&
1017 ( (!UDFIsDeleted(DirNdx)) || (!NotDeleted) ) ) {
1018 (*Index) = ScanContext.i;
1019 return STATUS_SUCCESS;
1020 }
1021 }
1023 }
1024
1025 if(hashes.hPosix == hashes.hLfn) {
1026
1027 while((DirNdx = UDFDirIndexScan(&ScanContext, NULL))) {
1028 if(!DirNdx->FName.Buffer ||
1029 (NotDeleted && UDFIsDeleted(DirNdx)) )
1030 continue;
1031 if( (DirNdx->hashes.hLfn == hashes.hLfn) &&
1032 (!RtlCompareUnicodeString(&(DirNdx->FName), Name, IgnoreCase)) ) {
1033 (*Index) = ScanContext.i;
1034 return STATUS_SUCCESS;
1035 } else
1036 if( CanBe8d3 &&
1037 !(DirNdx->FI_Flags & UDF_FI_FLAG_DOS) &&
1038 (DirNdx->hashes.hDos == hashes.hLfn) &&
1039 (k == (uint_di)(-1))) {
1040 UDFDOSName(Vcb, &ShortName, &(DirNdx->FName), ScanContext.i < 2) ;
1042 k = ScanContext.i;
1043 }
1044 }
1045
1046 } else {
1047
1048 while((DirNdx = UDFDirIndexScan(&ScanContext, NULL))) {
1049 // perform sequential directory scan
1050 if(!DirNdx->FName.Buffer ||
1051 (NotDeleted && UDFIsDeleted(DirNdx)) )
1052 continue;
1053 if( (DirNdx->hashes.hPosix == hashes.hPosix) &&
1054 (!RtlCompareUnicodeString(&(DirNdx->FName), Name, FALSE)) ) {
1055 (*Index) = ScanContext.i;
1056 return STATUS_SUCCESS;
1057 } else
1058 if( (DirNdx->hashes.hLfn == hashes.hLfn) &&
1059 (j == (uint_di)(-1)) &&
1060 (!RtlCompareUnicodeString(&(DirNdx->FName), Name, IgnoreCase)) ) {
1061 j = ScanContext.i;
1062 } else
1063 if( CanBe8d3 &&
1064 !(DirNdx->FI_Flags & UDF_FI_FLAG_DOS) &&
1065 (DirNdx->hashes.hDos == hashes.hLfn) &&
1066 (k == (uint_di)(-1))) {
1067 UDFDOSName(Vcb, &ShortName, &(DirNdx->FName), ScanContext.i < 2 );
1069 k = ScanContext.i;
1070 }
1071 }
1072 }
1073 }
1074
1075 if(j != (uint_di)(-1)) {
1076 (*Index) = j;
1077 return STATUS_SUCCESS;
1078 } else
1079 if(k != (uint_di)(-1)) {
1080 (*Index) = k;
1081 return STATUS_SUCCESS;
1082 }
1083
1085
1086} // end UDFFindFile()
unsigned char BOOLEAN
#define IgnoreCase
Definition: cdprocs.h:461
PDIR_INDEX_ITEM UDFDirIndexScan(PUDF_DIR_SCAN_CONTEXT Context, PUDF_FILE_INFO *_FileInfo)
Definition: dirtree.cpp:378
uint8 UDFBuildHashEntry(IN PVCB Vcb, IN PUNICODE_STRING Name, OUT PHASH_ENTRY hashes, IN uint8 Mask)
Definition: dirtree.cpp:429
BOOLEAN UDFDirIndexInitScan(IN PUDF_FILE_INFO DirInfo, OUT PUDF_DIR_SCAN_CONTEXT Context, IN uint_di Index)
Definition: dirtree.cpp:347
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
Definition: fatprocs.h:1307
BOOLEAN __fastcall UDFCanNameBeA8dot3(IN PUNICODE_STRING Name)
Definition: namesup.cpp:266
UNICODE_STRING FName
Definition: udf_rel.h:173
uint8 FI_Flags
Definition: udf_rel.h:199
HASH_ENTRY hashes
Definition: udf_rel.h:206
Definition: udf_rel.h:128
uint32 hLfn
Definition: udf_rel.h:130
uint32 hDos
Definition: udf_rel.h:129
uint32 hPosix
Definition: udf_rel.h:131
#define UDFIsDeleted(DirNdx)
Definition: udf_info.h:788
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by UDFCreateFile__(), UDFFindFile__(), UDFHardLinkFile__(), UDFOpenFile__(), and UDFRenameMoveFile__().

◆ UDFFindFreeDloc()

LONG UDFFindFreeDloc ( IN PVCB  Vcb,
IN uint32  Lba 
)

Definition at line 1171 of file dirtree.cpp.

1175{
1176 PUDF_DATALOC_INDEX DlocList;
1177 uint32 l;
1178
1179 if(!Vcb->DlocList) {
1180 // init FE location cache
1182 return (-1);
1184 Vcb->DlocCount = DLOC_LIST_GRANULARITY;
1185 }
1186 // scan for free entry
1187 DlocList = Vcb->DlocList;
1188 l = Vcb->DlocCount;
1189 for(uint32 i=0; i<l; i++, DlocList++) {
1190 if(!DlocList->Dloc)
1191 return i;
1192 }
1193 // alloc some free entries
1194 if(!MyReallocPool__((int8*)(Vcb->DlocList), Vcb->DlocCount*sizeof(UDF_DATALOC_INDEX),
1195 (int8**)&(Vcb->DlocList), (Vcb->DlocCount+DLOC_LIST_GRANULARITY)*sizeof(UDF_DATALOC_INDEX))) {
1196 return (-1);
1197 }
1198 RtlZeroMemory(&(Vcb->DlocList[Vcb->DlocCount]), DLOC_LIST_GRANULARITY*sizeof(UDF_DATALOC_INDEX));
1199 Vcb->DlocCount += DLOC_LIST_GRANULARITY;
1200 return (Vcb->DlocCount - DLOC_LIST_GRANULARITY);
1201} // end UDFFindFreeDloc()
#define NonPagedPool
Definition: env_spec_w32.h:307
#define DLOC_LIST_GRANULARITY
Definition: udf_common.h:654
#define MEM_DLOC_NDX_TAG
Definition: udf_rel.h:481

Referenced by UDFStoreDloc().

◆ UDFFreeDloc()

void UDFFreeDloc ( IN PVCB  Vcb,
IN PUDF_DATALOC_INFO  Dloc 
)

Definition at line 1353 of file dirtree.cpp.

1357{
1358 LONG i;
1359
1360 UDFAcquireResourceExclusive(&(Vcb->DlocResource),TRUE);
1361
1362 if((i = UDFFindDlocInMem(Vcb, Dloc)) != (-1)) {
1363 ASSERT(Vcb->DlocList);
1364 RtlZeroMemory(&(Vcb->DlocList[i]), sizeof(UDF_DATALOC_INDEX));
1365 }
1366 UDFReleaseResource(&(Vcb->DlocResource));
1367 MyFreePool__(Dloc);
1368} // end UDFFreeDloc()
LONG UDFFindDlocInMem(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1149
#define ASSERT(a)
Definition: mode.c:44
long LONG
Definition: pedump.c:60

Referenced by UDFCleanUpFile__().

◆ UDFGetDirIndexByFileInfo()

PDIR_INDEX_HDR UDFGetDirIndexByFileInfo ( IN PUDF_FILE_INFO  FileInfo)

Definition at line 1092 of file dirtree.cpp.

1095{
1097
1098 if(!FileInfo) {
1099 BrutePoint();
1100 return NULL;
1101 }
1102 if (FileInfo->ParentFile) {
1103 ValidateFileInfo(FileInfo->ParentFile);
1104
1106 return NULL;
1107 if(FileInfo->ParentFile->Dloc)
1108 return FileInfo->ParentFile->Dloc->DirIndex;
1109 return NULL;
1110 }
1111 if(FileInfo->Dloc)
1112 return FileInfo->Dloc->DirIndex;
1113 return NULL;
1114}
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
#define UDFIsAStreamDir(FI)
Definition: udf_info.h:998

Referenced by UDFCloseFile__(), UDFCommonCleanup(), UDFCommonClose(), UDFCommonCreate(), UDFCompleteMount(), UDFCreateFile__(), UDFDoesOSAllowFilePretendDeleted__(), UDFDoesOSAllowFileToBeTargetForRename__(), UDFFirstOpenFile(), UDFFlushAFile(), UDFFlushFE(), UDFFlushFile__(), UDFGetAltNameInformation(), UDFGetBasicInformation(), UDFGetFileSizeFromDirNdx(), UDFGetNetworkInformation(), UDFPretendFileDeleted__(), UDFRecordDirectory__(), UDFSetBasicInformation(), UDFSetEOF(), UDFSetFileSizeInDirNdx(), and UDFSetFileXTime().

◆ UDFIndexDirectory()

OSSTATUS UDFIndexDirectory ( IN PVCB  Vcb,
IN OUT PUDF_FILE_INFO  FileInfo 
)

Definition at line 507 of file dirtree.cpp.

511{
512 PDIR_INDEX_HDR hDirNdx;
513 PDIR_INDEX_ITEM DirNdx;
514 PFILE_IDENT_DESC FileId;
515 uint32 Offset = 0;
516// uint32 prevOffset = 0;
517 uint_di Count = 0;
519 int8* buff;
520 PEXTENT_INFO ExtInfo; // Extent array for directory
521 uint16 PartNum;
523 uint16 valueCRC;
524
527
528 ExtInfo = &(FileInfo->Dloc->DataLoc);
529 FileInfo->Dloc->DirIndex = NULL;
530 UDFPrint(("UDF: scaning directory\n"));
531 // allocate buffer for the whole directory
532 ASSERT((uint32)(ExtInfo->Length));
533 if(!ExtInfo->Length)
536 if(!buff)
538
540
541 // read FileIdents
542 status = UDFReadExtent(Vcb, ExtInfo, 0, (uint32)(ExtInfo->Length), FALSE, buff, &ReadBytes);
543 if(!OS_SUCCESS(status)) {
545 return status;
546 }
547 // scan Dir to get entry counter
548 FileId = (PFILE_IDENT_DESC)buff;
549 DirPrint((" ExtInfo->Length %x\n", ExtInfo->Length));
550// prevOffset = 0;
552 DirPrint((" Offset %x\n", Offset));
553 if(!FileId->descTag.tagIdent) {
554 DirPrint((" term item\n"));
555 break;
556 }
557 if(FileId->descTag.tagIdent != TID_FILE_IDENT_DESC) {
558 DirPrint((" Inv. tag %x\n", FileId->descTag.tagIdent));
559 Offset = UDFFindNextFI(buff, prevOffset, (ULONG)(ExtInfo->Length));
560 if(!Offset) {
561 DirPrint((" can't find next\n"));
562 break;
563 } else {
564 DirPrint((" found next offs %x\n", Offset));
565 FileId = (PFILE_IDENT_DESC)((buff)+Offset);
566 }
567 }
568 if(((ULONG)Offset & (Vcb->LBlockSize-1)) > (Vcb->LBlockSize-sizeof(FILE_IDENT_DESC))) {
569 DirPrint((" badly aligned\n", Offset));
570 if(Vcb->Modified) {
571 DirPrint((" queue repack request\n"));
572 FileInfo->Dloc->DirIndex->DelCount = Vcb->PackDirThreshold+1;
573 }
574 }
575// prevOffset = Offset;
576 Offset += (FileId->lengthFileIdent + FileId->lengthOfImpUse + sizeof(FILE_IDENT_DESC) + 3) & (~((uint32)3));
577 FileId = (PFILE_IDENT_DESC)((buff)+Offset);
578 Count++;
579 if(Offset+sizeof(FILE_IDENT_DESC) > ExtInfo->Length) {
580 if(Offset != ExtInfo->Length) {
581 UDFPrint((" Trash at the end of Dir\n"));
582 }
583// BrutePoint();
584 break;
585 }
586 }
587 DirPrint((" final Offset %x\n", Offset));
588 if(Offset > ExtInfo->Length) {
589 BrutePoint();
590 UDFPrint((" Unexpected end of Dir\n"));
593 }
594 // allocate buffer for directory index & zero it
595 DirPrint((" Count %x\n", Count));
596 hDirNdx = UDFDirIndexAlloc(Count+1);
597 if(!hDirNdx) {
600 }
601
602 Offset = Count = 0;
603 hDirNdx->DIFlags |= (ExtInfo->Offset ? UDF_DI_FLAG_INIT_IN_ICB : 0);
604 // add entry pointing to the directory itself
605 DirNdx = UDFDirIndex(hDirNdx,0);
606 ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
607 DirNdx->FileEntryLoc.partitionReferenceNum = PartNum =
608 (uint16)UDFGetPartNumByPhysLba(Vcb, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
609 ASSERT(PartNum != -1);
611 UDFPhysLbaToPart(Vcb, PartNum, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
612 if(DirNdx->FileEntryLoc.logicalBlockNum == (ULONG)-1) {
613 DirPrint((" err: FileEntryLoc=-1\n"));
615 UDFDirIndexFree(hDirNdx);
617 }
618 DirNdx->FileCharacteristics = (FileInfo->FileIdent) ?
619 FileInfo->FileIdent->fileCharacteristics :
621// DirNdx->Offset = 0;
622// DirNdx->Length = 0;
623 RtlInitUnicodeString(&DirNdx->FName, L".");
624 DirNdx->FileInfo = FileInfo;
626 DirNdx->FI_Flags |= UDFBuildHashEntry(Vcb, &(DirNdx->FName), &(DirNdx->hashes),
628 Count++;
629 FileId = (PFILE_IDENT_DESC)buff;
631// prevOffset = 0;
632 while((Offset<ExtInfo->Length) && FileId->descTag.tagIdent) {
633 // add new entry to index list
634 if(FileId->descTag.tagIdent != TID_FILE_IDENT_DESC) {
635 UDFPrint((" Invalid tagIdent %x (expected %x) offst %x\n", FileId->descTag.tagIdent, TID_FILE_IDENT_DESC, Offset));
636 DirPrint((" FileId: filen %x, iulen %x, charact %x\n",
637 FileId->lengthFileIdent, FileId->lengthOfImpUse, FileId->fileCharacteristics));
638 DirPrint((" loc: @%x\n", UDFExtentOffsetToLba(Vcb, ExtInfo->Mapping, Offset, NULL, NULL, NULL, NULL)));
639 KdDump(FileId, sizeof(FileId->descTag));
640 Offset = UDFFindNextFI(buff, prevOffset, (ULONG)(ExtInfo->Length));
641 if(!Offset) {
643 UDFDirIndexFree(hDirNdx);
645 } else {
646 DirPrint((" found next offs %x\n", Offset));
647 FileId = (PFILE_IDENT_DESC)((buff)+Offset);
648 }
649 }
650 DirNdx = UDFDirIndex(hDirNdx,Count);
651 // allocate buffer & fill it with decompressed unicode filename
652 if(FileId->fileCharacteristics & FILE_DELETED) {
653 DirPrint((" FILE_DELETED\n"));
654 hDirNdx->DelCount++;
655 }
656 DirPrint((" FileId: offs %x, filen %x, iulen %x\n", Offset, FileId->lengthFileIdent, FileId->lengthOfImpUse));
657 DirNdx->Length = (FileId->lengthFileIdent + FileId->lengthOfImpUse + sizeof(FILE_IDENT_DESC) + 3) & (~((uint32)3));
658 DirPrint((" DirNdx: Length %x, Charact %x\n", DirNdx->Length, FileId->fileCharacteristics));
659 if(FileId->fileCharacteristics & FILE_PARENT) {
660 DirPrint((" parent\n"));
661 // init 'parent' entry
662 // '..' points to Parent Object (if any),
663 // otherwise it points to the Dir itself
664 RtlInitUnicodeString(&DirNdx->FName, L"..");
665 DirNdx->FileInfo = (FileInfo->ParentFile) ?
666 FileInfo->ParentFile : FileInfo;
668 DirNdx->FI_Flags |= UDFBuildHashEntry(Vcb, &(DirNdx->FName), &(DirNdx->hashes), HASH_ALL | HASH_KEEP_NAME);
669 } else {
670 // init plain file/dir entry
671 ASSERT( (Offset+sizeof(FILE_IDENT_DESC)+FileId->lengthOfImpUse+FileId->lengthFileIdent) <=
672 ExtInfo->Length );
673 UDFDecompressUnicode(&(DirNdx->FName),
674 ((uint8*)(FileId+1)) + (FileId->lengthOfImpUse),
675 FileId->lengthFileIdent,
676 &valueCRC);
677 UDFNormalizeFileName(&(DirNdx->FName), valueCRC);
678 DirNdx->FI_Flags |= UDFBuildHashEntry(Vcb, &(DirNdx->FName), &(DirNdx->hashes), HASH_ALL);
679 }
681 ||
682 !DirNdx->FName.Buffer
683 ||
684 ((DirNdx->FName.Length >= sizeof(UDF_RESERVED_NAME_HDR)-sizeof(WCHAR)) &&
686 DirPrint((" metadata\n"));
688 }
689#if 0
690 UDFPrint(("%ws\n", DirNdx->FName.Buffer));
691#endif
692 DirPrint(("%ws\n", DirNdx->FName.Buffer));
693 // remember FileEntry location...
694 DirNdx->FileEntryLoc = FileId->icb.extLocation;
695 // ... and some file characteristics
697 DirNdx->Offset = Offset;
698#ifdef UDF_CHECK_DISK_ALLOCATION
699 if(!(FileId->fileCharacteristics & FILE_DELETED) &&
701 UDFGetFreeBit(((uint32*)(Vcb->FSBM_Bitmap)), UDFPartLbaToPhys(Vcb, &(DirNdx->FileEntryLoc)) )) {
702
703 AdPrint(("Ref to Discarded block %x\n",UDFPartLbaToPhys(Vcb, &(DirNdx->FileEntryLoc)) ));
704 BrutePoint();
706 } else
708 AdPrint(("Ref to Invalid block %x\n", UDFPartLbaToPhys(Vcb, &(DirNdx->FileEntryLoc)) ));
709 BrutePoint();
711 }
712#endif // UDF_CHECK_DISK_ALLOCATION
713// prevOffset = Offset;
714 Offset += DirNdx->Length;
715 FileId = (PFILE_IDENT_DESC)(((int8*)FileId)+DirNdx->Length);
716 Count++;
717 if(Offset+sizeof(FILE_IDENT_DESC) > ExtInfo->Length) {
718 if(Offset != ExtInfo->Length) {
719 UDFPrint((" Trash at the end of Dir (2)\n"));
720 }
721// BrutePoint();
722 break;
723 }
724 } // while()
725 // we needn't writing terminator 'cause the buffer is already zero-filled
727 if(Count < 2) {
728 UDFDirIndexFree(hDirNdx);
729 UDFPrint((" Directory too short\n"));
731 }
732 // store index
733 FileInfo->Dloc->DirIndex = hDirNdx;
734 return status;
735} // end UDFIndexDirectory()
VOID UDFNormalizeFileName(IN PUNICODE_STRING FName, IN USHORT valueCRC)
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
Definition: alloc.cpp:201
uint32 __fastcall UDFPartLbaToPhys(IN PVCB Vcb, IN lb_addr *Addr)
Definition: alloc.cpp:114
unsigned short uint16
Definition: types.h:30
#define UDFFindNextFI(a, b, c)
Definition: dirtree.cpp:500
#define DirPrint(x)
Definition: dirtree.cpp:34
void UDFDirIndexFree(PDIR_INDEX_HDR hDirNdx)
Definition: dirtree.cpp:98
PDIR_INDEX_HDR UDFDirIndexAlloc(IN uint_di i)
Definition: dirtree.cpp:43
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
#define FILE_PARENT
Definition: ecma_167.h:441
#define FILE_DIRECTORY
Definition: ecma_167.h:439
#define FILE_METADATA
Definition: ecma_167.h:442
struct _FILE_IDENT_DESC * PFILE_IDENT_DESC
struct _FILE_IDENT_DESC FILE_IDENT_DESC
#define FILE_DELETED
Definition: ecma_167.h:440
#define TID_FILE_IDENT_DESC
Definition: ecma_167.h:166
#define KdDump(a, b)
Definition: env_spec_w32.h:312
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define DbgFreePool
Definition: env_spec_w32.h:334
#define DbgAllocatePool
Definition: env_spec_w32.h:332
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
#define PagedPool
Definition: env_spec_w32.h:308
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)
Definition: extent.cpp:3021
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)
Definition: extent.cpp:28
static unsigned char buff[32768]
Definition: fatten.c:17
int Count
Definition: noreturn.cpp:7
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define UDF_RESERVED_NAME_HDR
Definition: osta_misc.h:343
ULONG DIFlags
Definition: udf_rel.h:142
uint_di DelCount
Definition: udf_rel.h:139
struct _UDF_FILE_INFO * FileInfo
Definition: udf_rel.h:204
uint32 Offset
Definition: udf_rel.h:161
lb_addr FileEntryLoc
Definition: udf_rel.h:178
uint8 FileCharacteristics
Definition: udf_rel.h:182
uint32 Length
Definition: udf_rel.h:168
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
int64 Length
Definition: udf_rel.h:67
UCHAR Flags
Definition: udf_rel.h:69
uint32 Offset
Definition: udf_rel.h:65
uint16 lengthOfImpUse
Definition: ecma_167.h:431
uint8 lengthFileIdent
Definition: ecma_167.h:429
uint8 fileCharacteristics
Definition: ecma_167.h:428
uint16 partitionReferenceNum
Definition: ecma_167.h:363
uint32 logicalBlockNum
Definition: ecma_167.h:362
lb_addr extLocation
Definition: ecma_167.h:375
uint16 tagIdent
Definition: ecma_167.h:139
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG
Definition: typedefs.h:59
void __fastcall UDFDecompressUnicode(IN OUT PUNICODE_STRING UName, IN uint8 *CS0, IN SIZE_T Length, OUT uint16 *valueCRC)
Definition: udf_info.cpp:170
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
#define UDFGetFreeBit(arr, bit)
Definition: udf_info.h:1199
#define HASH_ALL
Definition: udf_info.h:78
#define UDF_FI_FLAG_FI_INTERNAL
Given entry represents the file used for internal FS purposes & must be invisible.
Definition: udf_rel.h:221
#define UDF_DI_FLAG_INIT_IN_ICB
Definition: udf_rel.h:147
#define LBA_OUT_OF_EXTENT
Definition: udf_rel.h:426
#define UDF_FI_FLAG_KEEP_NAME
Definition: udf_rel.h:226
#define EXTENT_FLAG_ALLOC_SEQUENTIAL
Definition: udf_rel.h:77
#define STATUS_FILE_CORRUPT_ERROR
Definition: udferr_usr.h:168
#define UDFPrint(Args)
Definition: udffs.h:223

Referenced by UDFCleanUpFile__(), UDFOpenFile__(), UDFOpenRootFile__(), and UDFRecordDirectory__().

◆ UDFInsertLinkedFile()

void UDFInsertLinkedFile ( PUDF_FILE_INFO  fi,
PUDF_FILE_INFO  fi2 
)

Definition at line 1470 of file dirtree.cpp.

1474{
1475 fi->NextLinkedFile = fi2->NextLinkedFile;
1476 fi->PrevLinkedFile = fi2;
1477 fi->NextLinkedFile->PrevLinkedFile =
1478 fi->PrevLinkedFile->NextLinkedFile = fi;
1479 return;
1480} // end UDFInsertLinkedFile()
struct _UDF_FILE_INFO * PrevLinkedFile
Definition: udf_rel.h:409
struct _UDF_FILE_INFO * NextLinkedFile
Definition: udf_rel.h:408

Referenced by UDFHardLinkFile__(), UDFOpenFile__(), and UDFOpenStreamDir__().

◆ UDFLocateAnyParallelFI()

PUDF_FILE_INFO UDFLocateAnyParallelFI ( PUDF_FILE_INFO  fi)

Definition at line 1439 of file dirtree.cpp.

1442{
1443 if(!fi->ParentFile) {
1444 if(fi->NextLinkedFile == fi)
1445 return NULL;
1446 return fi->NextLinkedFile;
1447 }
1448 PUDF_FILE_INFO ParFileInfo = fi->NextLinkedFile;
1449 PUDF_DATALOC_INFO Dloc = fi->ParentFile->Dloc;
1450 uint_di i = fi->Index;
1451 BOOLEAN NotFound = TRUE;
1452 while((ParFileInfo != fi) &&
1453 (NotFound =
1454 ((ParFileInfo->Index != i) ||
1455 (ParFileInfo->ParentFile->Dloc != Dloc))) ) {
1456 ParFileInfo = ParFileInfo->NextLinkedFile;
1457 }
1458/* if(NotFound) {
1459 if((ParFileInfo->Index == i) &&
1460 (ParFileInfo->ParentFile->Dloc == Dloc))
1461 return ParFileInfo;
1462 return NULL;
1463 }
1464 return ParFileInfo;*/
1465 return NotFound ? NULL : ParFileInfo;
1466// BrutePoint();
1467} // end UDFLocateAnyParallelFI()
uint_di Index
Definition: udf_rel.h:392

Referenced by UDFCleanUpFile__().

◆ UDFLocateParallelFI()

PUDF_FILE_INFO UDFLocateParallelFI ( PUDF_FILE_INFO  di,
uint_di  i,
PUDF_FILE_INFO  fi 
)

Definition at line 1417 of file dirtree.cpp.

1422{
1423 PUDF_FILE_INFO ParFileInfo = fi->NextLinkedFile;
1424// PUDF_DATALOC_INFO Dloc = di->Dloc;
1425 while((ParFileInfo != fi) &&
1426 ((ParFileInfo->ParentFile != di) ||
1427 (ParFileInfo->Index != i)) ) {
1428 ParFileInfo = ParFileInfo->NextLinkedFile;
1429 }
1430 return ParFileInfo;
1431// BrutePoint();
1432} // end UDFLocateParallelFI()

Referenced by UDFDirIndexScan(), UDFOpenFile__(), and UDFOpenStreamDir__().

◆ UDFPackDirectory__()

OSSTATUS UDFPackDirectory__ ( IN PVCB  Vcb,
IN OUT PUDF_FILE_INFO  FileInfo 
)

Definition at line 743 of file dirtree.cpp.

747{
748#ifdef UDF_PACK_DIRS
749 uint32 d, LBS;
750 uint_di i, j;
751 uint32 IUl, FIl, l;
752 uint32 DataLocOffset;
753 uint32 Offset, curOffset;
754 int8* Buf;
757 int8* storedFI;
758 PUDF_FILE_INFO curFileInfo;
759 PDIR_INDEX_ITEM DirNdx, DirNdx2;
760 UDF_DIR_SCAN_CONTEXT ScanContext;
761 uint_di dc=0;
762 uint16 PartNum;
763#endif //UDF_PACK_DIRS
764
766 PDIR_INDEX_HDR hDirNdx = FileInfo->Dloc->DirIndex;
767 if(!hDirNdx) return STATUS_NOT_A_DIRECTORY;
768#ifndef UDF_PACK_DIRS
769 return STATUS_SUCCESS;
770#else // UDF_PACK_DIRS
771
772 // do not pack dirs on unchanged disks
773 if(!Vcb->Modified)
774 return STATUS_SUCCESS;
775 // start packing
776 LBS = Vcb->LBlockSize;
777 Buf = (int8*)DbgAllocatePool(PagedPool, LBS*2);
778 if(!Buf) return STATUS_INSUFFICIENT_RESOURCES;
779 // we shall never touch 1st entry 'cause it can't be deleted
780 Offset = UDFDirIndex(hDirNdx,2)->Offset;
781 DataLocOffset = FileInfo->Dloc->DataLoc.Offset;
782
783 i=j=2;
784
785 if(!UDFDirIndexInitScan(FileInfo, &ScanContext, i)) {
786 DbgFreePool(Buf);
787 return STATUS_SUCCESS;
788 }
789
790 ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
791 PartNum = (uint16)UDFGetPartNumByPhysLba(Vcb, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
792 ASSERT(PartNum != -1);
793
794 while((DirNdx = UDFDirIndexScan(&ScanContext, NULL))) {
795
796 if(UDFIsDeleted(DirNdx))
797 dc++;
798
799 if(!UDFIsDeleted(DirNdx) ||
800 DirNdx->FileInfo) {
801 // move down valid entry
802 status = UDFReadFile__(Vcb, FileInfo, curOffset = DirNdx->Offset,
803 l = DirNdx->Length, FALSE, Buf, &ReadBytes);
804 if(!OS_SUCCESS(status)) {
805 DbgFreePool(Buf);
806 return status;
807 }
808 // remove ImpUse field
809 IUl = ((PFILE_IDENT_DESC)Buf)->lengthOfImpUse;
810 curFileInfo = DirNdx->FileInfo;
811 // align next entry
812 if((d = LBS - ((curOffset + (l - IUl) + DataLocOffset) & (LBS-1)) ) < sizeof(FILE_IDENT_DESC)) {
813
814 // insufficient space at the end of last sector for
815 // next FileIdent's tag. fill it with ImpUse data
816
817 // generally, all data should be DWORD-aligned, but if it is not so
818 // this opearation will help us to avoid glitches
819 d = (d+3) & ~(3);
820 if(d != IUl) {
821 l = l + d - IUl;
822 FIl = ((PFILE_IDENT_DESC)Buf)->lengthFileIdent;
823 // copy filename to upper addr
824 RtlMoveMemory(Buf+sizeof(FILE_IDENT_DESC)+d,
825 Buf+sizeof(FILE_IDENT_DESC)+IUl, FIl);
826 RtlZeroMemory(Buf+sizeof(FILE_IDENT_DESC), d);
827 ((PFILE_IDENT_DESC)Buf)->lengthOfImpUse = (uint16)d;
828
829 if(curFileInfo && curFileInfo->FileIdent) {
830 // update stored FI if any
831 if(!MyReallocPool__((int8*)(curFileInfo->FileIdent), l,
832 (int8**)&(curFileInfo->FileIdent), (l+IUl-d) )) {
833 DbgFreePool(Buf);
835 }
836 storedFI = (int8*)(curFileInfo->FileIdent);
837 RtlMoveMemory(storedFI+sizeof(FILE_IDENT_DESC)+d,
838 storedFI+sizeof(FILE_IDENT_DESC)+IUl, FIl);
839 RtlZeroMemory(storedFI+sizeof(FILE_IDENT_DESC), d);
840 ((PFILE_IDENT_DESC)storedFI)->lengthOfImpUse = (uint16)d;
841 FileInfo->Dloc->FELoc.Modified = TRUE;
842 FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
843 }
844 }
845 } else {
846 d = 0;
847 }
848 // write modified to new addr
849 if((d != IUl) ||
850 (curOffset != Offset)) {
851
852 UDFSetUpTag(Vcb, (tag*)Buf, (uint16)l,
853 UDFPhysLbaToPart(Vcb, PartNum,
854 UDFExtentOffsetToLba(Vcb, FileInfo->Dloc->DataLoc.Mapping,
855 Offset, NULL, NULL, NULL, NULL)));
856
858 if(!OS_SUCCESS(status)) {
859 DbgFreePool(Buf);
860 return status;
861 }
862 }
863 DirNdx2 = UDFDirIndex(hDirNdx, j);
864 *DirNdx2 = *DirNdx;
865 DirNdx2->Offset = Offset;
866 DirNdx2->Length = l;
867 if(curFileInfo) {
868 curFileInfo->Index = j;
870 }
871 Offset += l;
872 j++;
873 }
874 }
875 // resize DirIndex
876 DbgFreePool(Buf);
877 if(dc) {
878 if(!OS_SUCCESS(status = UDFDirIndexTrunc(&(FileInfo->Dloc->DirIndex), dc))) {
879 return status;
880 }
881 }
882 // terminator is set by UDFDirIndexTrunc()
883 FileInfo->Dloc->DirIndex->DelCount = 0;
884 ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
885
886 // now Offset points to EOF. Let's truncate directory
888#endif // UDF_PACK_DIRS
889} // end UDFPackDirectory__()
static const WCHAR dc[]
PFILE_IDENT_DESC FileIdent
Definition: udf_rel.h:372
Definition: ecma_167.h:138
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
void UDFSetUpTag(IN PVCB Vcb, IN tag *Tag, IN uint16 DataLen, IN uint32 TagLoc)
Definition: udf_info.cpp:936
OSSTATUS UDFWriteFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
Definition: udf_info.cpp:1605
OSSTATUS UDFResizeFile__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
Definition: udf_info.cpp:3468
__inline OSSTATUS UDFReadFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, OUT int8 *Buffer, OUT PSIZE_T ReadBytes)
Definition: udf_info.h:666
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
#define UDF_FI_FLAG_FI_MODIFIED
FileIdent was modified & should be flushed.
Definition: udf_rel.h:217
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169

Referenced by UDFOpenFile__(), and UDFOpenRootFile__().

◆ UDFReleaseDloc()

OSSTATUS UDFReleaseDloc ( IN PVCB  Vcb,
IN PUDF_DATALOC_INFO  Dloc 
)

Definition at line 1224 of file dirtree.cpp.

1228{
1229 UDFAcquireResourceExclusive(&(Vcb->DlocResource2),TRUE);
1230 Dloc->FE_Flags &= ~UDF_FE_FLAG_UNDER_INIT;
1231 UDFReleaseResource(&(Vcb->DlocResource2));
1232 return STATUS_SUCCESS;
1233} // end UDFReleaseDloc()

Referenced by UDFCreateFile__(), UDFCreateRootFile__(), UDFOpenFile__(), UDFOpenRootFile__(), and UDFStoreDloc().

◆ UDFReleaseDlocList()

void UDFReleaseDlocList ( IN PVCB  Vcb)

Definition at line 1396 of file dirtree.cpp.

1399{
1400 if(!Vcb->DlocList) return;
1401 UDFAcquireResourceExclusive(&(Vcb->DlocResource),TRUE);
1402 for(uint32 i=0; i<Vcb->DlocCount; i++) {
1403 if(Vcb->DlocList[i].Dloc)
1404 MyFreePool__(Vcb->DlocList[i].Dloc);
1405 }
1406 MyFreePool__(Vcb->DlocList);
1407 Vcb->DlocList = NULL;
1408 Vcb->DlocCount = 0;
1409 UDFReleaseResource(&(Vcb->DlocResource));
1410} // end UDFReleaseDlocList()

Referenced by UDFCleanupVCB().

◆ UDFRelocateDloc()

void UDFRelocateDloc ( IN PVCB  Vcb,
IN PUDF_DATALOC_INFO  Dloc,
IN uint32  NewLba 
)

Definition at line 1374 of file dirtree.cpp.

1379{
1380 LONG i;
1381
1382 UDFAcquireResourceExclusive(&(Vcb->DlocResource),TRUE);
1383
1384 if((i = UDFFindDlocInMem(Vcb, Dloc)) != (-1)) {
1385 ASSERT(Vcb->DlocList);
1386 Vcb->DlocList[i].Lba = NewLba;
1387 }
1388 UDFReleaseResource(&(Vcb->DlocResource));
1389
1390} // end UDFRelocateDloc()

Referenced by UDFFlushFE().

◆ UDFRemoveDloc()

OSSTATUS UDFRemoveDloc ( IN PVCB  Vcb,
IN PUDF_DATALOC_INFO  Dloc 
)

Definition at line 1299 of file dirtree.cpp.

1303{
1304 LONG i;
1305
1306 UDFAcquireResourceExclusive(&(Vcb->DlocResource),TRUE);
1307
1308 if((i = UDFFindDlocInMem(Vcb, Dloc)) == (-1)) {
1309 // FE specified is not in cache. exit
1310 UDFReleaseResource(&(Vcb->DlocResource));
1312 }
1313 // remove from cache
1314 ASSERT(Vcb->DlocList);
1315 RtlZeroMemory(&(Vcb->DlocList[i]), sizeof(UDF_DATALOC_INDEX));
1316 UDFReleaseResource(&(Vcb->DlocResource));
1317 MyFreePool__(Dloc);
1318 return STATUS_SUCCESS;
1319} // end UDFRemoveDloc()

Referenced by UDFBuildFileEntry(), UDFCleanUpFile__(), and UDFHardLinkFile__().

◆ UDFReTagDirectory()

OSSTATUS UDFReTagDirectory ( IN PVCB  Vcb,
IN OUT PUDF_FILE_INFO  FileInfo 
)

Definition at line 895 of file dirtree.cpp.

899{
900 uint32 l;
902 int8* Buf;
905 PUDF_FILE_INFO curFileInfo;
906 PDIR_INDEX_ITEM DirNdx;
907 UDF_DIR_SCAN_CONTEXT ScanContext;
908 uint16 PartNum;
909
911 PDIR_INDEX_HDR hDirNdx = FileInfo->Dloc->DirIndex;
912 if(!hDirNdx) return STATUS_NOT_A_DIRECTORY;
913
914 // do not pack dirs on unchanged disks
915 if(!Vcb->Modified)
916 return STATUS_SUCCESS;
917
918 if( ((hDirNdx->DIFlags & UDF_DI_FLAG_INIT_IN_ICB) ? TRUE : FALSE) ==
919 ((FileInfo->Dloc->DataLoc.Offset) ? TRUE : FALSE) ) {
920 return STATUS_SUCCESS;
921 }
922
923 // start packing
924 Buf = (int8*)DbgAllocatePool(PagedPool, Vcb->LBlockSize*2);
925 if(!Buf) return STATUS_INSUFFICIENT_RESOURCES;
926
927 Offset = UDFDirIndex(hDirNdx,1)->Offset;
928
929 if(!UDFDirIndexInitScan(FileInfo, &ScanContext, 1)) {
930 DbgFreePool(Buf);
931 return STATUS_SUCCESS;
932 }
933
934 ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
935 PartNum = (uint16)UDFGetPartNumByPhysLba(Vcb, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
936 ASSERT(PartNum != -1);
937
938 while((DirNdx = UDFDirIndexScan(&ScanContext, NULL))) {
939
941 l = DirNdx->Length, FALSE, Buf, &ReadBytes);
942 if(!OS_SUCCESS(status)) {
943 DbgFreePool(Buf);
944 return status;
945 }
946 curFileInfo = DirNdx->FileInfo;
947 // write modified
948 UDFSetUpTag(Vcb, (tag*)Buf, (uint16)l,
949 UDFPhysLbaToPart(Vcb, PartNum,
950 UDFExtentOffsetToLba(Vcb, FileInfo->Dloc->DataLoc.Mapping,
951 Offset, NULL, NULL, NULL, NULL)));
952
953 if(curFileInfo && curFileInfo->FileIdent) {
954 FileInfo->Dloc->FELoc.Modified = TRUE;
955 FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
956 }
957
959 if(!OS_SUCCESS(status)) {
960 DbgFreePool(Buf);
961 return status;
962 }
963 if(curFileInfo) {
965 }
966 }
967 // resize DirIndex
968 DbgFreePool(Buf);
969
970 hDirNdx->DIFlags &= ~UDF_DI_FLAG_INIT_IN_ICB;
971 hDirNdx->DIFlags |= (FileInfo->Dloc->DataLoc.Offset ? UDF_DI_FLAG_INIT_IN_ICB : 0);
972 return status;
973
974} // end UDFReTagDirectory()

Referenced by UDFFlushFE().

◆ UDFStoreDloc()

OSSTATUS UDFStoreDloc ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  fi,
IN uint32  Lba 
)

Definition at line 1240 of file dirtree.cpp.

1245{
1246 LONG i;
1247 PUDF_DATALOC_INFO Dloc;
1248
1249 if(!Lba) return STATUS_INVALID_PARAMETER;
1250 if(Lba == (ULONG)-1) return STATUS_INVALID_PARAMETER;
1251
1252 UDFAcquireResourceExclusive(&(Vcb->DlocResource),TRUE);
1253
1254 // check if FE specified is already in use
1255 if((i = UDFFindDloc(Vcb, Lba)) == (-1)) {
1256 // not used
1257 if((i = UDFFindFreeDloc(Vcb, Lba)) == (-1)) {
1258 UDFReleaseResource(&(Vcb->DlocResource));
1260 }
1261 } else {
1262 if(!OS_SUCCESS(UDFAcquireDloc(Vcb, Dloc = Vcb->DlocList[i].Dloc))) {
1263 UDFReleaseResource(&(Vcb->DlocResource));
1264 return STATUS_SHARING_PAUSED;
1265 }
1266 // update caller's structures & exit
1267 fi->Dloc = Dloc;
1268 UDFReleaseDloc(Vcb, Dloc);
1269#if defined UDF_DBG && !defined _CONSOLE
1270 if(fi->Dloc->CommonFcb) {
1271 ASSERT((uint32)(fi->Dloc->CommonFcb) != 0xDEADDA7A);
1272 ASSERT(fi->Dloc->CommonFcb->CommonFCBHeader.NodeTypeCode == UDF_NODE_TYPE_NT_REQ_FCB);
1273 }
1274#endif // UDF_DBG
1275 UDFReleaseResource(&(Vcb->DlocResource));
1276 return STATUS_SUCCESS;
1277 }
1278 // allocate common DataLocation (Dloc) descriptor
1280 if(!Dloc) {
1281 UDFReleaseResource(&(Vcb->DlocResource));
1283 }
1284 Vcb->DlocList[i].Lba = Lba;
1285 Vcb->DlocList[i].Dloc = Dloc;
1286 RtlZeroMemory(Dloc, sizeof(UDF_DATALOC_INFO));
1287 Dloc->LinkedFileInfo = fi;
1288 UDFAcquireDloc(Vcb, Dloc);
1289 UDFReleaseResource(&(Vcb->DlocResource));
1290 return STATUS_SUCCESS;
1291} // end UDFStoreDloc()
OSSTATUS UDFReleaseDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1224
OSSTATUS UDFAcquireDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1206
LONG UDFFindFreeDloc(IN PVCB Vcb, IN uint32 Lba)
Definition: dirtree.cpp:1171
LONG UDFFindDloc(IN PVCB Vcb, IN uint32 Lba)
Definition: dirtree.cpp:1127
#define UDF_NODE_TYPE_NT_REQ_FCB
Definition: struct.h:57
struct _UDF_FILE_INFO * LinkedFileInfo
Definition: udf_rel.h:313
#define MEM_DLOC_INF_TAG
Definition: udf_rel.h:482
#define UDF_DATALOC_INFO_MT
Definition: udf_rel.h:228
struct _UDF_DATALOC_INFO * PUDF_DATALOC_INFO

Referenced by UDFBlankMount(), UDFBuildFileEntry(), UDFOpenFile__(), and UDFOpenRootFile__().

◆ UDFUnlinkDloc()

OSSTATUS UDFUnlinkDloc ( IN PVCB  Vcb,
IN PUDF_DATALOC_INFO  Dloc 
)

Definition at line 1327 of file dirtree.cpp.

1331{
1332 LONG i;
1333
1334 UDFAcquireResourceExclusive(&(Vcb->DlocResource),TRUE);
1335
1336 if((i = UDFFindDlocInMem(Vcb, Dloc)) == (-1)) {
1337 // FE specified is not in cache. exit
1338 UDFReleaseResource(&(Vcb->DlocResource));
1340 }
1341 // remove from cache
1342 ASSERT(Vcb->DlocList);
1343 RtlZeroMemory(&(Vcb->DlocList[i]), sizeof(UDF_DATALOC_INDEX));
1344 UDFReleaseResource(&(Vcb->DlocResource));
1345 return STATUS_SUCCESS;
1346} // end UDFUnlinkDloc()

Referenced by UDFRenameMoveFile__(), and UDFUnlinkFile__().