ReactOS  0.4.13-dev-1158-g658d5a3
udf_info.cpp File Reference
#include "udf.h"
Include dependency graph for udf_info.cpp:

Go to the source code of this file.

Macros

#define UDF_BUG_CHECK_ID   UDF_FILE_UDF_INFO
 
#define DOS_CRC_MODULUS   41
 
#define hexChar   crcChar
 
#define DOS_CRC_LEN   4
 
#define DOS_CRC_MODULUS   41
 
#define lba   WrittenBytes
 

Functions

void __fastcall UDFDecompressUnicode (IN OUT PUNICODE_STRING UName, IN uint8 *CS0, IN SIZE_T Length, OUT uint16 *valueCRC)
 
void __fastcall UDFCompressUnicode (IN PUNICODE_STRING UName, IN OUT uint8 **_CS0, IN OUT PSIZE_T Length)
 
OSSTATUS UDFReadFileEntry (IN PVCB Vcb, IN long_ad *Icb, IN OUT PFILE_ENTRY FileEntry, IN OUT uint16 *Ident)
 
BOOLEAN UDFUnicodeInString (IN uint8 *string, IN WCHAR ch)
 
BOOLEAN __fastcall UDFIsIllegalChar (IN WCHAR chr)
 
void __fastcall UDFDOSName (IN PVCB Vcb, IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)
 
void __fastcall UDFDOSName100 (IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)
 
void __fastcall UDFDOSName200 (IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact, IN BOOLEAN Mode150)
 
void __fastcall UDFDOSName201 (IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)
 
void UDFSetUpTag (IN PVCB Vcb, IN tag *Tag, IN uint16 DataLen, IN uint32 TagLoc)
 
OSSTATUS UDFBuildFileEntry (IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum, IN uint16 AllocMode, IN uint32 ExtAttrSz, IN BOOLEAN Extended)
 
OSSTATUS UDFLoadExtInfo (IN PVCB Vcb, IN PFILE_ENTRY fe, IN PLONG_AD fe_loc, IN OUT PEXTENT_INFO FExtInfo, IN OUT PEXTENT_INFO AExtInfo)
 
OSSTATUS UDFBuildFileIdent (IN PVCB Vcb, IN PUNICODE_STRING fn, IN PLONG_AD FileEntryIcb, IN uint32 ImpUseLen, OUT PFILE_IDENT_DESC *_FileId, OUT uint32 *FileIdLen)
 
void UDFSetFileSize (IN PUDF_FILE_INFO FileInfo, IN int64 Size)
 
void UDFSetFileSizeInDirNdx (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 *ASize)
 
int64 UDFGetFileSize (IN PUDF_FILE_INFO FileInfo)
 
int64 UDFGetFileSizeFromDirNdx (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
 
void UDFSetAllocDescLen (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
 
void UDFChangeFileLinkCount (IN PUDF_FILE_INFO FileInfo, IN BOOLEAN Increase)
 
uint16 UDFGetFileLinkCount (IN PUDF_FILE_INFO FileInfo)
 
uint32 UDFGetFileEALength (IN PUDF_FILE_INFO FileInfo)
 
int64 UDFAssingNewFUID (IN PVCB Vcb)
 
void UDFSetFileUID (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
 
__inline int64 UDFGetFileUID_ (IN tag *FileEntry)
 
int64 UDFGetFileUID (IN PUDF_FILE_INFO FileInfo)
 
void UDFChangeFileCounter (IN PVCB Vcb, IN BOOLEAN FileCounter, IN BOOLEAN Increase)
 
void UDFSetEntityID_imp_ (IN EntityID *eID, IN uint8 *Str, IN uint32 Len)
 
void UDFReadEntityID_Domain (PVCB Vcb, EntityID *eID)
 
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)
 
OSSTATUS UDFUnlinkFile__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN BOOLEAN FreeSpace)
 
OSSTATUS UDFUnlinkAllFilesInDir (IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo)
 
OSSTATUS UDFOpenFile__ (IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN BOOLEAN NotDeleted, IN PUNICODE_STRING fn, IN PUDF_FILE_INFO DirInfo, OUT PUDF_FILE_INFO *_FileInfo, IN uint_di *IndexToOpen)
 
OSSTATUS UDFOpenRootFile__ (IN PVCB Vcb, IN lb_addr *RootLoc, OUT PUDF_FILE_INFO FileInfo)
 
uint32 UDFCleanUpFile__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFCreateFile__ (IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN PUNICODE_STRING _fn, IN uint32 ExtAttrSz, IN uint32 ImpUseLen, IN BOOLEAN Extended, IN BOOLEAN CreateNew, IN OUT PUDF_FILE_INFO DirInfo, OUT PUDF_FILE_INFO *_FileInfo)
 
__inline OSSTATUS UDFZeroFile__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, OUT PSIZE_T ReadBytes)
 
__inline OSSTATUS UDFSparseFile__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, OUT PSIZE_T ReadBytes)
 
OSSTATUS UDFPadLastSector (IN PVCB Vcb, IN PEXTENT_INFO ExtInfo)
 
OSSTATUS UDFCloseFile__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFRenameMoveFile__ (IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN OUT BOOLEAN *Replace, IN PUNICODE_STRING fn, IN OUT PUDF_FILE_INFO DirInfo1, IN OUT PUDF_FILE_INFO DirInfo2, IN OUT PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFRecordDirectory__ (IN PVCB Vcb, IN OUT PUDF_FILE_INFO DirInfo)
 
OSSTATUS UDFResizeFile__ (IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
 
OSSTATUS UDFLoadVAT (IN PVCB Vcb, IN uint32 PartNdx)
 
BOOLEAN UDFIsDirEmpty (IN PDIR_INDEX_HDR hCurDirNdx)
 
OSSTATUS UDFFlushFE (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
 
OSSTATUS UDFFlushFI (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
 
OSSTATUS UDFFlushFile__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN ULONG FlushFlags)
 
BOOLEAN UDFCompareFileInfo (IN PUDF_FILE_INFO f1, IN PUDF_FILE_INFO f2)
 
uint32 __fastcall crc32 (IN uint8 *s, IN uint32 len)
 
uint16 __fastcall UDFUnicodeCksum (PWCHAR s, uint32 n)
 
uint16 __fastcall UDFUnicodeCksum150 (PWCHAR s, uint32 n)
 
uint16 __fastcall UDFCrc (IN uint8 *Data, IN SIZE_T Size)
 
OSSTATUS UDFReadTagged (PVCB Vcb, int8 *Buf, uint32 Block, uint32 Location, uint16 *Ident)
 
OSSTATUS UDFHardLinkFile__ (IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN OUT BOOLEAN *Replace, IN PUNICODE_STRING fn, IN OUT PUDF_FILE_INFO DirInfo1, IN OUT PUDF_FILE_INFO DirInfo2, IN OUT PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFCreateRootFile__ (IN PVCB Vcb, IN uint32 PartNum, IN uint32 ExtAttrSz, IN uint32 ImpUseLen, IN BOOLEAN Extended, OUT PUDF_FILE_INFO *_FileInfo)
 
OSSTATUS UDFCreateStreamDir__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, OUT PUDF_FILE_INFO *_SDirInfo)
 
OSSTATUS UDFOpenStreamDir__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, OUT PUDF_FILE_INFO *_SDirInfo)
 
OSSTATUS UDFRecordVAT (IN PVCB Vcb)
 
OSSTATUS UDFUpdateVAT (IN void *_Vcb, IN uint32 Lba, IN uint32 *RelocTab, IN uint32 BCount)
 
OSSTATUS UDFConvertFEToNonInICB (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint8 NewAllocMode)
 
OSSTATUS UDFConvertFEToExtended (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
 
OSSTATUS UDFPretendFileDeleted__ (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
 

Variables

static const char valid_char_arr [] = {"*/:?\"<>|\\"}
 
static const char crcChar [] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#_~-@"
 
static const uint16 CrcTable [256]
 
static const uint32 crc32_tab []
 

Macro Definition Documentation

◆ DOS_CRC_LEN

#define DOS_CRC_LEN   4

◆ DOS_CRC_MODULUS [1/2]

#define DOS_CRC_MODULUS   41

Definition at line 44 of file udf_info.cpp.

◆ DOS_CRC_MODULUS [2/2]

#define DOS_CRC_MODULUS   41

Definition at line 44 of file udf_info.cpp.

◆ hexChar

#define hexChar   crcChar

Definition at line 45 of file udf_info.cpp.

◆ lba

#define lba   WrittenBytes

◆ UDF_BUG_CHECK_ID

#define UDF_BUG_CHECK_ID   UDF_FILE_UDF_INFO

Definition at line 19 of file udf_info.cpp.

Function Documentation

◆ crc32()

uint32 __fastcall crc32 ( IN uint8 s,
IN uint32  len 
)

Definition at line 4290 of file udf_info.cpp.

4294 {
4295 #if defined(_X86_) && defined(_MSC_VER) && !defined(__clang__)
4296 // uint32 _Size = len;
4297 
4298  __asm {
4299  push ebx
4300  push ecx
4301  push edx
4302  push esi
4303 
4304  xor eax,eax
4305  mov esi,ecx // ESI <- s
4306  mov ecx,edx // ECX <- len
4307 
4308  jecxz EO_CRC
4309 
4310  lea ebx,[crc32_tab]
4311  xor edx,edx
4312 
4313 CRC_loop:
4314 
4315  mov dl,al
4316  xor dl,[esi]
4317  shr eax,8
4318  xor eax,[dword ptr ebx+edx*4]
4319  inc esi
4320  loop CRC_loop
4321 
4322 EO_CRC:
4323 
4324  pop esi
4325  pop edx
4326  pop ecx
4327  pop ebx
4328 
4329  ret
4330  }
4331 #else // NO X86 optimization , use generic C/C++
4332  uint32 i;
4333  uint32 crc32val = 0;
4334 
4335  for(i=0; i<len; i++, s++) {
4336  crc32val =
4337  crc32_tab[(crc32val ^ (*s)) & 0xff] ^ (crc32val >> 8);
4338  }
4339  return crc32val;
4340 #endif // _X86_
4341 } // end crc32()
static void xor(unsigned char *dst, const unsigned char *a, const unsigned char *b, const int count)
Definition: crypt_des.c:251
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx eax jnz xchgl ecx incl TEMP esi
Definition: synth_sse3d.h:103
static const uint32 crc32_tab[]
Definition: udf_info.cpp:86
unsigned int uint32
Definition: types.h:32
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
static PVOID ptr
Definition: dispmode.c:27
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl ebx
Definition: synth_sse3d.h:83
int ret
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
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

◆ UDFAssingNewFUID()

int64 UDFAssingNewFUID ( IN PVCB  Vcb)

Definition at line 1445 of file udf_info.cpp.

1448 {
1449  Vcb->NextUniqueId++;
1450  if(!((uint32)(Vcb->NextUniqueId)))
1451  Vcb->NextUniqueId += 16;
1452  return Vcb->NextUniqueId;
1453 }
unsigned int uint32
Definition: types.h:32
#define Vcb
Definition: cdprocs.h:1425

Referenced by UDFHardLinkFile__(), and UDFSetFileUID().

◆ UDFBuildFileEntry()

OSSTATUS UDFBuildFileEntry ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  DirInfo,
IN PUDF_FILE_INFO  FileInfo,
IN uint32  PartNum,
IN uint16  AllocMode,
IN uint32  ExtAttrSz,
IN BOOLEAN  Extended 
)

Definition at line 971 of file udf_info.cpp.

980 {
981  PFILE_ENTRY FileEntry;
983 // EntityID* eID;
984  uint32 l;
985  EXTENT_INFO _FEExtInfo;
986  uint16* lcp;
987 
988  ASSERT(!PartNum);
989  ASSERT(!ExtAttrSz);
990  // calculate the length required
991  l = (Extended ? sizeof(EXTENDED_FILE_ENTRY) : sizeof(FILE_ENTRY)) + ExtAttrSz;
992  if(l > Vcb->LBlockSize) return STATUS_INVALID_PARAMETER;
993  // allocate block for FE
994  if(!OS_SUCCESS(status = UDFAllocateFESpace(Vcb, DirInfo, PartNum, &_FEExtInfo, l) ))
995  return status;
996  // remember FE location for future hard link creation
997  ASSERT(UDFFindDloc(Vcb, _FEExtInfo.Mapping[0].extLocation) == (-1));
998  if(!OS_SUCCESS(status = UDFStoreDloc(Vcb, FileInfo, _FEExtInfo.Mapping[0].extLocation))) {
1000  UDFFreeFESpace(Vcb, DirInfo, &_FEExtInfo); // free
1001  MyFreePool__(_FEExtInfo.Mapping);
1002  return status;
1003  }
1005  if(!FileEntry) {
1006  UDFRemoveDloc(Vcb, FileInfo->Dloc);
1007  FileInfo->Dloc = NULL;
1008  UDFFreeFESpace(Vcb, DirInfo, &_FEExtInfo); // free
1009  MyFreePool__(_FEExtInfo.Mapping);
1011  }
1012  FileInfo->Dloc->FELoc = _FEExtInfo;
1013 
1014  RtlZeroMemory((int8*)FileEntry, l);
1015  // set up in-memory FE structure
1016  FileEntry->icbTag.flags = AllocMode;
1017  FileEntry->icbTag.fileType = UDF_FILE_TYPE_REGULAR;
1018  FileEntry->icbTag.numEntries = 1;
1019 // if(DirInfo && DirInfo->Dloc && DirInfo->Dloc
1020  FileEntry->icbTag.strategyType = 4;
1021 // FileEntry->icbTag.strategyParameter = 0;
1022  FileEntry->descTag.tagIdent = Extended ? TID_EXTENDED_FILE_ENTRY : TID_FILE_ENTRY;
1023  FileEntry->descTag.tagLocation = UDFPhysLbaToPart(Vcb, PartNum, _FEExtInfo.Mapping[0].extLocation);
1024  FileEntry->uid = Vcb->DefaultUID;
1025  FileEntry->gid = Vcb->DefaultGID;
1026 
1027  if(Extended) {
1028 // eID = &(((PEXTENDED_FILE_ENTRY)FileEntry)->impIdent);
1029  lcp = &(((PEXTENDED_FILE_ENTRY)FileEntry)->fileLinkCount);
1030  ((PEXTENDED_FILE_ENTRY)FileEntry)->checkpoint = 1;
1031  } else {
1032 // eID = &(FileEntry->impIdent);
1033  lcp = &(FileEntry->fileLinkCount);
1034  ((PFILE_ENTRY)FileEntry)->checkpoint = 1;
1035  }
1036 
1037 #if 0
1039 #endif
1040 
1041  /*RtlCopyMemory((int8*)&(eID->ident), UDF_ID_DEVELOPER, sizeof(UDF_ID_DEVELOPER) );
1042  iis = (impIdentSuffix*)&(eID->identSuffix);
1043  iis->OSClass = UDF_OS_CLASS_WINNT;
1044  iis->OSIdent = UDF_OS_ID_WINNT;*/
1045 
1046  *lcp = 0xffff;
1047 
1048  FileInfo->Dloc->FileEntry = (tag*)FileEntry;
1049  FileInfo->Dloc->FileEntryLen = l;
1050 
1051  FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
1052 
1053  return STATUS_SUCCESS;
1054 } // end UDFBuildFileEntry()
uint16 tagIdent
Definition: ecma_167.h:139
OSSTATUS UDFAllocateFESpace(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN uint32 PartNum, IN PEXTENT_INFO FEExtInfo, IN uint32 Len)
Definition: extent.cpp:1563
uint32 gid
Definition: ecma_167.h:517
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _EXTENDED_FILE_ENTRY EXTENDED_FILE_ENTRY
#define UDFSetEntityID_imp(eID, Str)
Definition: udf_info.h:598
unsigned int uint32
Definition: types.h:32
uint16 fileLinkCount
Definition: ecma_167.h:519
struct _FILE_ENTRY * PFILE_ENTRY
uint32 extLocation
Definition: ecma_167.h:129
Definition: ecma_167.h:138
uint16 numEntries
Definition: ecma_167.h:456
uint32 tagLocation
Definition: ecma_167.h:146
#define MEM_FE_TAG
Definition: udf_rel.h:486
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
#define TID_EXTENDED_FILE_ENTRY
Definition: ecma_167.h:175
#define UDF_ID_DEVELOPER
Definition: osta_misc.h:20
#define OSSTATUS
Definition: env_spec_w32.h:57
smooth NULL
Definition: ftsmooth.c:416
void UDFFreeFESpace(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN PEXTENT_INFO FEExtInfo)
Definition: extent.cpp:1725
OSSTATUS UDFStoreDloc(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN uint32 Lba)
Definition: dirtree.cpp:1240
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
r l[0]
Definition: byte_order.h:167
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define UDF_FILE_TYPE_REGULAR
Definition: ecma_167.h:469
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ecma_167.h:513
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
#define STATUS_SHARING_PAUSED
Definition: udferr_usr.h:165
uint32 uid
Definition: ecma_167.h:516
Definition: shlfileop.cpp:55
#define MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
OSSTATUS UDFRemoveDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1299
tag descTag
Definition: ecma_167.h:514
icbtag icbTag
Definition: ecma_167.h:515
unsigned short uint16
Definition: types.h:30
uint16 flags
Definition: ecma_167.h:460
uint16 strategyType
Definition: ecma_167.h:454
struct _EXTENDED_FILE_ENTRY * PEXTENDED_FILE_ENTRY
uint8 fileType
Definition: ecma_167.h:458
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
LONG UDFFindDloc(IN PVCB Vcb, IN uint32 Lba)
Definition: dirtree.cpp:1127
#define TID_FILE_ENTRY
Definition: ecma_167.h:170
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
char int8
Definition: platform.h:10
Definition: ps.c:97

Referenced by UDFCreateFile__(), and UDFCreateRootFile__().

◆ UDFBuildFileIdent()

OSSTATUS UDFBuildFileIdent ( IN PVCB  Vcb,
IN PUNICODE_STRING  fn,
IN PLONG_AD  FileEntryIcb,
IN uint32  ImpUseLen,
OUT PFILE_IDENT_DESC _FileId,
OUT uint32 FileIdLen 
)

Definition at line 1107 of file udf_info.cpp.

1115 {
1116  PFILE_IDENT_DESC FileId;
1117  uint8* CS0;
1118  SIZE_T Nlen;
1119  uint32 l;
1120  // prepare filename
1121  UDFCompressUnicode(fn, &CS0, &Nlen);
1122  if(!CS0) return STATUS_INSUFFICIENT_RESOURCES;
1123  if(Nlen < 2) {
1124  Nlen = 0;
1125  } else
1126  if(Nlen > UDF_NAME_LEN) {
1127  if(CS0) MyFreePool__(CS0);
1129  }
1130  // allocate memory for FI
1131  l = (sizeof(FILE_IDENT_DESC) + Nlen + ImpUseLen + 3) & ~((uint32)3);
1133  if(!FileId) {
1134  if(CS0) MyFreePool__(CS0);
1136  }
1137  // fill FI structure
1138  RtlZeroMemory( (int8*)FileId, l);
1139  RtlCopyMemory( ((int8*)(FileId+1))+ImpUseLen, CS0, Nlen);
1141  FileId->fileVersionNum = 1;
1142  FileId->lengthOfImpUse = (uint16)ImpUseLen;
1143  FileId->lengthFileIdent = (uint8)Nlen;
1144  FileId->icb = *FileEntryIcb;
1145  *_FileId = FileId;
1146  *FileIdLen = l;
1147 
1148  if(CS0) MyFreePool__(CS0);
1149  return STATUS_SUCCESS;
1150 } // end UDFBuildFileIdent()
uint16 tagIdent
Definition: ecma_167.h:139
struct _FILE_IDENT_DESC * PFILE_IDENT_DESC
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _FILE_IDENT_DESC FILE_IDENT_DESC
#define UDF_NAME_LEN
Definition: osta_misc.h:314
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
unsigned int uint32
Definition: types.h:32
#define MEM_FID_TAG
Definition: udf_rel.h:488
uint8 lengthFileIdent
Definition: ecma_167.h:429
r l[0]
Definition: byte_order.h:167
#define MyFreePool__(addr)
Definition: mem_tools.h:152
void __fastcall UDFCompressUnicode(IN PUNICODE_STRING UName, IN OUT uint8 **_CS0, IN OUT PSIZE_T Length)
Definition: udf_info.cpp:240
unsigned char uint8
Definition: types.h:28
uint16 lengthOfImpUse
Definition: ecma_167.h:431
uint16 fileVersionNum
Definition: ecma_167.h:427
#define TID_FILE_IDENT_DESC
Definition: ecma_167.h:166
#define MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short uint16
Definition: types.h:30
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
char int8
Definition: platform.h:10

Referenced by UDFCreateFile__(), and UDFRecordDirectory__().

◆ UDFChangeFileCounter()

void UDFChangeFileCounter ( IN PVCB  Vcb,
IN BOOLEAN  FileCounter,
IN BOOLEAN  Increase 
)

Definition at line 1520 of file udf_info.cpp.

1525 {
1526  uint32* counter;
1527 
1528  counter = FileCounter ?
1529  &(Vcb->numFiles) :
1530  &(Vcb->numDirs);
1531  if(*counter == (ULONG)-1)
1532  return;
1533  if(Increase) {
1535  } else {
1537  }
1538 
1539 } // end UDFChangeFileCounter()
unsigned int uint32
Definition: types.h:32
#define UDFInterlockedDecrement(addr)
Definition: env_spec_w32.h:677
GLuint counter
Definition: glext.h:11116
#define Vcb
Definition: cdprocs.h:1425
#define UDFInterlockedIncrement(addr)
Definition: env_spec_w32.h:675
long int32
Definition: platform.h:12
unsigned int ULONG
Definition: retypes.h:1

Referenced by UDFUnlinkFile__().

◆ UDFChangeFileLinkCount()

void UDFChangeFileLinkCount ( IN PUDF_FILE_INFO  FileInfo,
IN BOOLEAN  Increase 
)

Definition at line 1315 of file udf_info.cpp.

1319 {
1320  uint16 Ident;
1321 
1323 
1324  FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
1325  Ident = FileInfo->Dloc->FileEntry->tagIdent;
1326  if(Ident == TID_FILE_ENTRY) {
1327  PFILE_ENTRY fe = (PFILE_ENTRY)(FileInfo->Dloc->FileEntry);
1328  if(Increase) {
1329  fe->fileLinkCount++;
1330  } else {
1331  fe->fileLinkCount--;
1332  }
1333  if(fe->fileLinkCount & 0x8000)
1334  fe->fileLinkCount = 0xffff;
1335  return;
1336  } else if(Ident == TID_EXTENDED_FILE_ENTRY) {
1337  PEXTENDED_FILE_ENTRY fe = (PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry);
1338  if(Increase) {
1339  fe->fileLinkCount++;
1340  } else {
1341  fe->fileLinkCount--;
1342  }
1343  if(fe->fileLinkCount & 0x8000)
1344  fe->fileLinkCount = 0xffff;
1345  return;
1346  }
1347  return;
1348 } // end UDFChangeFileLinkCount()
uint16 fileLinkCount
Definition: ecma_167.h:519
struct _FILE_ENTRY * PFILE_ENTRY
#define TID_EXTENDED_FILE_ENTRY
Definition: ecma_167.h:175
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
uint16 fileLinkCount
Definition: ecma_167.h:748
Definition: ecma_167.h:742
Definition: ecma_167.h:513
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
unsigned short uint16
Definition: types.h:30
struct _EXTENDED_FILE_ENTRY * PEXTENDED_FILE_ENTRY
#define TID_FILE_ENTRY
Definition: ecma_167.h:170

◆ UDFCleanUpFile__()

uint32 UDFCleanUpFile__ ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo 
)

Definition at line 2276 of file udf_info.cpp.

2280 {
2281  PUDF_DATALOC_INFO Dloc;
2282  uint32 lc = 0;
2283  BOOLEAN IsASDir;
2284  BOOLEAN KeepDloc;
2285  PDIR_INDEX_ITEM DirNdx, DirNdx2;
2286  BOOLEAN Parallel = FALSE;
2287  BOOLEAN Linked = FALSE;
2288 #ifdef UDF_DBG
2289  BOOLEAN Modified = FALSE;
2290  PDIR_INDEX_HDR hDirNdx;
2291  uint_di Index;
2292  PUDF_FILE_INFO DirInfo;
2293 #endif // UDF_DBG
2294 
2295  if(!FileInfo) return UDF_FREE_FILEINFO;
2296 
2298 
2299  if(FileInfo->OpenCount || FileInfo->RefCount) {
2300  UDFPrint(("UDF: not all references are closed\n"));
2301  UDFPrint((" Skipping cleanup\n"));
2302  UDFPrint(("UDF: OpenCount = %x, RefCount = %x, LinkRefCount = %x\n",
2303  FileInfo->OpenCount,FileInfo->RefCount,FileInfo->Dloc->LinkRefCount));
2304  return UDF_FREE_NOTHING;
2305  }
2306  if(FileInfo->Fcb) {
2307  UDFPrint(("Operating System still has references to this file\n"));
2308  UDFPrint((" Skipping cleanup\n"));
2309 // BrutePoint();
2310  return UDF_FREE_NOTHING;
2311  }
2312 
2313  IsASDir = UDFIsAStreamDir(FileInfo);
2314 
2315  if((Dloc = FileInfo->Dloc)) {
2316 
2317 #ifdef UDF_DBG
2318  DirInfo = FileInfo->ParentFile;
2319  if(DirInfo) {
2320  hDirNdx = DirInfo->Dloc->DirIndex;
2321  Index = FileInfo->Index;
2322  // we can't delete modified file
2323  // it should be closed & reopened (or flushed) before deletion
2324  DirNdx = UDFDirIndex(hDirNdx,Index);
2325  UDFPrint(("Cleanup Mod: %s%s%s%s%s%s\n",
2326  (Dloc->FE_Flags & UDF_FE_FLAG_FE_MODIFIED) ? "FE " : "",
2327  (Dloc->DataLoc.Modified) ? "DataLoc " : "",
2328  (Dloc->DataLoc.Flags & EXTENT_FLAG_PREALLOCATED) ? "Data-PreAlloc " : "",
2329  (Dloc->AllocLoc.Modified) ? "AllocLoc " : "",
2330  (Dloc->FELoc.Modified) ? "FELoc " : "",
2331  (DirNdx && (DirNdx->FI_Flags & UDF_FI_FLAG_FI_MODIFIED)) ? "FI " : ""
2332  ));
2333  Modified = ((Dloc->FE_Flags & UDF_FE_FLAG_FE_MODIFIED) ||
2334  Dloc->DataLoc.Modified ||
2336  Dloc->AllocLoc.Modified ||
2337  Dloc->FELoc.Modified ||
2338  (DirNdx && (DirNdx->FI_Flags & UDF_FI_FLAG_FI_MODIFIED)) );
2339  }
2340 #endif // UDF_DBG
2341 
2343 
2344  Parallel = (ParFileInfo != NULL);
2345  Linked = (FileInfo->NextLinkedFile != FileInfo);
2346 
2347 // Parallel = (FileInfo->NextLinkedFile != FileInfo);
2348  ASSERT(FileInfo->NextLinkedFile);
2349 // ASSERT(!Parallel);
2350  KeepDloc = (Dloc->LinkRefCount ||
2351  Dloc->CommonFcb ||
2352  Linked ) ?
2353  TRUE : FALSE;
2354 
2355  if(Dloc->DirIndex) {
2356  uint_di i;
2357  for(i=2; (DirNdx = UDFDirIndex(Dloc->DirIndex,i)); i++) {
2358  if(DirNdx->FileInfo) {
2359  if(!KeepDloc) {
2360  BrutePoint();
2361  UDFPrint(("UDF: Found not cleaned up reference.\n"));
2362  UDFPrint((" Skipping cleanup (1)\n"));
2363 // BrutePoint();
2364  return UDF_FREE_NOTHING;
2365  }
2366  // The file being cleaned up may have not closed Dirs
2367  // (linked Dir). In this case each of them may have
2368  // reference to FileInfo in DirIndex[1]
2369  // Here we'll check it and change for valid value if
2370  // necessary (Update Child Objects - I)
2371  if(DirNdx->FileInfo->Dloc) {
2372  // we can get here only when (Parallel == TRUE)
2373  DirNdx2 = UDFDirIndex(DirNdx->FileInfo->Dloc->DirIndex, 1);
2374  // It is enough to check DirNdx2->FileInfo only.
2375  // If one of Parallel FI's has reference (and equal)
2376  // to the FI being removed, it'll be removed from
2377  // the chain & nothing wrong will happen.
2378  if(DirNdx2 && (DirNdx2->FileInfo == FileInfo)) {
2379  if(FileInfo->PrevLinkedFile == FileInfo) {
2380  BrutePoint();
2381  DirNdx2->FileInfo = NULL;
2382  } else {
2383  DirNdx2->FileInfo = Parallel ?
2384  ParFileInfo : FileInfo->PrevLinkedFile;
2385  }
2386  ASSERT(!DirNdx2->FileInfo->RefCount);
2387  }
2388  }
2389  }
2390  }
2391  }
2392  if(Dloc->SDirInfo) {
2393  UDFPrint(("UDF: Found not cleaned up reference (SDir).\n"));
2394 
2395  // (Update Child Objects - II)
2396  if(Dloc->SDirInfo->ParentFile == FileInfo) {
2397  BrutePoint();
2398  ASSERT(ParFileInfo);
2399  Dloc->SDirInfo->ParentFile = ParFileInfo;
2400  }
2401  // We should break Cleanup process if alive reference detected
2402  // and there is no possibility to store pointer in some other
2403  // place (in parallel object)
2404  if(!KeepDloc) {
2405  BrutePoint();
2406  UDFPrint((" Skipping cleanup\n"));
2407  return UDF_FREE_NOTHING;
2408  }
2409 
2410  if(!UDFIsSDirDeleted(Dloc->SDirInfo) &&
2411  Dloc->SDirInfo->Dloc) {
2412  DirNdx2 = UDFDirIndex(Dloc->SDirInfo->Dloc->DirIndex, 1);
2413  if(DirNdx2 && (DirNdx2->FileInfo == FileInfo)) {
2414  DirNdx2->FileInfo =
2415  Parallel ? ParFileInfo : NULL;
2416  ASSERT(!DirNdx2->FileInfo->RefCount);
2417  }
2418  }
2419  }
2420 
2421  if(!KeepDloc) {
2422 
2423 #ifdef UDF_DBG
2424  ASSERT(!Modified);
2425 #endif
2426 
2427 #ifndef UDF_TRACK_ONDISK_ALLOCATION
2428  if(Dloc->DataLoc.Mapping) MyFreePool__(Dloc->DataLoc.Mapping);
2429  if(Dloc->AllocLoc.Mapping) MyFreePool__(Dloc->AllocLoc.Mapping);
2430  if(Dloc->FELoc.Mapping) MyFreePool__(Dloc->FELoc.Mapping);
2431  if(Dloc->FileEntry) {
2432  // plain file
2434  MyFreePool__(Dloc->FileEntry);
2435  Dloc->FileEntry = NULL;
2436  } else if(FileInfo->Index >= 2) {
2437  // error durring open operation
2439  }
2440 #endif //UDF_TRACK_ONDISK_ALLOCATION
2441  if(FileInfo->Dloc->DirIndex) {
2442  uint_di i;
2443  for(i=2; (DirNdx = UDFDirIndex(Dloc->DirIndex,i)); i++) {
2444  ASSERT(!DirNdx->FileInfo);
2445  if(DirNdx->FName.Buffer)
2446  MyFreePool__(DirNdx->FName.Buffer);
2447  }
2448  // The only place where we can free FE_Charge extent is here
2449  UDFFlushFESpace(Vcb, Dloc);
2450  UDFDirIndexFree(Dloc->DirIndex);
2451  Dloc->DirIndex = NULL;
2452 #ifdef UDF_TRACK_ONDISK_ALLOCATION
2454  if(FileInfo->Dloc->DirIndex) {
2455  for(i=2; DirNdx = UDFDirIndex(Dloc->DirIndex,i); i++) {
2456  ASSERT(!DirNdx->FileInfo);
2457  if(DirNdx->FName.Buffer)
2458  MyFreePool__(DirNdx->FName.Buffer);
2459  }
2460  UDFDirIndexFree(Dloc->DirIndex);
2461  Dloc->DirIndex = NULL;
2462  }
2463 #endif //UDF_TRACK_ONDISK_ALLOCATION
2464  }
2465 
2466 #ifdef UDF_TRACK_ONDISK_ALLOCATION
2467  if(Dloc->AllocLoc.Mapping) MyFreePool__(Dloc->AllocLoc.Mapping);
2468  if(Dloc->FELoc.Mapping) MyFreePool__(Dloc->FELoc.Mapping);
2469  if(Dloc->FileEntry) {
2470  // plain file
2472  MyFreePool__(Dloc->FileEntry);
2473  Dloc->FileEntry = NULL;
2474  } else if(FileInfo->Index >= 2) {
2475  // error durring open operation
2477  }
2478  if(Dloc->DataLoc.Mapping) {
2479  if(lc && (lc != UDF_INVALID_LINK_COUNT)) {
2480  UDFCheckSpaceAllocation(Vcb, 0, Dloc->DataLoc.Mapping, AS_USED); // check if used
2481  } else {
2482  UDFCheckSpaceAllocation(Vcb, 0, Dloc->DataLoc.Mapping, AS_FREE); // check if free
2483  }
2484  MyFreePool__(Dloc->DataLoc.Mapping);
2485  }
2486 #endif //UDF_TRACK_ONDISK_ALLOCATION
2487 
2488  if(lc && (lc != UDF_INVALID_LINK_COUNT)) {
2489  UDFRemoveDloc(Vcb, Dloc);
2490  } else {
2491  UDFFreeDloc(Vcb, Dloc);
2492  }
2493  } else // KeepDloc cannot be FALSE if (Linked == TRUE)
2494  if(Linked) {
2495 // BrutePoint();
2496  // Update pointers in ParentObject (if any)
2497  if(FileInfo->ParentFile->Dloc->SDirInfo == FileInfo)
2498  FileInfo->ParentFile->Dloc->SDirInfo = FileInfo->PrevLinkedFile;
2499  DirNdx = UDFDirIndex(FileInfo->Dloc->DirIndex, 0);
2500  if(DirNdx && (DirNdx->FileInfo == FileInfo))
2501  DirNdx->FileInfo = FileInfo->PrevLinkedFile;
2502  DirNdx = UDFDirIndex(FileInfo->ParentFile->Dloc->DirIndex, FileInfo->Index);
2503  if(DirNdx && (DirNdx->FileInfo == FileInfo))
2504  DirNdx->FileInfo = ParFileInfo;
2505  // remove from linked chain
2506  FileInfo->NextLinkedFile->PrevLinkedFile = FileInfo->PrevLinkedFile;
2507  FileInfo->PrevLinkedFile->NextLinkedFile = FileInfo->NextLinkedFile;
2508  // update pointer in Dloc
2509  if(FileInfo->Dloc->LinkedFileInfo == FileInfo)
2510  FileInfo->Dloc->LinkedFileInfo = FileInfo->PrevLinkedFile;
2511  }
2512  FileInfo->Dloc = NULL;
2513  } else {
2514  KeepDloc = FALSE;
2515  }
2516 
2517  // Cleanup pointers in ParentObject (if any)
2518  if(IsASDir) {
2519  if(FileInfo->ParentFile->Dloc->SDirInfo == FileInfo) {
2520  ASSERT(!Linked);
2521  FileInfo->ParentFile->Dloc->SDirInfo = NULL;
2522  FileInfo->ParentFile->Dloc->FE_Flags &= ~UDF_FE_FLAG_HAS_DEL_SDIR;
2523  }
2524  } else
2525  if(FileInfo->ParentFile) {
2526  ASSERT(FileInfo->ParentFile->Dloc);
2527  DirNdx = UDFDirIndex(FileInfo->ParentFile->Dloc->DirIndex, FileInfo->Index);
2528  ASSERT(DirNdx);
2529 #ifdef UDF_DBG
2530  PUDF_FILE_INFO OldFI;
2531  if(Parallel) {
2532  ASSERT(!DirNdx || !(OldFI = DirNdx->FileInfo) ||
2533  !(OldFI == FileInfo));
2534  } else {
2535  ASSERT(!DirNdx || !(OldFI = DirNdx->FileInfo) ||
2536  (OldFI == FileInfo));
2537  }
2538 #endif
2539  if( DirNdx && (DirNdx->FileInfo == FileInfo) ) {
2540  if(!Parallel)
2541  DirNdx->FileInfo = NULL;
2542 #ifdef UDF_DBG
2543  } else {
2544  // We can get here after incomplete Open
2545  if(!Parallel && DirNdx->FileInfo)
2546  BrutePoint();
2547 #endif
2548  }
2549 #ifdef UDF_DBG
2550  } else {
2551 // BrutePoint();
2552 #endif
2553  }
2554 
2555  if(!Parallel && FileInfo->FileIdent)
2556  MyFreePool__(FileInfo->FileIdent);
2557  FileInfo->FileIdent = NULL;
2558  // Kill reference to parent object
2559  FileInfo->ParentFile = NULL;
2560  // Kill references to parallel object(s) since it has no reference to
2561  // this one now
2562  FileInfo->NextLinkedFile =
2563  FileInfo->PrevLinkedFile = FileInfo;
2564  if(FileInfo->ListPtr)
2565  FileInfo->ListPtr->FileInfo = NULL;;
2566  return KeepDloc ? UDF_FREE_FILEINFO : (UDF_FREE_FILEINFO | UDF_FREE_DLOC);
2567 } // end UDFCleanUpFile__()
UNICODE_STRING FName
Definition: udf_rel.h:173
void UDFFreeDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1353
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
EXTENT_INFO AllocLoc
Definition: udf_rel.h:274
#define UDF_FE_FLAG_HAS_DEL_SDIR
File contains pointer to Deleted Stream Dir.
Definition: udf_rel.h:331
OSSTATUS UDFIndexDirectory(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:507
#define UDF_FREE_FILEINFO
Definition: udf_info.h:649
BOOLEAN Modified
Definition: udf_rel.h:68
#define UDF_INVALID_LINK_COUNT
Definition: udf_rel.h:508
unsigned int uint32
Definition: types.h:32
PDIR_INDEX_HDR DirIndex
Definition: udf_rel.h:312
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
#define UDFCheckSpaceAllocation(Vcb, FileInfo, Map, asXXX)
Definition: udf_info.h:281
uint32 FE_Flags
Definition: udf_rel.h:299
PUDF_DATALOC_INFO Dloc
Definition: udf_rel.h:367
#define UDF_FI_FLAG_FI_MODIFIED
FileIdent was modified & should be flushed.
Definition: udf_rel.h:217
uint32 uint_di
Definition: udf_rel.h:29
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
void UDFDirIndexFree(PDIR_INDEX_HDR hDirNdx)
Definition: dirtree.cpp:98
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
PUDF_FILE_INFO UDFLocateAnyParallelFI(PUDF_FILE_INFO fi)
Definition: dirtree.cpp:1439
unsigned char BOOLEAN
EXTENT_INFO FELoc
Definition: udf_rel.h:279
smooth NULL
Definition: ftsmooth.c:416
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
#define UDFIsAStreamDir(FI)
Definition: udf_info.h:998
UCHAR Flags
Definition: udf_rel.h:69
EXTENT_INFO DataLoc
Definition: udf_rel.h:262
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
static const UCHAR Index[8]
Definition: usbohci.c:18
#define BrutePoint()
Definition: env_spec_w32.h:504
struct _UDF_FILE_INFO * SDirInfo
Definition: udf_rel.h:319
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
#define UDFIsSDirDeleted(FI)
Definition: udf_info.h:1004
struct _UDFNTRequiredFCB * CommonFcb
Definition: udf_rel.h:255
uint32 LinkRefCount
Definition: udf_rel.h:306
#define AS_USED
Definition: udf_info.h:327
OSSTATUS UDFRemoveDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1299
#define UDF_FREE_DLOC
Definition: udf_info.h:650
#define AS_FREE
Definition: udf_info.h:326
#define UDF_FREE_NOTHING
Definition: udf_info.h:648
struct _UDF_FILE_INFO * FileInfo
Definition: udf_rel.h:204
static const WCHAR Linked[]
Definition: interface.c:30
struct FileInfo FileInfo
void UDFFlushFESpace(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc, IN BOOLEAN Discard)
Definition: extent.cpp:1776
#define EXTENT_FLAG_PREALLOCATED
Definition: udf_rel.h:79
uint8 FI_Flags
Definition: udf_rel.h:199
uint16 UDFGetFileLinkCount(IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1355

Referenced by UDFBlankMount(), UDFCleanUpFcbChain(), UDFCloseResidual(), UDFCommonCreate(), UDFCompareVcb(), UDFCompleteMount(), UDFCreateFile__(), UDFCreateStreamDir__(), UDFHardLinkFile__(), UDFLoadVAT(), UDFMarkStreamsForDeletion(), UDFReadSecurity(), UDFRenameMoveFile__(), UDFUnlinkAllFilesInDir(), UDFUnlinkFile__(), and UDFWriteSecurity().

◆ UDFCloseFile__()

OSSTATUS UDFCloseFile__ ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo 
)

Definition at line 2994 of file udf_info.cpp.

2998 {
3000 
3001  if(!FileInfo) return STATUS_SUCCESS;
3002  if(FileInfo->Index<2 && (FileInfo->ParentFile) && !UDFIsAStreamDir(FileInfo)) {
3003  UDFPrint(("Closing Current or Parent Directory... :-\\\n"));
3004  if(FileInfo->RefCount) {
3005  UDFInterlockedDecrement((PLONG)&(FileInfo->RefCount));
3006  ASSERT(FileInfo->Dloc);
3007  if(FileInfo->Dloc)
3008  UDFInterlockedDecrement((PLONG)&(FileInfo->Dloc->LinkRefCount));
3009 #ifdef UDF_DBG
3010  } else {
3011  BrutePoint();
3012  UDFPrint(("ERROR: Closing unreferenced file!\n"));
3013 #endif // UDF_DBG
3014  }
3015  if(FileInfo->ParentFile->OpenCount) {
3016  UDFInterlockedDecrement((PLONG)&(FileInfo->ParentFile->OpenCount));
3017 #ifdef UDF_DBG
3018  } else {
3019  BrutePoint();
3020  UDFPrint(("ERROR: Closing unopened file!\n"));
3021 #endif // UDF_DBG
3022  }
3023  return STATUS_SUCCESS;
3024  }
3025  PUDF_FILE_INFO DirInfo = FileInfo->ParentFile;
3026  OSSTATUS status;
3027  uint32 PartNum;
3028  if(FileInfo->RefCount) {
3029  UDFInterlockedDecrement((PLONG)&(FileInfo->RefCount));
3030  ASSERT(FileInfo->Dloc);
3031  if(FileInfo->Dloc)
3032  UDFInterlockedDecrement((PLONG)&(FileInfo->Dloc->LinkRefCount));
3033 #ifdef UDF_DBG
3034  } else {
3035  BrutePoint();
3036  UDFPrint(("ERROR: Closing unreferenced file!\n"));
3037 #endif // UDF_DBG
3038  }
3039  if(DirInfo) {
3040  // validate DirInfo
3041  ValidateFileInfo(DirInfo);
3042 
3043  if(DirInfo->OpenCount) {
3044  UDFInterlockedDecrement((PLONG)&(DirInfo->OpenCount));
3045 #ifdef UDF_DBG
3046  } else {
3047  BrutePoint();
3048  UDFPrint(("ERROR: Closing unopened file!\n"));
3049 #endif // UDF_DBG
3050  }
3051  }
3052  // If the file has gone (unlinked) we should return STATUS_SUCCESS here.
3053  if(!FileInfo->Dloc) return STATUS_SUCCESS;
3054 
3055  if(FileInfo->RefCount ||
3056  FileInfo->OpenCount ||
3057  !(FileInfo->Dloc->FELoc.Mapping)) return STATUS_SUCCESS;
3058 // ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
3059  PartNum = UDFGetPartNumByPhysLba(Vcb, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
3060  if(PartNum == (uint32)-1) {
3061  UDFPrint((" Is DELETED ?\n"));
3062  if(DirInfo) {
3063  PartNum = UDFGetPartNumByPhysLba(Vcb, DirInfo->Dloc->FELoc.Mapping[0].extLocation);
3064  } else {
3065  BrutePoint();
3066  }
3067  }
3068 #ifdef UDF_CHECK_DISK_ALLOCATION
3069  if( FileInfo->Fcb &&
3070  UDFGetFreeBit(((uint32*)(Vcb->FSBM_Bitmap)), FileInfo->Dloc->FELoc.Mapping[0].extLocation)) {
3071 
3072  //ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
3073  if(UDFIsAStreamDir(FileInfo)) {
3074  if(!UDFIsSDirDeleted(FileInfo)) {
3075  UDFPrint((" Not DELETED SDir\n"));
3076  BrutePoint();
3077  }
3078  ASSERT(!FileInfo->Dloc->FELoc.Modified);
3079  } else
3080  if(!FileInfo->FileIdent ||
3081  !(FileInfo->FileIdent->fileCharacteristics & FILE_DELETED)) {
3082  if(!FileInfo->FileIdent) {
3083  AdPrint((" No FileIdent\n"));
3084  }
3085  if(FileInfo->FileIdent &&
3086  !(FileInfo->FileIdent->fileCharacteristics & FILE_DELETED))
3087  AdPrint((" Not DELETED\n"));
3088  ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
3089  AdPrint(("Flushing to Discarded block %x\n", FileInfo->Dloc->FELoc.Mapping[0].extLocation));
3090  BrutePoint();
3091  } else {
3092  UDFCheckSpaceAllocation(Vcb, 0, FileInfo->Dloc->DataLoc.Mapping, AS_FREE); // check if free
3093  UDFCheckSpaceAllocation(Vcb, 0, FileInfo->Dloc->FELoc.Mapping, AS_FREE); // check if free
3094  }
3095  } else {
3096  if(!FileInfo->Dloc->FELoc.Mapping[0].extLocation ||
3097  UDFGetFreeBit(((uint32*)(Vcb->FSBM_Bitmap)), FileInfo->Dloc->FELoc.Mapping[0].extLocation)) {
3098  UDFCheckSpaceAllocation(Vcb, 0, FileInfo->Dloc->DataLoc.Mapping, AS_FREE); // check if free
3099  } else {
3100  UDFCheckSpaceAllocation(Vcb, 0, FileInfo->Dloc->DataLoc.Mapping, AS_USED); // check if used
3101  }
3102  }
3103 #endif // UDF_CHECK_DISK_ALLOCATION
3104  // check if we should update parentICBLocation
3105  if( !((icbtag*)(FileInfo->Dloc->FileEntry+1))->parentICBLocation.logicalBlockNum &&
3106  !((icbtag*)(FileInfo->Dloc->FileEntry+1))->parentICBLocation.partitionReferenceNum &&
3107  DirInfo &&
3108  !Vcb->CDR_Mode &&
3109  Vcb->Modified &&
3111  ASSERT(DirInfo->Dloc->FELoc.Mapping[0].extLocation);
3112  ((icbtag*)(FileInfo->Dloc->FileEntry+1))->parentICBLocation.logicalBlockNum =
3113  UDFPhysLbaToPart(Vcb, PartNum, DirInfo->Dloc->FELoc.Mapping[0].extLocation);
3114  ((icbtag*)(FileInfo->Dloc->FileEntry+1))->parentICBLocation.partitionReferenceNum = (uint16)PartNum;
3115  FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
3116  }
3117 
3118  // we needn't flushing FE & Allocs untill all links are closed...
3119  if(!FileInfo->Dloc->LinkRefCount) {
3120 
3121  // flush FE and pre-allocation charge for directories
3122  if(FileInfo->Dloc &&
3123  FileInfo->Dloc->DirIndex) {
3124 
3125  UDFFlushFESpace(Vcb, FileInfo->Dloc);
3126  if(FileInfo->Dloc->DataLoc.Flags & EXTENT_FLAG_PREALLOCATED) {
3127  FileInfo->Dloc->DataLoc.Flags |= EXTENT_FLAG_CUT_PREALLOCATED;
3128  status = UDFResizeExtent(Vcb, PartNum, UDFGetFileSize(FileInfo), FALSE, &(FileInfo->Dloc->DataLoc));
3129  FileInfo->Dloc->DataLoc.Flags &= ~(EXTENT_FLAG_PREALLOCATED | EXTENT_FLAG_CUT_PREALLOCATED);
3130  if(OS_SUCCESS(status)) {
3131  AdPrint(("Dir pre-alloc truncated (Close)\n"));
3132  FileInfo->Dloc->DataLoc.Modified = TRUE;
3133  }
3134  }
3135  }
3136 
3137  if(!OS_SUCCESS(status = UDFFlushFE(Vcb, FileInfo, PartNum))) {
3138  UDFPrint(("Error flushing FE\n"));
3139 //flush_recovery:
3140  BrutePoint();
3141  if(FileInfo->Index >= 2) {
3142  PDIR_INDEX_ITEM DirNdx;
3144  if(DirNdx) {
3145  UDFPrint(("Recovery: mark as deleted & flush FI\n"));
3146  DirNdx->FI_Flags |= UDF_FI_FLAG_FI_MODIFIED;
3147  DirNdx->FileCharacteristics |= FILE_DELETED;
3148  FileInfo->FileIdent->fileCharacteristics |= FILE_DELETED;
3149  UDFFlushFI(Vcb, FileInfo, PartNum);
3150  }
3151  }
3152  return status;
3153  }
3154  }
3155  // ... but FI must be updated (if any)
3156  if(!OS_SUCCESS(status = UDFFlushFI(Vcb, FileInfo, PartNum))) {
3157  UDFPrint(("Error flushing FI\n"));
3158  return status;
3159  }
3160 #ifdef UDF_DBG
3161 // ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
3162  if((FileInfo->Dloc->FileEntry->descVersion != 2) &&
3163  (FileInfo->Dloc->FileEntry->descVersion != 3)) {
3164  ASSERT(UDFGetFreeBit(((uint32*)(Vcb->FSBM_Bitmap)), FileInfo->Dloc->FELoc.Mapping[0].extLocation));
3165  }
3166 #endif // UDF_DBG
3167  return STATUS_SUCCESS;
3168 } // end UDFCloseFile__()
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
unsigned int uint32
Definition: types.h:32
OSSTATUS UDFResizeExtent(IN PVCB Vcb, IN uint32 PartNum, IN int64 Length, IN BOOLEAN AlwaysInIcb, OUT PEXTENT_INFO ExtInfo)
Definition: extent.cpp:2235
OSSTATUS UDFFlushFI(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
Definition: udf_info.cpp:4051
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
uint32 extLocation
Definition: ecma_167.h:129
#define UDFCheckSpaceAllocation(Vcb, FileInfo, Map, asXXX)
Definition: udf_info.h:281
int64 UDFGetFileSize(IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1236
PUDF_DATALOC_INFO Dloc
Definition: udf_rel.h:367
#define UDF_FI_FLAG_FI_MODIFIED
FileIdent was modified & should be flushed.
Definition: udf_rel.h:217
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:1092
#define OSSTATUS
Definition: env_spec_w32.h:57
#define UDFInterlockedDecrement(addr)
Definition: env_spec_w32.h:677
EXTENT_INFO FELoc
Definition: udf_rel.h:279
uint8 FileCharacteristics
Definition: udf_rel.h:182
#define FILE_DELETED
Definition: ecma_167.h:440
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
#define UDFIsAStreamDir(FI)
Definition: udf_info.h:998
uint32 OpenCount
Definition: udf_rel.h:407
#define Vcb
Definition: cdprocs.h:1425
#define BrutePoint()
Definition: env_spec_w32.h:504
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
#define UDFIsSDirDeleted(FI)
Definition: udf_info.h:1004
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
#define AS_USED
Definition: udf_info.h:327
OSSTATUS UDFFlushFE(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
Definition: udf_info.cpp:3864
#define AS_FREE
Definition: udf_info.h:326
unsigned short uint16
Definition: types.h:30
#define EXTENT_FLAG_CUT_PREALLOCATED
Definition: udf_rel.h:80
void UDFFlushFESpace(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc, IN BOOLEAN Discard)
Definition: extent.cpp:1776
#define UDFGetFreeBit(arr, bit)
Definition: udf_info.h:1199
#define EXTENT_FLAG_PREALLOCATED
Definition: udf_rel.h:79
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
Definition: alloc.cpp:201
uint8 FI_Flags
Definition: udf_rel.h:199
return STATUS_SUCCESS
Definition: btrfs.c:2966
signed int * PLONG
Definition: retypes.h:5
static SERVICE_STATUS status
Definition: service.c:31
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
uint16 UDFGetFileLinkCount(IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1355
Definition: ps.c:97

Referenced by UDFCleanUpFcbChain(), UDFCloseFileInfoChain(), UDFCloseResidual(), UDFCommonCreate(), UDFCompareVcb(), UDFCompleteMount(), UDFCreateFile__(), UDFCreateStreamDir__(), UDFHardLinkFile__(), UDFLoadVAT(), UDFMarkStreamsForDeletion(), UDFReadSecurity(), UDFRename(), UDFRenameMoveFile__(), UDFSetEOF(), UDFUnlinkAllFilesInDir(), UDFUnlinkFile__(), and UDFWriteSecurity().

◆ UDFCompareFileInfo()

BOOLEAN UDFCompareFileInfo ( IN PUDF_FILE_INFO  f1,
IN PUDF_FILE_INFO  f2 
)

Definition at line 4218 of file udf_info.cpp.

4222 {
4223  uint_di i;
4224  PDIR_INDEX_HDR hDirIndex1;
4225  PDIR_INDEX_HDR hDirIndex2;
4226  PDIR_INDEX_ITEM DirIndex1;
4227  PDIR_INDEX_ITEM DirIndex2;
4228 
4229  if(!f1 || !f2) return FALSE;
4230  if(f1->Dloc->FileEntryLen != f2->Dloc->FileEntryLen) return FALSE;
4231 // if(f1->FileIdentLen != f2->FileIdentLen) return FALSE;
4232 /* if(f1->Dloc->DirIndex && !f2->Dloc->DirIndex) return FALSE;
4233  if(f2->Dloc->DirIndex && !f1->Dloc->DirIndex) return FALSE;
4234  if((f1->Dloc->DirIndex) &&
4235  (f1->Dloc->DirIndex->LastFrameCount != f2->Dloc->DirIndex->LastFrameCount)) return FALSE;*/
4236  if(f1->Index != f2->Index) return FALSE;
4237  if(!(f1->Dloc->DataLoc.Mapping)) return FALSE;
4238  if(!(f2->Dloc->DataLoc.Mapping)) return FALSE;
4239  if(f1->Dloc->DataLoc.Mapping[0].extLocation != f2->Dloc->DataLoc.Mapping[0].extLocation) return FALSE;
4240  if(f1->Dloc->DataLoc.Mapping[0].extLength != f2->Dloc->DataLoc.Mapping[0].extLength) return FALSE;
4241 // if(f1-> != f2->) return FALSE;
4242 // if(f1-> != f2->) return FALSE;
4243 // if(f1-> != f2->) return FALSE;
4244  if(!(f1->Dloc->FileEntry)) return FALSE;
4245  if(!(f2->Dloc->FileEntry)) return FALSE;
4246  if(RtlCompareMemory(f1->Dloc->FileEntry, f2->Dloc->FileEntry, f2->Dloc->FileEntryLen) != f2->Dloc->FileEntryLen)
4247  return FALSE;
4248  if(!(hDirIndex1 = f1->Dloc->DirIndex)) return FALSE;
4249  if(!(hDirIndex2 = f2->Dloc->DirIndex)) return FALSE;
4250 
4251  for(i=2; (DirIndex1 = UDFDirIndex(hDirIndex1,i)) &&
4252  (DirIndex2 = UDFDirIndex(hDirIndex2,i)); i++) {
4253  if( DirIndex1->FName.Buffer &&
4254  !DirIndex2->FName.Buffer)
4255  return FALSE;
4256  if( DirIndex2->FName.Buffer &&
4257  !DirIndex1->FName.Buffer)
4258  return FALSE;
4259  if(!DirIndex2->FName.Buffer &&
4260  !DirIndex1->FName.Buffer)
4261  continue;
4262  if(RtlCompareUnicodeString(&(DirIndex1->FName),
4263  &(DirIndex2->FName),FALSE)) {
4264  return FALSE;
4265  }
4266 // if(DirIndex1[i].FileEntry != DirIndex2[i].FileEntry)
4267 // return FALSE;
4268  if(RtlCompareMemory(&(DirIndex1->FileEntryLoc),
4269  &(DirIndex2->FileEntryLoc), sizeof(lb_addr)) != sizeof(lb_addr))
4270  return FALSE;
4271  }
4272 
4273  return TRUE;
4274 } // end UDFCompareFileInfo()
UNICODE_STRING FName
Definition: udf_rel.h:173
#define TRUE
Definition: types.h:120
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
lb_addr FileEntryLoc
Definition: udf_rel.h:178
uint32 uint_di
Definition: udf_rel.h:29
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
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define f1(x, y, z)
Definition: sha1.c:30
int f2(S1 &, S2 &)
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

Referenced by UDFCompareVcb().

◆ UDFCompressUnicode()

void __fastcall UDFCompressUnicode ( IN PUNICODE_STRING  UName,
IN OUT uint8 **  _CS0,
IN OUT PSIZE_T  Length 
)

Definition at line 240 of file udf_info.cpp.

245 {
246  uint8* CS0;
247  uint8 compID;
248  uint16 unicodeIndex;
249  uint32 i, len;
250  PWCHAR Buff;
251 
252  len = (UName->Length) / sizeof(WCHAR);
253  compID = (!len) ? 0 : UDF_COMP_ID_8;
254  // check for uncompressable characters
255  Buff = UName->Buffer;
256  for(i=0; i<len; i++, Buff++) {
257  if((*Buff) & 0xff00) {
258  compID = UDF_COMP_ID_16;
259  break;
260  }
261  }
262 
263  CS0 = (uint8*)MyAllocatePool__(NonPagedPool, *Length = (((compID==UDF_COMP_ID_8) ? 1 : 2)*len + 1) );
264  if(!CS0) return;
265 
266  CS0[0] = compID;
267  *_CS0 = CS0;
268  // init loop
269  CS0++;
270  unicodeIndex = 0;
271  Buff = UName->Buffer;
272  if(compID == UDF_COMP_ID_16) {
273  // Loop through all the bytes.
274  while (unicodeIndex < len) {
275  // Move the 2nd byte to the low bits of the compressed unicode char.
276  *CS0 = (uint8)((*Buff) >> 8);
277  CS0++;
278  *CS0 = (uint8)(*Buff);
279  CS0++;
280  Buff++;
281  unicodeIndex++;
282  }
283  } else {
284  // Loop through all the bytes.
285  while (unicodeIndex < len) {
286  *CS0 = (uint8)(*Buff);
287  CS0++;
288  Buff++;
289  unicodeIndex++;
290  }
291  }
292 } // end UDFCompressUnicode()
unsigned int uint32
Definition: types.h:32
uint16_t * PWCHAR
Definition: typedefs.h:54
#define UDF_COMP_ID_8
Definition: ecma_167.h:22
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 MyAllocatePool__(type, size)
Definition: mem_tools.h:149
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char uint8
Definition: types.h:28
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
GLenum GLsizei len
Definition: glext.h:6722
#define UDF_COMP_ID_16
Definition: ecma_167.h:23
unsigned short uint16
Definition: types.h:30

Referenced by UDFBuildFileIdent(), UDFRenameMoveFile__(), and UDFSetDstring().

◆ UDFConvertFEToExtended()

OSSTATUS UDFConvertFEToExtended ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo 
)

Definition at line 5458 of file udf_info.cpp.

5462 {
5463  PEXTENDED_FILE_ENTRY ExFileEntry;
5464  PFILE_ENTRY FileEntry;
5466  OSSTATUS status;
5467  SIZE_T ReadBytes;
5468 
5469  if(!FileInfo) return STATUS_INVALID_PARAMETER;
5471  if(FileInfo->Dloc->FileEntry->tagIdent == TID_EXTENDED_FILE_ENTRY) return STATUS_SUCCESS;
5472  if(FileInfo->Dloc->FileEntry->tagIdent != TID_FILE_ENTRY) return STATUS_INVALID_PARAMETER;
5473 
5474 /* if(!OS_SUCCESS(status = UDFFlushFile__(Vcb, FileInfo)))
5475  return status;*/
5476 
5477  Length = FileInfo->Dloc->FileEntryLen;
5478  NewLength = Length - sizeof(FILE_ENTRY) + sizeof(EXTENDED_FILE_ENTRY);
5480  if(!ExFileEntry) return STATUS_INSUFFICIENT_RESOURCES;
5481  FileEntry = (PFILE_ENTRY)(FileInfo->Dloc->FileEntry);
5482  RtlZeroMemory(ExFileEntry, NewLength);
5483 
5484  ExFileEntry->descTag.tagIdent = TID_EXTENDED_FILE_ENTRY;
5485  ExFileEntry->icbTag = FileEntry->icbTag;
5486  ExFileEntry->uid = FileEntry->uid;
5487  ExFileEntry->gid = FileEntry->gid;
5488  ExFileEntry->permissions = FileEntry->permissions;
5489  ExFileEntry->fileLinkCount = FileEntry->fileLinkCount;
5490  ExFileEntry->recordFormat = FileEntry->recordFormat;
5491  ExFileEntry->recordDisplayAttr = FileEntry->recordDisplayAttr;
5492  ExFileEntry->recordLength = FileEntry->recordLength;
5493  ExFileEntry->informationLength = FileEntry->informationLength;
5494  ExFileEntry->logicalBlocksRecorded = FileEntry->logicalBlocksRecorded;
5495  ExFileEntry->accessTime = FileEntry->accessTime;
5496  ExFileEntry->modificationTime = FileEntry->modificationTime;
5497  ExFileEntry->attrTime = FileEntry->attrTime;
5498  ExFileEntry->checkpoint = FileEntry->checkpoint;
5499  ExFileEntry->extendedAttrICB = FileEntry->extendedAttrICB;
5500  ExFileEntry->impIdent = FileEntry->impIdent;
5501  ExFileEntry->uniqueID = FileEntry->uniqueID;
5502  ExFileEntry->lengthExtendedAttr = FileEntry->lengthExtendedAttr;
5503  ExFileEntry->lengthAllocDescs = FileEntry->lengthAllocDescs;
5504  RtlCopyMemory(ExFileEntry+1, FileEntry+1, FileEntry->lengthExtendedAttr);
5505  RtlCopyMemory((int8*)(ExFileEntry+1)+FileEntry->lengthExtendedAttr, (int8*)(ExFileEntry+1)+FileEntry->lengthExtendedAttr, FileEntry->lengthAllocDescs);
5506 
5507  if((((PFILE_ENTRY)(FileInfo->Dloc->FileEntry))->icbTag.flags & ICB_FLAG_ALLOC_MASK) == ICB_FLAG_AD_IN_ICB) {
5508 
5509  if((l = (uint32)(FileInfo->Dloc->DataLoc.Length))) {
5510 
5511  int8* tmp_buff = (int8*)MyAllocatePool__(NonPagedPool, l);
5512  if(!tmp_buff) {
5513  MyFreePool__(ExFileEntry);
5515  }
5516  if(!OS_SUCCESS(status = UDFReadFile__(Vcb, FileInfo, 0, l, FALSE, tmp_buff, &ReadBytes)) ||
5518  MyFreePool__(ExFileEntry);
5519  MyFreePool__(tmp_buff);
5520  return status;
5521  }
5522  FileInfo->Dloc->FELoc.Length =
5523  FileInfo->Dloc->DataLoc.Offset = NewLength;
5524  FileInfo->Dloc->FELoc.Modified =
5525  FileInfo->Dloc->DataLoc.Modified = TRUE;
5526  MyFreePool__(FileInfo->Dloc->FileEntry);
5527  FileInfo->Dloc->FileEntry = (tag*)ExFileEntry;
5529  !OS_SUCCESS(status = UDFWriteFile__(Vcb, FileInfo, 0, l, FALSE, tmp_buff, &ReadBytes)) ) {
5530  MyFreePool__(ExFileEntry);
5531  MyFreePool__(tmp_buff);
5532  return status;
5533  }
5534  MyFreePool__(tmp_buff);
5535  } else {
5536  FileInfo->Dloc->FELoc.Length =
5537  FileInfo->Dloc->DataLoc.Offset = NewLength;
5538  FileInfo->Dloc->FELoc.Modified =
5539  FileInfo->Dloc->DataLoc.Modified = TRUE;
5540  MyFreePool__(FileInfo->Dloc->FileEntry);
5541  FileInfo->Dloc->FileEntry = (tag*)ExFileEntry;
5542  }
5543  } else {
5544  FileInfo->Dloc->FELoc.Length =
5545  FileInfo->Dloc->AllocLoc.Offset = NewLength;
5546  FileInfo->Dloc->FELoc.Modified =
5547  FileInfo->Dloc->AllocLoc.Modified = TRUE;
5548  MyFreePool__(FileInfo->Dloc->FileEntry);
5549  FileInfo->Dloc->FileEntry = (tag*)ExFileEntry;
5550  }
5551  FileInfo->Dloc->FileEntryLen = NewLength;
5552  FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
5553  if(Vcb->minUDFReadRev < 0x0200)
5554  Vcb->minUDFReadRev = 0x0200;
5555  return STATUS_SUCCESS;
5556 } // end UDFConvertFEToExtended()
uint16 tagIdent
Definition: ecma_167.h:139
long_ad extendedAttrICB
Definition: ecma_167.h:529
timestamp accessTime
Definition: ecma_167.h:525
uint32 gid
Definition: ecma_167.h:517
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
timestamp attrTime
Definition: ecma_167.h:527
uint32 lengthAllocDescs
Definition: ecma_167.h:766
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint64 uniqueID
Definition: ecma_167.h:764
uint32 lengthExtendedAttr
Definition: ecma_167.h:765
unsigned int uint32
Definition: types.h:32
uint8 recordDisplayAttr
Definition: ecma_167.h:750
uint16 fileLinkCount
Definition: ecma_167.h:519
struct _FILE_ENTRY * PFILE_ENTRY
timestamp modificationTime
Definition: ecma_167.h:756
Definition: ecma_167.h:138
uint32 uid
Definition: ecma_167.h:745
uint64 logicalBlocksRecorded
Definition: ecma_167.h:524
timestamp accessTime
Definition: ecma_167.h:755
static USHORT USHORT * NewLength
#define MEM_XFE_TAG
Definition: udf_rel.h:487
#define TID_EXTENDED_FILE_ENTRY
Definition: ecma_167.h:175
EntityID impIdent
Definition: ecma_167.h:763
uint64 uniqueID
Definition: ecma_167.h:531
uint32 checkpoint
Definition: ecma_167.h:528
#define OSSTATUS
Definition: env_spec_w32.h:57
uint64 informationLength
Definition: ecma_167.h:752
uint32 permissions
Definition: ecma_167.h:518
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
r l[0]
Definition: byte_order.h:167
#define ICB_FLAG_AD_IN_ICB
Definition: ecma_167.h:496
uint32 recordLength
Definition: ecma_167.h:522
icbtag icbTag
Definition: ecma_167.h:744
uint16 fileLinkCount
Definition: ecma_167.h:748
Definition: ecma_167.h:742
uint8 recordFormat
Definition: ecma_167.h:749
timestamp attrTime
Definition: ecma_167.h:758
uint64 informationLength
Definition: ecma_167.h:523
uint8 recordDisplayAttr
Definition: ecma_167.h:521
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
uint32 lengthExtendedAttr
Definition: ecma_167.h:533
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
tag descTag
Definition: ecma_167.h:743
Definition: ecma_167.h:513
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
uint64 logicalBlocksRecorded
Definition: ecma_167.h:754
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
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
uint32 lengthAllocDescs
Definition: ecma_167.h:534
uint32 gid
Definition: ecma_167.h:746
uint32 uid
Definition: ecma_167.h:516
#define MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
__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
uint32 checkpoint
Definition: ecma_167.h:759
ULONG_PTR SIZE_T
Definition: typedefs.h:78
icbtag icbTag
Definition: ecma_167.h:515
long_ad extendedAttrICB
Definition: ecma_167.h:761
OSSTATUS UDFResizeFile__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
Definition: udf_info.cpp:3468
struct _EXTENDED_FILE_ENTRY * PEXTENDED_FILE_ENTRY
uint32 recordLength
Definition: ecma_167.h:751
EntityID impIdent
Definition: ecma_167.h:530
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
uint8 recordFormat
Definition: ecma_167.h:520
#define TID_FILE_ENTRY
Definition: ecma_167.h:170
timestamp modificationTime
Definition: ecma_167.h:526
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
uint32 permissions
Definition: ecma_167.h:747
#define ICB_FLAG_ALLOC_MASK
Definition: ecma_167.h:480
char int8
Definition: platform.h:10
struct _FILE_ENTRY FILE_ENTRY
Definition: ps.c:97

Referenced by UDFCreateStreamDir__().

◆ UDFConvertFEToNonInICB()

OSSTATUS UDFConvertFEToNonInICB ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo,
IN uint8  NewAllocMode 
)

Definition at line 5358 of file udf_info.cpp.

5363 {
5364  OSSTATUS status;
5365  int8* OldInIcb = NULL;
5366  uint32 OldLen;
5368  SIZE_T ReadBytes;
5369  SIZE_T _WrittenBytes;
5370  PUDF_DATALOC_INFO Dloc;
5371 
5372 // ASSERT(FileInfo->RefCount >= 1);
5373 
5374  Dloc = FileInfo->Dloc;
5375  ASSERT(Dloc->FELoc.Mapping[0].extLocation);
5377 
5378  if(NewAllocMode == ICB_FLAG_AD_DEFAULT_ALLOC_MODE) {
5379  NewAllocMode = (uint8)(Vcb->DefaultAllocMode);
5380  }
5381  // we do not support recording of extended AD now
5382  if(NewAllocMode != ICB_FLAG_AD_SHORT &&
5383  NewAllocMode != ICB_FLAG_AD_LONG)
5384  return STATUS_INVALID_PARAMETER;
5385  if(!Dloc->DataLoc.Offset || !Dloc->DataLoc.Length)
5386  return STATUS_SUCCESS;
5387  ASSERT(!Dloc->AllocLoc.Mapping);
5388  // read in-icb data. it'll be replaced after resize
5389  OldInIcb = (int8*)MyAllocatePool__(NonPagedPool, (uint32)(Dloc->DataLoc.Length));
5390  if(!OldInIcb)
5392  OldLen = (uint32)(Dloc->DataLoc.Length);
5393  status = UDFReadExtent(Vcb, &(Dloc->DataLoc), 0, OldLen, FALSE, OldInIcb, &ReadBytes);
5394  if(!OS_SUCCESS(status)) {
5395  MyFreePool__(OldInIcb);
5396  return status;
5397  }
5398 /* if(!Dloc->AllocLoc.Mapping) {
5399  Dloc->AllocLoc.Mapping = (PEXTENT_MAP)MyAllocatePool__(NonPagedPool, sizeof(EXTENT_MAP)*2);
5400  if(!Dloc->AllocLoc.Mapping) {
5401  MyFreePool__(OldInIcb);
5402  return STATUS_INSUFFICIENT_RESOURCES;
5403  }
5404  }
5405  // init Alloc mode
5406  if((((PFILE_ENTRY)(Dloc->FileEntry))->icbTag.flags & ICB_FLAG_ALLOC_MASK) == ICB_FLAG_AD_IN_ICB) {
5407  ((PFILE_ENTRY)(Dloc->FileEntry))->icbTag.flags &= ~ICB_FLAG_ALLOC_MASK;
5408  ((PFILE_ENTRY)(Dloc->FileEntry))->icbTag.flags |= Vcb->DefaultAllocMode;
5409  } else {
5410  BrutePoint();
5411  }
5412  RtlZeroMemory(Dloc->AllocLoc.Mapping, sizeof(EXTENT_MAP)*2);
5413 // Dloc->AllocLoc.Mapping[0].extLocation = 0;
5414  Dloc->AllocLoc.Mapping[0].extLength = Vcb->LBlockSize | EXTENT_NOT_RECORDED_NOT_ALLOCATED;
5415 // Dloc->AllocLoc.Mapping[1].extLocation = 0;
5416 // Dloc->AllocLoc.Mapping[1].extLength = 0;
5417 */
5418 
5419  // grow extent in order to force space allocation
5420  status = UDFResizeExtent(Vcb, PartNum, Vcb->LBlockSize, FALSE, &Dloc->DataLoc);
5421  if(!OS_SUCCESS(status)) {
5422  MyFreePool__(OldInIcb);
5423  return status;
5424  }
5425 
5426  // set Alloc mode
5427  if((((PFILE_ENTRY)(Dloc->FileEntry))->icbTag.flags & ICB_FLAG_ALLOC_MASK) == ICB_FLAG_AD_IN_ICB) {
5428  ((PFILE_ENTRY)(Dloc->FileEntry))->icbTag.flags &= ~ICB_FLAG_ALLOC_MASK;
5429  ((PFILE_ENTRY)(Dloc->FileEntry))->icbTag.flags |= NewAllocMode;
5430  } else {
5431  BrutePoint();
5432  }
5433 
5434  // revert to initial extent size. This will not cause NonInICB->InICB transform
5435  status = UDFResizeExtent(Vcb, PartNum, OldLen, FALSE, &Dloc->DataLoc);
5436  if(!OS_SUCCESS(status)) {
5437  MyFreePool__(OldInIcb);
5438  return status;
5439  }
5440 
5441  // replace data from ICB (if any) & free buffer
5442  status = UDFWriteExtent(Vcb, &(Dloc->DataLoc), 0, OldLen, FALSE, OldInIcb, &_WrittenBytes);
5443  MyFreePool__(OldInIcb);
5444  if(!OS_SUCCESS(status)) {
5445  return status;
5446  }
5447  // inform UdfInfo, that AllocDesc's must be rebuilt on flush/close
5448  Dloc->AllocLoc.Modified = TRUE;
5449  Dloc->DataLoc.Modified = TRUE;
5450  return STATUS_SUCCESS;
5451 } // end UDFConvertFEToNonInICB()
#define ICB_FLAG_AD_DEFAULT_ALLOC_MODE
Definition: udf_rel.h:506
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
EXTENT_INFO AllocLoc
Definition: udf_rel.h:274
BOOLEAN Modified
Definition: udf_rel.h:68
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
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned int uint32
Definition: types.h:32
OSSTATUS UDFResizeExtent(IN PVCB Vcb, IN uint32 PartNum, IN int64 Length, IN BOOLEAN AlwaysInIcb, OUT PEXTENT_INFO ExtInfo)
Definition: extent.cpp:2235
#define ICB_FLAG_AD_LONG
Definition: ecma_167.h:494
struct _FILE_ENTRY * PFILE_ENTRY
uint32 extLocation
Definition: ecma_167.h:129
int64 Length
Definition: udf_rel.h:67
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
#define OSSTATUS
Definition: env_spec_w32.h:57
#define ICB_FLAG_AD_SHORT
Definition: ecma_167.h:493
EXTENT_INFO FELoc
Definition: udf_rel.h:279
smooth NULL
Definition: ftsmooth.c:416
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
#define ICB_FLAG_AD_IN_ICB
Definition: ecma_167.h:496
EXTENT_INFO DataLoc
Definition: udf_rel.h:262
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define BrutePoint()
Definition: env_spec_w32.h:504
unsigned char uint8
Definition: types.h:28
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ecma_167.h:513
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
uint32 Offset
Definition: udf_rel.h:65
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:78
OSSTATUS UDFWriteExtent(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
Definition: extent.cpp:3186
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
Definition: alloc.cpp:201
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
#define ICB_FLAG_ALLOC_MASK
Definition: ecma_167.h:480
char int8
Definition: platform.h:10
Definition: ps.c:97

Referenced by UDFSetFileAllocModeFromICB().

◆ UDFCrc()

uint16 __fastcall UDFCrc ( IN uint8 Data,
IN SIZE_T  Size 
)

Definition at line 4527 of file udf_info.cpp.

4531 {
4532 #if defined(_X86_) && defined(_MSC_VER) && !defined(__clang__)
4533 // uint32 _Size = Size;
4534 
4535  __asm {
4536  push ebx
4537  push ecx
4538  push edx
4539  push esi
4540 
4541  mov esi,ecx
4542  mov ecx,edx
4543  xor eax,eax
4544 
4545  jecxz EO_CRC
4546 
4547  lea ebx,[CrcTable]
4548  xor edx,edx
4549 
4550 CRC_loop:
4551 
4552  mov dl,ah
4553  xor dl,[esi]
4554  mov ah,al
4555  mov al,dh
4556  xor ax,[word ptr ebx+edx*2]
4557  inc esi
4558  loop CRC_loop
4559 
4560 EO_CRC:
4561 
4562  pop esi
4563  pop edx
4564  pop ecx
4565  pop ebx
4566 
4567  ret
4568  }
4569 #else // NO X86 optimization , use generic C/C++
4570  uint16 Crc = 0;
4571  while (Size--)
4572  Crc = CrcTable[(Crc >> 8 ^ *Data++) & 0xff] ^ (Crc << 8);
4573  return Crc;
4574 #endif // _X86_
4575 
4576 } // end UDFCrc()
static void xor(unsigned char *dst, const unsigned char *a, const unsigned char *b, const int count)
Definition: crypt_des.c:251
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx eax jnz xchgl ecx incl TEMP esi
Definition: synth_sse3d.h:103
static calc_node_t * pop(void)
Definition: rpn_ieee.c:90
static PVOID ptr
Definition: dispmode.c:27
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 mm1 mm5 paddd mm0 paddd mm4 mm0 mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 mm1 paddd mm0 mm0 packssdw mm0 movd eax movw ax
Definition: synth_sse3d.h:171
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl eax
Definition: synth_sse3d.h:85
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl ebx
Definition: synth_sse3d.h:83
int ret
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned short uint16
Definition: types.h:30
const WCHAR * word
Definition: lex.c:78
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
static const uint16 CrcTable[256]
Definition: udf_info.cpp:51

Referenced by UDFDecompressUnicode(), UDFReadTagged(), and UDFSetUpTag().

◆ UDFCreateFile__()

OSSTATUS UDFCreateFile__ ( IN PVCB  Vcb,
IN BOOLEAN  IgnoreCase,
IN PUNICODE_STRING  _fn,
IN uint32  ExtAttrSz,
IN uint32  ImpUseLen,
IN BOOLEAN  Extended,
IN BOOLEAN  CreateNew,
IN OUT PUDF_FILE_INFO  DirInfo,
OUT PUDF_FILE_INFO _FileInfo 
)

Definition at line 2577 of file udf_info.cpp.

2589 {
2590  uint32 l, d;
2591  uint_di i, j;
2592  OSSTATUS status;
2593  LONG_AD FEicb;
2594  UDF_DIR_SCAN_CONTEXT ScanContext;
2595  PDIR_INDEX_HDR hDirNdx = DirInfo->Dloc->DirIndex;
2596  PDIR_INDEX_ITEM DirNdx;
2597  uint32 LBS = Vcb->LBlockSize;
2599  *_FileInfo = NULL;
2600  BOOLEAN undel = FALSE;
2601  SIZE_T ReadBytes;
2602 // BOOLEAN PackDir = FALSE;
2603  BOOLEAN FEAllocated = FALSE;
2604 
2605  ValidateFileInfo(DirInfo);
2606  *_FileInfo = NULL;
2607 
2608  ASSERT(DirInfo->Dloc->FELoc.Mapping[0].extLocation);
2609  uint32 PartNum = UDFGetPartNumByPhysLba(Vcb, DirInfo->Dloc->FELoc.Mapping[0].extLocation);
2610  if(!hDirNdx) return STATUS_NOT_A_DIRECTORY;
2611  i = 0;
2612 
2613  _SEH2_TRY {
2614 
2615  // check if exists
2616  status = UDFFindFile(Vcb, IgnoreCase, FALSE, _fn, DirInfo, &i);
2617  DirNdx = UDFDirIndex(hDirNdx,i);
2618  if(OS_SUCCESS(status)) {
2619  // file is a Cur(Parent)Dir
2621  // file deleted
2622  if(UDFIsDeleted(DirNdx)) {
2623  j=0;
2624  if(OS_SUCCESS(UDFFindFile(Vcb, IgnoreCase, TRUE, _fn, DirInfo, &j))) {
2625  i=j;
2626  DirNdx = UDFDirIndex(hDirNdx,i);
2627  goto CreateBothFound;
2628  }
2629  // we needn't allocating new FileIdent inside Dir stream
2630  // perform 'undel'
2631  if(DirNdx->FileInfo) {
2632  // BrutePoint();
2634  if(!OS_SUCCESS(status))
2636  } else {
2637  undel = TRUE;
2638  }
2639  // BrutePoint();
2640  goto CreateUndel;
2641  }
2642 CreateBothFound:
2643  // file already exists
2644  if(CreateNew) try_return (status = STATUS_ACCESS_DENIED);
2645  // try to open it
2646  BrutePoint();
2647  status = UDFOpenFile__(Vcb, IgnoreCase, TRUE, _fn, DirInfo, _FileInfo,&i);
2648  // *_FileInfo = FileInfo; // OpenFile__ has already done it, so update it...
2649  DirNdx = UDFDirIndex(hDirNdx,i);
2650  DirNdx->FI_Flags &= ~UDF_FI_FLAG_SYS_ATTR;
2651  FileInfo = *_FileInfo;
2652  if(!OS_SUCCESS(status)) {
2653  // :(( can't open....
2656  *_FileInfo = NULL;
2657  }
2658  BrutePoint();
2659  try_return (status);
2660  }
2661  // check if we can delete this file
2662  if(FileInfo->OpenCount || (FileInfo->RefCount > 1)) {
2663  BrutePoint();
2666  }
2667  BrutePoint();
2668  // remove DIRECTORY flag
2669  DirNdx->FileCharacteristics &= ~FILE_DIRECTORY;
2670  FileInfo->FileIdent->fileCharacteristics &= ~FILE_DIRECTORY;
2671  DirNdx->FI_Flags |= UDF_FI_FLAG_FI_MODIFIED;
2672  // truncate file size to ZERO
2674  if(!OS_SUCCESS(status)) {
2675  BrutePoint();
2677  }
2678  // set NORMAL flag
2679  FileInfo->FileIdent->fileCharacteristics = 0;
2680  DirNdx->FileCharacteristics = 0;
2681  // update DeletedFiles counter in Directory... (for PackDir)
2682  if(undel && OS_SUCCESS(status))
2683  hDirNdx->DelCount--;
2684  try_return (status);
2685  }
2686 
2687 CreateUndel:
2688 
2689  // allocate FileInfo
2691  *_FileInfo = FileInfo;
2692  if(!FileInfo)
2694  ImpUseLen = (ImpUseLen + 3) & ~((uint16)3);
2695 
2697  // init horizontal links
2698  FileInfo->NextLinkedFile =
2699  FileInfo->PrevLinkedFile = FileInfo;
2700  // allocate space for FileEntry
2701  if(!OS_SUCCESS(status =
2702  UDFBuildFileEntry(Vcb, DirInfo, FileInfo, PartNum, ICB_FLAG_AD_IN_ICB, ExtAttrSz, Extended) )) {
2703  BrutePoint();
2704  try_return (status);
2705  }
2706  FEAllocated = TRUE;
2707  FEicb.extLength = LBS;
2708  ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
2709  FEicb.extLocation.logicalBlockNum = UDFPhysLbaToPart(Vcb, PartNum, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
2710  FEicb.extLocation.partitionReferenceNum = (uint16)PartNum;
2711  RtlZeroMemory(&(FEicb.impUse), sizeof(FEicb.impUse));
2712 
2713  if(!undel) {
2714  // build FileIdent
2715  if(!OS_SUCCESS(status =
2716  UDFBuildFileIdent(Vcb, _fn, &FEicb, ImpUseLen,
2717  &(FileInfo->FileIdent), &(FileInfo->FileIdentLen)) ))
2718  try_return (status);
2719  } else {
2720  // read FileIdent
2723  FileInfo->FileIdentLen = DirNdx->Length;
2724  if(!OS_SUCCESS(status = UDFReadExtent(Vcb, &(DirInfo->Dloc->DataLoc), DirNdx->Offset,
2725  DirNdx->Length, FALSE, (int8*)(FileInfo->FileIdent), &ReadBytes) ))
2726  try_return (status);
2727  FileInfo->FileIdent->fileCharacteristics = 0;
2728  FileInfo->FileIdent->icb = FEicb;
2729  ImpUseLen = FileInfo->FileIdent->lengthOfImpUse;
2730  DirNdx->FileCharacteristics = 0;
2731  }
2732  // init 'parentICBLocation' & so on in FE
2733  ((icbtag*)(FileInfo->Dloc->FileEntry+1))->parentICBLocation.logicalBlockNum =
2734  UDFPhysLbaToPart(Vcb, PartNum, DirInfo->Dloc->FELoc.Mapping[0].extLocation);
2735  ((icbtag*)(FileInfo->Dloc->FileEntry+1))->parentICBLocation.partitionReferenceNum = (uint16)PartNum;
2736  // ((icbtag*)(FileInfo->Dloc->FileEntry+1))->strategyType = 4;
2737  // ((icbtag*)(FileInfo->Dloc->FileEntry+1))->numEntries = 1;
2738  // try to find suitable unused FileIdent in DirIndex
2739  l = FileInfo->FileIdentLen;
2740  if(undel) goto CrF__2;
2741 #ifndef UDF_LIMIT_DIR_SIZE
2742  if(Vcb->CDR_Mode) {
2743 #endif // UDF_LIMIT_DIR_SIZE
2744  // search for suitable unused entry
2745  if(UDFDirIndexInitScan(DirInfo, &ScanContext, 2)) {
2746  while((DirNdx = UDFDirIndexScan(&ScanContext, NULL))) {
2747  if((DirNdx->Length == l) && UDFIsDeleted(DirNdx) &&
2748  !DirNdx->FileInfo ) {
2749  // free unicode-buffer with old name
2750  if(DirNdx->FName.Buffer) {
2751  MyFreePool__(DirNdx->FName.Buffer);
2752  DirNdx->FName.Buffer = NULL;
2753  }
2754  i = ScanContext.i;
2755  goto CrF__1;
2756  }
2757  }
2758  }
2759 #ifndef UDF_LIMIT_DIR_SIZE
2760  } else {
2761 #endif // UDF_LIMIT_DIR_SIZE
2762  i = UDFDirIndexGetLastIndex(hDirNdx); // 'i' points beyond EO DirIndex
2763 #ifndef UDF_LIMIT_DIR_SIZE
2764  }
2765 #endif // UDF_LIMIT_DIR_SIZE
2766 
2767  // append entry
2768  if(!OS_SUCCESS(status = UDFDirIndexGrow(&(DirInfo->Dloc->DirIndex), 1))) {
2769  try_return (status);
2770  }
2771 
2772  // init offset of new FileIdent in directory Data extent
2773  hDirNdx = DirInfo->Dloc->DirIndex;
2774  if(i-1) {
2775  DirNdx = UDFDirIndex(hDirNdx,i-1);
2776  UDFDirIndex(hDirNdx,i)->Offset = DirNdx->Offset + DirNdx->Length;
2777  DirNdx = UDFDirIndex(hDirNdx,i);
2778  } else {
2779  DirNdx = UDFDirIndex(hDirNdx,i);
2780  DirNdx->Offset = 0;
2781  }
2782  // new terminator is recorded by UDFDirIndexGrow()
2783  if( ((d = ((LBS - (DirNdx->Offset + l + DirInfo->Dloc->DataLoc.Offset)) & (LBS-1) )) < sizeof(FILE_IDENT_DESC)) &&
2784  d ) {
2785  // insufficient space at the end of last sector for
2786  // next FileIdent's tag. fill it with ImpUse data
2787 
2788  // generally, all data should be DWORD-aligned, but if it is not so
2789  // this opearation will help us to avoid glitches
2790  d = (d+3) & ~((uint32)3);
2791 
2792  uint32 IUl, FIl;
2793  if(!MyReallocPool__((int8*)(FileInfo->FileIdent), l,
2794  (int8**)&(FileInfo->FileIdent), (l+d+3) & ~((uint32)(3)) ))
2796  l += d;
2797  IUl = FileInfo->FileIdent->lengthOfImpUse;
2798  FIl = FileInfo->FileIdent->lengthFileIdent;
2799  // move filename to higher addr
2800  RtlMoveMemory(((int8*)(FileInfo->FileIdent+1))+IUl+d,
2801  ((int8*)(FileInfo->FileIdent+1))+IUl, FIl);
2802  RtlZeroMemory(((int8*)(FileInfo->FileIdent+1))+IUl, d);
2803  FileInfo->FileIdent->lengthOfImpUse += (uint16)d;
2804  FileInfo->FileIdentLen = l;
2805  }
2806  DirNdx->Length = l;
2807 CrF__1:
2808  // clone unicode string
2809  // it **<<MUST>>** be allocated with internal memory manager
2810  DirNdx->FName.Buffer = (PWCHAR)MyAllocatePoolTag__(UDF_FILENAME_MT, (DirNdx->FName.MaximumLength = _fn->Length + sizeof(WCHAR)), MEM_FNAMECPY_TAG);
2811  DirNdx->FName.Length = _fn->Length;
2812  if(!DirNdx->FName.Buffer)
2814  RtlCopyMemory(DirNdx->FName.Buffer, _fn->Buffer, _fn->Length);
2815  DirNdx->FName.Buffer[_fn->Length/sizeof(WCHAR)] = 0;
2816 CrF__2:
2817  DirNdx->FI_Flags |= UDFBuildHashEntry(Vcb, &(DirNdx->FName), &(DirNdx->hashes), HASH_ALL);
2818  // we get here immediately when 'undel' occured
2819  FileInfo->Index = i;
2820  DirNdx->FI_Flags |= UDF_FI_FLAG_FI_MODIFIED;
2821  DirNdx->FI_Flags &= ~UDF_FI_FLAG_SYS_ATTR;
2822  ASSERT(!DirNdx->FileInfo);
2823  DirNdx->FileInfo = FileInfo;
2824  DirNdx->FileEntryLoc = FEicb.extLocation;
2825  // mark file as 'deleted' for now
2827  FileInfo->FileIdent->fileCharacteristics |= FILE_DELETED;
2828  FileInfo->Dloc->DataLoc.Mapping = UDFExtentToMapping(&(FileInfo->Dloc->FELoc.Mapping[0]));
2829  if(!(FileInfo->Dloc->DataLoc.Mapping)) {
2830  UDFFlushFI(Vcb, FileInfo, PartNum);
2832  }
2833  FileInfo->Dloc->DataLoc.Length = 0;
2834  FileInfo->Dloc->DataLoc.Offset = FileInfo->Dloc->FileEntryLen;
2835  FileInfo->ParentFile = DirInfo;
2836  // init FileEntry
2839  UDFIncFileLinkCount(FileInfo); // increase to 1
2840  UDFUpdateCreateTime(Vcb, FileInfo);
2842  FileInfo->Dloc->FileEntry, Vcb->DefaultAttr);
2843  FileInfo->Dloc->DataLoc.Mapping[0].extLength &= UDF_EXTENT_LENGTH_MASK;
2844  FileInfo->Dloc->DataLoc.Modified = TRUE;
2845  FileInfo->Dloc->FELoc.Mapping[0].extLength &= UDF_EXTENT_LENGTH_MASK;
2846  // zero sector for FileEntry
2847  if(!Vcb->CDR_Mode) {
2848  status = UDFWriteData(Vcb, TRUE, ((int64)(FileInfo->Dloc->FELoc.Mapping[0].extLocation)) << Vcb->BlockSizeBits, LBS, FALSE, Vcb->ZBuffer, &ReadBytes);
2849  if(!OS_SUCCESS(status)) {
2850  UDFFlushFI(Vcb, FileInfo, PartNum);
2851  try_return (status);
2852  }
2853  }
2854 #if 0
2855  if((i >= 2) && (DirNdx->FName.Buffer[0] == L'.')) {
2856  BrutePoint();
2857  }
2858 #endif
2859 
2860 #ifdef UDF_CHECK_DISK_ALLOCATION
2861  if( /*FileInfo->Fcb &&*/
2862  UDFGetFreeBit(((uint32*)(Vcb->FSBM_Bitmap)), FileInfo->Dloc->FELoc.Mapping[0].extLocation)) {
2863 
2864  if(!FileInfo->FileIdent ||
2865  !(FileInfo->FileIdent->fileCharacteristics & FILE_DELETED)) {
2866  AdPrint(("Flushing to Discarded block %x\n", FileInfo->Dloc->FELoc.Mapping[0].extLocation));
2867  BrutePoint();
2868  }
2869  }
2870 #endif // UDF_CHECK_DISK_ALLOCATION
2871 
2872  // make FileIdent valid
2873  FileInfo->FileIdent->fileCharacteristics = 0;
2874  DirNdx->FileCharacteristics = 0;
2876  UDFFlushFE(Vcb, FileInfo, PartNum);
2877  if(undel)
2878  hDirNdx->DelCount--;
2879  UDFReleaseDloc(Vcb, FileInfo->Dloc);
2881 
2882  UDFCheckSpaceAllocation(Vcb, 0, FileInfo->Dloc->DataLoc.Mapping, AS_USED); // check if used
2883 
2885 
2886 try_exit: NOTHING;
2887 
2888  } _SEH2_FINALLY {
2889  if(!OS_SUCCESS(status)) {
2890  if(FEAllocated)
2891  UDFFreeFESpace(Vcb, DirInfo, &(FileInfo->Dloc->FELoc));
2892  }
2893  } _SEH2_END
2894  return status;
2895 
2896 } // end UDFCreateFile__()
OSSTATUS UDFDirIndexGrow(IN PDIR_INDEX_HDR *_hDirNdx, IN uint_di d)
Definition: dirtree.cpp:117
UNICODE_STRING FName
Definition: udf_rel.h:173
#define UDFReferenceFile__(fi)
Definition: udf_info.h:1043
struct _FILE_IDENT_DESC * PFILE_IDENT_DESC
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
uint8 UDFBuildHashEntry(IN PVCB Vcb, IN PUNICODE_STRING Name, OUT PHASH_ENTRY hashes, IN uint8 Mask)
Definition: dirtree.cpp:429
uint8 impUse[6]
Definition: ecma_167.h:376
USHORT MaximumLength
Definition: env_spec_w32.h:370
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
unsigned int uint32
Definition: types.h:32
OSSTATUS UDFWriteData(IN PVCB Vcb, IN BOOLEAN Translate, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
Definition: phys_lib.cpp:4141
ULONG MyReallocPool__(PCHAR addr, ULONG len, PCHAR *pnewaddr, ULONG newlen)
Definition: mem_tools.h:224
OSSTATUS UDFFlushFI(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
Definition: udf_info.cpp:4051
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
#define UDF_FILE_INFO_MT
Definition: udf_rel.h:338
#define UDFCheckSpaceAllocation(Vcb, FileInfo, Map, asXXX)
Definition: udf_info.h:281
lb_addr extLocation
Definition: ecma_167.h:375
uint16_t * PWCHAR
Definition: typedefs.h:54
#define UDF_FI_FLAG_FI_MODIFIED
FileIdent was modified & should be flushed.
Definition: udf_rel.h:217
#define MEM_FE_TAG
Definition: udf_rel.h:486
lb_addr FileEntryLoc
Definition: udf_rel.h:178
long long int64
Definition: platform.h:13
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32 uint_di
Definition: udf_rel.h:29
_SEH2_TRY
Definition: create.c:4250
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_FILENAME_MT
Definition: udf_rel.h:126
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
uint_di DelCount
Definition: udf_rel.h:139
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:1092
#define OSSTATUS
Definition: env_spec_w32.h:57
unsigned char BOOLEAN
uint8 FileCharacteristics
Definition: udf_rel.h:182
smooth NULL
Definition: ftsmooth.c:416
void UDFFreeFESpace(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN PEXTENT_INFO FEExtInfo)
Definition: extent.cpp:1725
#define FILE_DELETED
Definition: ecma_167.h:440
#define MEM_FID_TAG
Definition: udf_rel.h:488
OSSTATUS UDFPretendFileDeleted__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:5566
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
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
r l[0]
Definition: byte_order.h:167
#define ICB_FLAG_AD_IN_ICB
Definition: ecma_167.h:496
uint32 UDFCleanUpFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:2276
#define MEM_FNAMECPY_TAG
Definition: udf_rel.h:485
#define d
Definition: ke_i.h:81
__wchar_t WCHAR
Definition: xmlstorage.h:180
void UDFSetFileSize(IN PUDF_FILE_INFO FileInfo, IN int64 Size)
Definition: udf_info.cpp:1157
#define try_return(S)
Definition: cdprocs.h:2189
HASH_ENTRY hashes
Definition: udf_rel.h:206
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define UDFIncFileCounter(Vcb)
Definition: udf_info.h:614
#define BrutePoint()
Definition: env_spec_w32.h:504
OSSTATUS UDFOpenFile__(IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN BOOLEAN NotDeleted, IN PUNICODE_STRING fn, IN PUDF_FILE_INFO DirInfo, OUT PUDF_FILE_INFO *_FileInfo, IN uint_di *IndexToOpen)
Definition: udf_info.cpp:2004
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define UDFExtentToMapping(e)
Definition: udf_info.h:181
OSSTATUS UDFBuildFileIdent(IN PVCB Vcb, IN PUNICODE_STRING fn, IN PLONG_AD FileEntryIcb, IN uint32 ImpUseLen, OUT PFILE_IDENT_DESC *_FileId, OUT uint32 *FileIdLen)
Definition: udf_info.cpp:1107
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define FILE_DIRECTORY
Definition: ecma_167.h:439
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: dirtree.cpp:982
#define STATUS_CANNOT_DELETE
Definition: shellext.h:66
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
PDIR_INDEX_ITEM UDFDirIndexScan(PUDF_DIR_SCAN_CONTEXT Context, PUDF_FILE_INFO *_FileInfo)
Definition: dirtree.cpp:378
static const WCHAR L[]
Definition: oid.c:1250
#define UDFIncFileLinkCount(fi)
Definition: udf_info.h:580
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
#define NOTHING
Definition: env_spec_w32.h:461
#define AS_USED
Definition: udf_info.h:327
uint32 Offset
Definition: udf_rel.h:161
OSSTATUS UDFCloseFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:2994
struct _UDF_FILE_INFO * PUDF_FILE_INFO
#define MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
void UDFSetFileUID(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1456
OSSTATUS UDFFlushFE(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
Definition: udf_info.cpp:3864
ULONG_PTR SIZE_T
Definition: typedefs.h:78
VOID UDFAttributesToUDF(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry, IN ULONG NTAttr)
_SEH2_END
Definition: create.c:4424
#define IgnoreCase
Definition: cdprocs.h:464
unsigned short uint16
Definition: types.h:30
OSSTATUS UDFResizeFile__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
Definition: udf_info.cpp:3468
struct _UDF_FILE_INFO * FileInfo
Definition: udf_rel.h:204
_SEH2_FINALLY
Definition: create.c:4395
uint32 logicalBlockNum
Definition: ecma_167.h:362
uint32 Length
Definition: udf_rel.h:168
uint16 partitionReferenceNum
Definition: ecma_167.h:363
struct FileInfo FileInfo
BOOLEAN UDFDirIndexInitScan(IN PUDF_FILE_INFO DirInfo, OUT PUDF_DIR_SCAN_CONTEXT Context, IN uint_di Index)
Definition: dirtree.cpp:347
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define UDFGetFreeBit(arr, bit)
Definition: udf_info.h:1199
#define UDFDirIndexGetLastIndex(di)
Definition: udf_info.h:1122
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
Definition: alloc.cpp:201
OSSTATUS UDFReleaseDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1224
uint32 extLength
Definition: ecma_167.h:374
#define HASH_ALL
Definition: udf_info.h:78
uint8 FI_Flags
Definition: udf_rel.h:199
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
#define UDF_EXTENT_LENGTH_MASK
Definition: osta_misc.h:148
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
#define UDFIsDeleted(DirNdx)
Definition: udf_info.h:788
OSSTATUS UDFBuildFileEntry(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum, IN uint16 AllocMode, IN uint32 ExtAttrSz, IN BOOLEAN Extended)
Definition: udf_info.cpp:971
#define UDF_FI_FLAG_SYS_ATTR
Given entry of file list contains valid file attributes & times in NT-specific format.
Definition: udf_rel.h:219
char int8
Definition: platform.h:10
Definition: ps.c:97

Referenced by UDFCommonCreate(), UDFHardLinkFile__(), UDFRenameMoveFile__(), and UDFWriteSecurity().

◆ UDFCreateRootFile__()

OSSTATUS UDFCreateRootFile__ ( IN PVCB  Vcb,
IN uint32  PartNum,
IN uint32  ExtAttrSz,
IN uint32  ImpUseLen,
IN BOOLEAN  Extended,
OUT PUDF_FILE_INFO _FileInfo 
)

Definition at line 4827 of file udf_info.cpp.

4836 {
4837  OSSTATUS status;
4838  LONG_AD FEicb;
4840  *_FileInfo = NULL;
4841  SIZE_T ReadBytes;
4842 
4844  *_FileInfo = FileInfo;
4845  if(!FileInfo)
4847  ImpUseLen = (ImpUseLen + 3) & ~((uint16)3);
4848 
4850  // init horizontal links
4851  FileInfo->NextLinkedFile =
4852  FileInfo->PrevLinkedFile = FileInfo;
4853  // allocate space for FileEntry
4854  if(!OS_SUCCESS(status =
4855  UDFBuildFileEntry(Vcb, NULL, FileInfo, PartNum, ICB_FLAG_AD_IN_ICB, ExtAttrSz, Extended) ))
4856  return status;
4857  FEicb.extLength = Vcb->LBlockSize;
4858  FEicb.extLocation.logicalBlockNum = UDFPhysLbaToPart(Vcb, PartNum, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
4859  FEicb.extLocation.partitionReferenceNum = (uint16)PartNum;
4860  RtlZeroMemory(&(FEicb.impUse), sizeof(FEicb.impUse));
4861 
4862  FileInfo->Dloc->DataLoc.Mapping = UDFExtentToMapping(&(FileInfo->Dloc->FELoc.Mapping[0]));
4863  if(!(FileInfo->Dloc->DataLoc.Mapping)) return STATUS_INSUFFICIENT_RESOURCES;
4864  FileInfo->Dloc->DataLoc.Length = 0;
4865  FileInfo->Dloc->DataLoc.Offset = FileInfo->Dloc->FileEntryLen;
4866  // init FileEntry
4869  UDFIncFileLinkCount(FileInfo); // increase to 1
4870  UDFUpdateCreateTime(Vcb, FileInfo);
4871  // zero sector for FileEntry
4872  FileInfo->Dloc->DataLoc.Mapping[0].extLength &= UDF_EXTENT_LENGTH_MASK;
4873  FileInfo->Dloc->FELoc.Mapping[0].extLength &= UDF_EXTENT_LENGTH_MASK;
4874  status = UDFWriteData(Vcb, TRUE, ((int64)(FileInfo->Dloc->FELoc.Mapping[0].extLocation)) << Vcb->BlockSizeBits, Vcb->LBlockSize, FALSE, Vcb->ZBuffer, &ReadBytes);
4875  if(!OS_SUCCESS(status))
4876  return status;
4877 
4879  UDFReleaseDloc(Vcb, FileInfo->Dloc);
4880  return STATUS_SUCCESS;
4881 } // end UDFCreateRootFile__()
#define UDFReferenceFile__(fi)
Definition: udf_info.h:1043
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
uint8 impUse[6]
Definition: ecma_167.h:376
OSSTATUS UDFWriteData(IN PVCB Vcb, IN BOOLEAN Translate, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
Definition: phys_lib.cpp:4141
#define UDF_FILE_INFO_MT
Definition: udf_rel.h:338
lb_addr extLocation
Definition: ecma_167.h:375
long long int64
Definition: platform.h:13
#define OSSTATUS
Definition: env_spec_w32.h:57
smooth NULL
Definition: ftsmooth.c:416
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
#define ICB_FLAG_AD_IN_ICB
Definition: ecma_167.h:496
void UDFSetFileSize(IN PUDF_FILE_INFO FileInfo, IN int64 Size)
Definition: udf_info.cpp:1157
#define Vcb
Definition: cdprocs.h:1425
#define UDFExtentToMapping(e)
Definition: udf_info.h:181
#define UDFIncFileLinkCount(fi)
Definition: udf_info.h:580
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
struct _UDF_FILE_INFO * PUDF_FILE_INFO
#define MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
void UDFSetFileUID(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1456
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short uint16
Definition: types.h:30
uint32 logicalBlockNum
Definition: ecma_167.h:362
uint16 partitionReferenceNum
Definition: ecma_167.h:363
#define MEM_FINF_TAG
Definition: udf_rel.h:489
struct FileInfo FileInfo
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
OSSTATUS UDFReleaseDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc)
Definition: dirtree.cpp:1224
uint32 extLength
Definition: ecma_167.h:374
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
#define UDF_EXTENT_LENGTH_MASK
Definition: osta_misc.h:148
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
OSSTATUS UDFBuildFileEntry(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum, IN uint16 AllocMode, IN uint32 ExtAttrSz, IN BOOLEAN Extended)
Definition: udf_info.cpp:971
Definition: ps.c:97

Referenced by UDFCreateStreamDir__().

◆ UDFCreateStreamDir__()

OSSTATUS UDFCreateStreamDir__ ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo,
OUT PUDF_FILE_INFO _SDirInfo 
)

Definition at line 4888 of file udf_info.cpp.

4894 {
4895  OSSTATUS status;
4896  PUDF_FILE_INFO SDirInfo;
4897  uint16 Ident;
4898 
4899  *_SDirInfo = NULL;
4901  // check currently recorded UDF revision
4902  if(!UDFStreamsSupported(Vcb))
4903  return STATUS_INVALID_PARAMETER;
4904  // check if we are allowed to associate Stream Dir with this file
4905  if((FileInfo->ParentFile && UDFIsAStreamDir(FileInfo->ParentFile)) ||
4907  return STATUS_FILE_DELETED;
4908  // check if we have Deleted SDir
4909  if(FileInfo->Dloc->SDirInfo &&
4910  UDFIsSDirDeleted(FileInfo->Dloc->SDirInfo))
4911  return STATUS_ACCESS_DENIED;
4912  // check if this file has ExtendedFileEntry
4913  if((Ident = FileInfo->Dloc->FileEntry->tagIdent) != TID_EXTENDED_FILE_ENTRY) {
4915  return status;
4916  }
4917 
4918  uint32 PartNum = UDFGetPartNumByPhysLba(Vcb, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
4919  // create stream directory file
4920  if(!OS_SUCCESS(status = UDFCreateRootFile__(Vcb, PartNum, 0,0,FALSE, &SDirInfo)))
4921  return status;
4922  // link objects
4923  SDirInfo->ParentFile = FileInfo;
4924  // record directory structure
4926 
4927  FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_HAS_SDIR;
4929  FileInfo->Dloc->FE_Flags &= ~UDF_FE_FLAG_HAS_SDIR;
4930 
4931  status = UDFRecordDirectory__(Vcb, SDirInfo);
4933 
4934  UDFInterlockedIncrement((PLONG)&(FileInfo->OpenCount));
4935  if(!OS_SUCCESS(status)) {
4936  UDFUnlinkFile__(Vcb, SDirInfo, TRUE);
4937  UDFCloseFile__(Vcb, SDirInfo);
4938  UDFCleanUpFile__(Vcb, SDirInfo);
4939  MyFreePool__(SDirInfo);
4940  ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->streamDirectoryICB.extLength = 0;
4941  ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->streamDirectoryICB.extLocation.partitionReferenceNum = 0;
4942  ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->streamDirectoryICB.extLocation.logicalBlockNum = 0;
4943  return status;
4944  }
4945  *_SDirInfo = SDirInfo;
4946  // do some init
4947  ((PEXTENDED_FILE_ENTRY)(SDirInfo->Dloc->FileEntry))->icbTag.fileType = UDF_FILE_TYPE_STREAMDIR;
4948  ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->streamDirectoryICB.extLength = Vcb->LBlockSize;
4949  ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->streamDirectoryICB.extLocation.partitionReferenceNum = (uint16)PartNum;
4950  ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->streamDirectoryICB.extLocation.logicalBlockNum =
4951  UDFPhysLbaToPart(Vcb, PartNum, SDirInfo->Dloc->FELoc.Mapping[0].extLocation);
4952  ((PEXTENDED_FILE_ENTRY)(SDirInfo->Dloc->FileEntry))->uniqueID =
4953  ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->uniqueID;
4954  FileInfo->Dloc->FE_Flags |= (UDF_FE_FLAG_FE_MODIFIED | UDF_FE_FLAG_HAS_SDIR);
4955  // open & finalize linkage
4956  FileInfo->Dloc->SDirInfo = SDirInfo;
4957  return STATUS_SUCCESS;
4958 } // end UDFCreateStreamDir__()
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned int uint32
Definition: types.h:32
uint32 extLocation
Definition: ecma_167.h:129
#define UDF_FE_FLAG_IS_SDIR
File is a StreamDir.
Definition: udf_rel.h:327
uint32 FE_Flags
Definition: udf_rel.h:299
PUDF_DATALOC_INFO Dloc
Definition: udf_rel.h:367
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
#define TID_EXTENDED_FILE_ENTRY
Definition: ecma_167.h:175
OSSTATUS UDFCreateRootFile__(IN PVCB Vcb, IN uint32 PartNum, IN uint32 ExtAttrSz, IN uint32 ImpUseLen, IN BOOLEAN Extended, OUT PUDF_FILE_INFO *_FileInfo)
Definition: udf_info.cpp:4827
#define OSSTATUS
Definition: env_spec_w32.h:57
#define UDFDecDirCounter(Vcb)
Definition: udf_info.h:617
EXTENT_INFO FELoc
Definition: udf_rel.h:279
smooth NULL
Definition: ftsmooth.c:416
OSSTATUS UDFConvertFEToExtended(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:5458
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
#define UDF_FE_FLAG_HAS_SDIR
File contains Stream Dir.
Definition: udf_rel.h:325
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
#define UDFIsAStreamDir(FI)
Definition: udf_info.h:998
uint32 UDFCleanUpFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:2276
Definition: ecma_167.h:742
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
struct _UDF_FILE_INFO * ParentFile
Definition: udf_rel.h:381
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
#define UDFIsSDirDeleted(FI)
Definition: udf_info.h:1004
#define UDFIncFileLinkCount(fi)
Definition: udf_info.h:580
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
OSSTATUS UDFCloseFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:2994
#define UDFInterlockedIncrement(addr)
Definition: env_spec_w32.h:675
unsigned short uint16
Definition: types.h:30
#define UDF_FILE_TYPE_STREAMDIR
Definition: ecma_167.h:477
OSSTATUS UDFUnlinkFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN BOOLEAN FreeSpace)
Definition: udf_info.cpp:1766
struct _EXTENDED_FILE_ENTRY * PEXTENDED_FILE_ENTRY
struct FileInfo FileInfo
#define UDFStreamsSupported(Vcb)
Definition: udf_info.h:1037
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
Definition: alloc.cpp:201
#define UDFHasAStreamDir(FI)
Definition: udf_info.h:1000
return STATUS_SUCCESS
Definition: btrfs.c:2966
OSSTATUS UDFRecordDirectory__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO DirInfo)
Definition: udf_info.cpp:3384
signed int * PLONG
Definition: retypes.h:5
static SERVICE_STATUS status
Definition: service.c:31
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
Definition: ps.c:97

Referenced by UDFCommonCreate(), and UDFWriteSecurity().

◆ UDFDecompressUnicode()

void __fastcall UDFDecompressUnicode ( IN OUT PUNICODE_STRING  UName,
IN uint8 CS0,
IN SIZE_T  Length,
OUT uint16 valueCRC 
)

Definition at line 170 of file udf_info.cpp.

176 {
177  uint16 compID = CS0[0];
178  uint32 unicodeIndex = 0;
179  uint32 byteIndex = 1;
180  PWCHAR buff;
181  uint8* _CS0 = CS0+1;
182 
183  if(!Length) goto return_empty_str;
184  // First check for valid compID.
185  switch(compID) {
186  case UDF_COMP_ID_8: {
187 
189  if(!buff) goto return_empty_str;
190  UName->Buffer = buff;
191 
192  // Loop through all the bytes.
193  while (byteIndex < Length) {
194  (*buff) = (*_CS0);
195  _CS0++;
196  byteIndex++;
197  buff++;
198  }
199  unicodeIndex = byteIndex-1;
200  break;
201  }
202  case UDF_COMP_ID_16: {
203 
205  if(!buff) goto return_empty_str;
206  UName->Buffer = buff;
207 
208  // Loop through all the bytes.
209  while (byteIndex < Length) {
210  // Move the first byte to the high bits of the unicode char.
211  *buff = ((*_CS0) << 8) | (*(_CS0+1));
212  _CS0+=2;
213  byteIndex+=2;
214  unicodeIndex++;
215  buff++;
216  ASSERT(byteIndex <= Length);
217  }
218  break;
219  }
220  default: {
221 return_empty_str:
222  UName->Buffer = NULL;
223  UName->MaximumLength =
224  UName->Length = 0;
225  return;
226  }
227  }
228  UName->MaximumLength = (UName->Length = (((uint16)unicodeIndex)*sizeof(WCHAR))) + sizeof(WCHAR);
229  UName->Buffer[unicodeIndex] = 0;
230  if(valueCRC) {
231  *valueCRC = UDFCrc(CS0+1, Length-1);
232  }
233 } // end UDFDecompressUnicode()
unsigned int uint32
Definition: types.h:32
uint16_t * PWCHAR
Definition: typedefs.h:54
#define UDF_COMP_ID_8
Definition: ecma_167.h:22
#define UDF_FILENAME_MT
Definition: udf_rel.h:126
uint16 __fastcall UDFCrc(IN uint8 *Data, IN SIZE_T Size)
Definition: udf_info.cpp:4527
smooth NULL
Definition: ftsmooth.c:416
#define MEM_FNAME_TAG
Definition: udf_rel.h:483
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char uint8
Definition: types.h:28
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
#define MEM_FNAME16_TAG
Definition: udf_rel.h:484
#define UDF_COMP_ID_16
Definition: ecma_167.h:23
unsigned short uint16
Definition: types.h:30
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by UDFGetDstring(), and UDFIndexDirectory().

◆ UDFDOSName()

void __fastcall UDFDOSName ( IN PVCB  Vcb,
IN OUT PUNICODE_STRING  DosName,
IN PUNICODE_STRING  UdfName,
IN BOOLEAN  KeepIntact 
)

Definition at line 427 of file udf_info.cpp.

433 {
434 #ifndef _CONSOLE
435  if(Vcb->CompatFlags & UDF_VCB_IC_OS_NATIVE_DOS_NAME) {
436  UDFDOSNameOsNative(DosName, UdfName, KeepIntact);
437  return;
438  }
439 #endif //_CONSOLE
440 
441  switch(Vcb->CurrentUDFRev) {
442  case 0x0100:
443  case 0x0101:
444  case 0x0102:
445  UDFDOSName100(DosName, UdfName, KeepIntact);
446  break;
447 
448  case 0x0150:
449  // in general, we need bytes-from-media to
450  // create valid UDF 1.50 name.
451  // Curently it is impossible, thus, we'll use
452  // UDF 2.00 translation algorithm
453  case 0x0200:
454  UDFDOSName200(DosName, UdfName, KeepIntact, Vcb->CurrentUDFRev == 0x0150);
455  break;
456 
457  case 0x0201:
458  default:
459  UDFDOSName201(DosName, UdfName, KeepIntact);
460  }
461 }
void __fastcall UDFDOSName201(IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)
Definition: udf_info.cpp:700
void __fastcall UDFDOSName100(IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)
Definition: udf_info.cpp:465
#define UDF_VCB_IC_OS_NATIVE_DOS_NAME
Definition: udf_common.h:503
void __fastcall UDFDOSName200(IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact, IN BOOLEAN Mode150)
Definition: udf_info.cpp:582
#define Vcb
Definition: cdprocs.h:1425
_Out_ PUNICODE_STRING DosName
Definition: rtlfuncs.h:1270
void __fastcall UDFDOSNameOsNative(IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)

Referenced by UDFBuildHashEntry(), UDFFileDirInfoToNT(), UDFFindFile(), and UDFIsNameInExpression().

◆ UDFDOSName100()

void __fastcall UDFDOSName100 ( IN OUT PUNICODE_STRING  DosName,
IN PUNICODE_STRING  UdfName,
IN BOOLEAN  KeepIntact 
)

Definition at line 465 of file udf_info.cpp.

470 {
471  PWCHAR dosName = DosName->Buffer;
472  PWCHAR udfName = UdfName->Buffer;
473  uint32 udfLen = UdfName->Length / sizeof(WCHAR);
474 
475  uint32 index, dosIndex = 0, extIndex = 0, lastPeriodIndex;
476  BOOLEAN needsCRC = FALSE, hasExt = FALSE, writingExt = FALSE, isParent = FALSE;
477  uint32 valueCRC;
479 
480  if(KeepIntact &&
481  (udfLen <= 2) && (udfName[0] == UNICODE_PERIOD)) {
482  isParent = TRUE;
483  if((udfLen == 2) && (udfName[1] != UNICODE_PERIOD))
484  isParent = FALSE;
485  }
486 
487  for (index = 0 ; index < udfLen ; index++) {
488  current = udfName[index];
489  if (current == UNICODE_PERIOD && !isParent) {
490  if (dosIndex==0 || hasExt) {
491  // Ignore leading periods or any other than used for extension.
492  needsCRC = TRUE;
493  } else {
494  // First, find last character which is NOT a period or space.
495  lastPeriodIndex = udfLen - 1;
496  while(lastPeriodIndex >=0 &&
497  (udfName[lastPeriodIndex] == UNICODE_PERIOD ||
498  udfName[lastPeriodIndex] == UNICODE_SPACE))
499  lastPeriodIndex--;
500  // Now search for last remaining period.
501  while(lastPeriodIndex >= 0 &&
502  udfName[lastPeriodIndex] != UNICODE_PERIOD)
503  lastPeriodIndex--;
504  // See if the period we found was the last or not.
505  if (lastPeriodIndex != index)
506  needsCRC = TRUE; // If not, name needs translation.
507  // As long as the period was not trailing,
508  // the file name has an extension.
509  if (lastPeriodIndex >= 0) hasExt = TRUE;
510  }
511  } else {
512  if ((!hasExt && dosIndex == DOS_NAME_LEN) ||
513  extIndex == DOS_EXT_LEN) {
514  // File name or extension is too long for DOS.
515  needsCRC = TRUE;
516  } else {
517  if (current == UNICODE_SPACE) { // Ignore spaces.
518  needsCRC = TRUE;
519  } else {
520  // Look for illegal or unprintable characters.
521  if (UDFIsIllegalChar(current) /*|| !UnicodeIsPrint(current)*/) {
522  needsCRC = TRUE;
524  /* Skip Illegal characters(even spaces),
525  * but not periods.
526  */
527  while(index+1 < udfLen &&
528  (UDFIsIllegalChar(udfName[index+1]) /*||
529  !UnicodeIsPrint(udfName[index+1])*/) &&
530  udfName[index+1] != UNICODE_PERIOD)
531  index++;
532  }
533  // Add current char to either file name or ext.
534  if (writingExt) {
535  ext[extIndex] = current;
536  extIndex++;
537  } else {
538  dosName[dosIndex] = current;
539  dosIndex++;
540  }
541  }
542  }
543  }
544  // See if we are done with file name, either because we reached
545  // the end of the file name length, or the final period.
546  if (!writingExt && hasExt && (dosIndex == DOS_NAME_LEN ||
547  index == lastPeriodIndex)) {
548  // If so, and the name has an extension, start reading it.
549  writingExt = TRUE;
550  // Extension starts after last period.
551  index = lastPeriodIndex;
552  }
553  }
554  //
555  if (needsCRC) {
556  // Add CRC to end of file name or at position 4.
557  if (dosIndex >4) dosIndex = 4;
558  valueCRC = UDFUnicodeCksum(udfName, udfLen);
559  // set CRC prefix
560  dosName[dosIndex] = UNICODE_CRC_MARK;
561  // Convert 12-bit CRC to hex characters.
562  dosName[dosIndex+1] = hexChar[(valueCRC & 0x0f00) >> 8];
563  dosName[dosIndex+2] = hexChar[(valueCRC & 0x00f0) >> 4];
564  dosName[dosIndex+3] = hexChar[(valueCRC & 0x000f)];
565  dosIndex+=4;
566  }
567  // Add extension, if any.
568  if (extIndex != 0) {
569  dosName[dosIndex] = UNICODE_PERIOD;
570  dosIndex++;
571  for (index = 0; index < extIndex; index++) {
572  dosName[dosIndex] = ext[index];
573  dosIndex++;
574  }
575  }
576  DosName->Length = (uint16)dosIndex*sizeof(WCHAR);
578 } // end UDFDOSName100()
#define TRUE
Definition: types.h:120
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
unsigned int uint32
Definition: types.h:32
#define hexChar
Definition: udf_info.cpp:45
uint16_t * PWCHAR
Definition: typedefs.h:54
#define UNICODE_SPACE
Definition: udf_rel.h:424
unsigned char BOOLEAN
char ext[3]
Definition: mkdosfs.c:358
BOOLEAN __fastcall UDFIsIllegalChar(IN WCHAR chr)
Definition: udf_info.cpp:370
GLuint index
Definition: glext.h:6031
#define UNICODE_CRC_MARK
Definition: udf_rel.h:422
#define DOS_EXT_LEN
Definition: udf_rel.h:420
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ILLEGAL_CHAR_MARK
Definition: udf_rel.h:421
#define index(s, c)
Definition: various.h:29
unsigned short uint16
Definition: types.h:30
_Out_ PUNICODE_STRING DosName
Definition: rtlfuncs.h:1270
#define DOS_NAME_LEN
Definition: udf_rel.h:419
#define UNICODE_PERIOD
Definition: udf_rel.h:423
uint16 __fastcall UDFUnicodeCksum(PWCHAR s, uint32 n)
Definition: udf_info.cpp:4356
struct task_struct * current
Definition: linux.c:32

Referenced by UDFDOSName().

◆ UDFDOSName200()

void __fastcall UDFDOSName200 ( IN OUT PUNICODE_STRING  DosName,
IN PUNICODE_STRING  UdfName,
IN BOOLEAN  KeepIntact,
IN BOOLEAN  Mode150 
)

Definition at line 582 of file udf_info.cpp.

588 {
589  PWCHAR dosName = DosName->Buffer;
590  PWCHAR udfName = UdfName->Buffer;
591  uint32 udfLen = UdfName->Length / sizeof(WCHAR);
592 
593  uint32 index, dosIndex = 0, extIndex = 0, lastPeriodIndex;
594  BOOLEAN needsCRC = FALSE, hasExt = FALSE, writingExt = FALSE, isParent = FALSE;
595  uint32 valueCRC;
597 
598  if(KeepIntact &&
599  (udfLen <= 2) && (udfName[0] == UNICODE_PERIOD)) {
600  isParent = TRUE;
601  if((udfLen == 2) && (udfName[1] != UNICODE_PERIOD))
602  isParent = FALSE;
603  }
604 
605  for (index = 0 ; index < udfLen ; index++) {
606  current = udfName[index];
607  if (current == UNICODE_PERIOD && !isParent) {
608  if (dosIndex==0 || hasExt) {
609  // Ignore leading periods or any other than used for extension.
610  needsCRC = TRUE;
611  } else {
612  // First, find last character which is NOT a period or space.
613  lastPeriodIndex = udfLen - 1;
614  while(lastPeriodIndex >=0 &&
615  (udfName[lastPeriodIndex] == UNICODE_PERIOD ||
616  udfName[lastPeriodIndex] == UNICODE_SPACE))
617  lastPeriodIndex--;
618  // Now search for last remaining period.
619  while(lastPeriodIndex >= 0 &&
620  udfName[lastPeriodIndex] != UNICODE_PERIOD)
621  lastPeriodIndex--;
622  // See if the period we found was the last or not.
623  if (lastPeriodIndex != index)
624  needsCRC = TRUE; // If not, name needs translation.
625  // As long as the period was not trailing,
626  // the file name has an extension.
627  if (lastPeriodIndex >= 0) hasExt = TRUE;
628  }
629  } else {
630  if ((!hasExt && dosIndex == DOS_NAME_LEN) ||
631  extIndex == DOS_EXT_LEN) {
632  // File name or extension is too long for DOS.
633  needsCRC = TRUE;
634  } else {
635  if (current == UNICODE_SPACE) { // Ignore spaces.
636  needsCRC = TRUE;
637  } else {
638  // Look for illegal or unprintable characters.
639  if (UDFIsIllegalChar(current) /*|| !UnicodeIsPrint(current)*/) {
640  needsCRC = TRUE;
642  /* Skip Illegal characters(even spaces),
643  * but not periods.
644  */
645  while(index+1 < udfLen &&
646  (UDFIsIllegalChar(udfName[index+1]) /*||
647  !UnicodeIsPrint(udfName[index+1])*/) &&
648  udfName[index+1] != UNICODE_PERIOD)
649  index++;
650  }
651  // Add current char to either file name or ext.
652  if (writingExt) {
653  ext[extIndex] = current;
654  extIndex++;
655  } else {
656  dosName[dosIndex] = current;
657  dosIndex++;
658  }
659  }
660  }
661  }
662  // See if we are done with file name, either because we reached
663  // the end of the file name length, or the final period.
664  if (!writingExt && hasExt && (dosIndex == DOS_NAME_LEN ||
665  index == lastPeriodIndex)) {
666  // If so, and the name has an extension, start reading it.
667  writingExt = TRUE;
668  // Extension starts after last period.
669  index = lastPeriodIndex;
670  }
671  }
672  // Now handle CRC if needed.
673  if (needsCRC) {
674  // Add CRC to end of file name or at position 4.
675  if (dosIndex >4) dosIndex = 4;
676  valueCRC = Mode150 ? UDFUnicodeCksum150(udfName, udfLen) : UDFUnicodeCksum(udfName, udfLen);
677  // Convert 16-bit CRC to hex characters.
678  dosName[dosIndex] = hexChar[(valueCRC & 0xf000) >> 12];
679  dosName[dosIndex+1] = hexChar[(valueCRC & 0x0f00) >> 8];
680  dosName[dosIndex+2] = hexChar[(valueCRC & 0x00f0) >> 4];
681  dosName[dosIndex+3] = hexChar[(valueCRC & 0x000f)];
682  dosIndex+=4;
683  }
684  // Add extension, if any.
685  if (extIndex != 0) {
686  dosName[dosIndex] = UNICODE_PERIOD;
687  dosIndex++;
688  for (index = 0; index < extIndex; index++) {
689  dosName[dosIndex] = ext[index];
690  dosIndex++;
691  }
692  }
693  DosName->Length = (uint16)dosIndex*sizeof(WCHAR);
695 } // end UDFDOSName200()
#define TRUE
Definition: types.h:120
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
unsigned int uint32
Definition: types.h:32
#define hexChar
Definition: udf_info.cpp:45
uint16_t * PWCHAR
Definition: typedefs.h:54
#define UNICODE_SPACE
Definition: udf_rel.h:424
unsigned char BOOLEAN
char ext[3]
Definition: mkdosfs.c:358
BOOLEAN __fastcall UDFIsIllegalChar(IN WCHAR chr)
Definition: udf_info.cpp:370
GLuint index
Definition: glext.h:6031
#define DOS_EXT_LEN
Definition: udf_rel.h:420
uint16 __fastcall UDFUnicodeCksum150(PWCHAR s, uint32 n)
Definition: udf_info.cpp:4422
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ILLEGAL_CHAR_MARK
Definition: udf_rel.h:421
#define index(s, c)
Definition: various.h:29
unsigned short uint16
Definition: types.h:30
_Out_ PUNICODE_STRING DosName
Definition: rtlfuncs.h:1270
#define DOS_NAME_LEN
Definition: udf_rel.h:419
#define UNICODE_PERIOD
Definition: udf_rel.h:423
uint16 __fastcall UDFUnicodeCksum(PWCHAR s, uint32 n)
Definition: udf_info.cpp:4356
struct task_struct * current
Definition: linux.c:32

Referenced by UDFDOSName().

◆ UDFDOSName201()

void __fastcall UDFDOSName201 ( IN OUT PUNICODE_STRING  DosName,
IN PUNICODE_STRING  UdfName,
IN BOOLEAN  KeepIntact 
)

Definition at line 700 of file udf_info.cpp.

705 {
706  PWCHAR dosName = DosName->Buffer;
707  PWCHAR udfName = UdfName->Buffer;
708  uint16 udfLen = UdfName->Length / sizeof(WCHAR);
709 
710  uint16 index, dosIndex = 0;
711  //uint16 extIndex = 0;
712  BOOLEAN needsCRC = FALSE, isParent = FALSE;
713  //BOOLEAN hasExt = FALSE, writingExt = FALSE;
714  uint16 valueCRC;
716  WCHAR current;
717 
718  if(KeepIntact &&
719  (udfLen <= 2) && (udfName[0] == UNICODE_PERIOD)) {
720  isParent = TRUE;
721  if((udfLen == 2) && (udfName[1] != UNICODE_PERIOD))
722  isParent = FALSE;
723  }
724 
725  #define DOS_CRC_LEN 4
726  #define DOS_CRC_MODULUS 41
727 
728  int16 crcIndex;
729  uint16 extLen;
730  uint16 nameLen;
731  uint16 charLen;
732  int16 overlayBytes;
733  int16 bytesLeft;
734 
735  /* Start at the end of the UDF file name and scan for a period */
736  /* ('.'). This will be where the DOS extension starts (if */
737  /* any). */
738  index = udfLen;
739  while (index-- > 0) {
740  if (udfName[index] == '.')
741  break;
742  }
743  if ((index < 0) || isParent) {
744  /* There name was scanned to the beginning of the buffer */
745  /* and no extension was found. */
746  extLen = 0;
747  nameLen = udfLen;
748  } else {
749  /* A DOS extension was found, process it first. */
750  extLen = udfLen - index - 1;
751  nameLen = index;
752  dosIndex = 0;
753  bytesLeft = DOS_EXT_LEN;
754  while (++index < udfLen && bytesLeft > 0) {
755  /* Get the current character and convert it to upper */
756  /* case. */
757  current = udfName[index];
758  if (current == ' ') {
759  /* If a space is found, a CRC must be appended to */
760  /* the mangled file name. */
761  needsCRC = TRUE;
762  } else {
763  /* Determine if this is a valid file name char and */
764  /* calculate its corresponding BCS character byte */
765  /* length (zero if the char is not legal or */
766  /* undisplayable on this system). */
767 
768  charLen = (UDFIsIllegalChar(current)
769  /*|| !UnicodeIsPrint(current)*/) ? 0 : 1;
770 
771  /* If the char is larger than the available space */
772  /* in the buffer, pretend it is undisplayable. */
773  if (charLen > bytesLeft)
774  charLen = 0;
775  if (charLen == 0) {
776  /* Undisplayable or illegal characters are */
777  /* substituted with an underscore ("_"), and */
778  /* required a CRC code appended to the mangled */
779  /* file name. */
780  needsCRC = TRUE;
781  charLen = 1;
782  current = '_';
783  /* Skip over any following undiplayable or */
784  /* illegal chars. */
785  while (index +1 <udfLen &&
786  (UDFIsIllegalChar(udfName[index+1])
787  /*|| !UnicodeIsPrint(udfName[index+1])*/))
788  index++;
789  }
790  /* Assign the resulting char to the next index in */
791  /* the extension buffer and determine how many BCS */
792  /* bytes are left. */
793  ext[dosIndex++] = current;
794  bytesLeft -= charLen;
795  }
796  }
797  /* Save the number of Unicode characters in the extension */
798  extLen = dosIndex;
799  /* If the extension was too large, or it was zero length */
800  /* (i.e. the name ended in a period), a CRC code must be */
801  /* appended to the mangled name. */
802  if (index < udfLen || extLen == 0)
803  needsCRC = TRUE;
804  }
805  /* Now process the actual file name. */
806  index = 0;
807  dosIndex = 0;
808  crcIndex = 0;
809  overlayBytes = -1;
810  bytesLeft = DOS_NAME_LEN;
812  /* Get the current character and convert it to upper case. */
813  current = udfName[index];
814  if (current ==' ' || (current == '.' && !isParent) ) {
815  /* Spaces and periods are just skipped, a CRC code */
816  /* must be added to the mangled file name. */
817  needsCRC = TRUE;
818  } else {
819  /* Determine if this is a valid file name char and */
820  /* calculate its corresponding BCS character byte */
821  /* length (zero if the char is not legal or */
822  /* undisplayable on this system). */
823 
824  charLen = (UDFIsIllegalChar(current)
825  /*|| !UnicodeIsPrint(current)*/) ? 0 : 1;
826 
827  /* If the char is larger than the available space in */
828  /* the buffer, pretend it is undisplayable. */
829  if (charLen > bytesLeft)
830  charLen = 0;
831 
832  if (charLen == 0) {
833  /* Undisplayable or illegal characters are */
834  /* substituted with an underscore ("_"), and */
835  /* required a CRC code appended to the mangled */
836  /* file name. */
837  needsCRC = TRUE;
838  charLen = 1;
839  current = '_';
840  /* Skip over any following undisplayable or illegal */
841  /* chars. */
842  while (index +1 <nameLen &&
843  (UDFIsIllegalChar(udfName[index+1])
844  /*|| !UnicodeIsPrint(udfName[index+1])*/))
845  index++;
846  /* Terminate loop if at the end of the file name. */
847  if (index >= nameLen)
848  break;
849  }
850  /* Assign the resulting char to the next index in the */
851  /* file name buffer and determine how many BCS bytes */
852  /* are left. */
853  dosName[dosIndex++] = current;
854  bytesLeft -= charLen;
855  /* This figures out where the CRC code needs to start */
856  /* in the file name buffer. */
857  if (bytesLeft >= DOS_CRC_LEN) {
858  /* If there is enough space left, just tack it */
859  /* onto the end. */
860  crcIndex = dosIndex;
861  } else {
862  /* If there is not enough space left, the CRC */
863  /* must overlay a character already in the file */
864  /* name buffer. Once this condition has been */
865  /* met, the value will not change. */
866  if (overlayBytes < 0) {
867  /* Determine the index and save the length of */
868  /* the BCS character that is overlayed. It */
869  /* is possible that the CRC might overlay */
870  /* half of a two-byte BCS character depending */
871  /* upon how the character boundaries line up. */
872  overlayBytes = (bytesLeft + charLen > DOS_CRC_LEN)?1 :0;
873  crcIndex = dosIndex - 1;
874  }
875  }
876  }
877  /* Advance to the next character. */
878  index++;
879  }
880  /* If the scan did not reach the end of the file name, or the */
881  /* length of the file name is zero, a CRC code is needed. */
882  if (index < nameLen || index == 0)
883  needsCRC = TRUE;
884 
885  /* If the name has illegal characters or and extension, it */
886  /* is not a DOS device name. */
887 
888 /* if (needsCRC == FALSE && extLen == 0) { */
889  /* If this is the name of a DOS device, a CRC code should */
890  /* be appended to the file name.
891  if (IsDeviceName(udfName, udfLen))
892  needsCRC = TRUE;
893  }*/
894 
895  /* Append the CRC code to the file name, if needed. */
896  if (needsCRC) {
897  /* Get the CRC value for the original Unicode string */
898  valueCRC = UDFUnicodeCksum(udfName, udfLen);
899 
900  /* begin. */
901  dosIndex = crcIndex;
902  /* If the character being overlayed is a two-byte BCS */
903  /* character, replace the first byte with an underscore. */
904  if (overlayBytes > 0)
905  dosName[dosIndex++] = '_';
906  /* Append the encoded CRC value with delimiter. */
907  dosName[dosIndex++] = '#';
908  dosName[dosIndex++] =
909  crcChar[valueCRC / (DOS_CRC_MODULUS * DOS_CRC_MODULUS)];
910  valueCRC %= DOS_CRC_MODULUS * DOS_CRC_MODULUS;
911  dosName[dosIndex++] =
912  crcChar[valueCRC / DOS_CRC_MODULUS];
913  valueCRC %= DOS_CRC_MODULUS;
914  dosName[dosIndex++] = crcChar[valueCRC];
915  }
916  /* Append the extension, if any. */
917  if (extLen > 0) {
918  /* Tack on a period and each successive byte in the */
919  /* extension buffer. */
920  dosName[dosIndex++] = '.';
921  for (index = 0; index < extLen; index++)
922  dosName[dosIndex++] = ext[index];
923  }
924  /* Return the length of the resulting Unicode string. */
925  DosName->Length = (uint16)dosIndex*sizeof(WCHAR);
927 
928 } // end UDFDOSName201()
#define TRUE
Definition: types.h:120
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
#define DOS_CRC_LEN
#define DOS_CRC_MODULUS
Definition: udf_info.cpp:44
uint16_t * PWCHAR
Definition: typedefs.h:54
unsigned char BOOLEAN
char ext[3]
Definition: mkdosfs.c:358
BOOLEAN __fastcall UDFIsIllegalChar(IN WCHAR chr)
Definition: udf_info.cpp:370
GLuint index
Definition: glext.h:6031
#define DOS_EXT_LEN
Definition: udf_rel.h:420
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define index(s, c)
Definition: various.h:29
unsigned short uint16
Definition: types.h:30
short int16
Definition: platform.h:11
_Out_ PUNICODE_STRING DosName
Definition: rtlfuncs.h:1270
static const char crcChar[]
Definition: udf_info.cpp:46
#define DOS_NAME_LEN
Definition: udf_rel.h:419
#define UNICODE_PERIOD
Definition: udf_rel.h:423
uint16 __fastcall UDFUnicodeCksum(PWCHAR s, uint32 n)
Definition: udf_info.cpp:4356
struct task_struct * current
Definition: linux.c:32

Referenced by UDFDOSName().

◆ UDFFlushFE()

OSSTATUS UDFFlushFE ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo,
IN uint32  PartNum 
)

Definition at line 3864 of file udf_info.cpp.

3869 {
3870  int8* NewAllocDescs;
3871  OSSTATUS status;
3872  SIZE_T WrittenBytes;
3873  uint16 AllocMode;
3874  uint32 lba;
3875 
3876  AllocMode = ((PFILE_ENTRY)(FileInfo->Dloc->FileEntry))->icbTag.flags & ICB_FLAG_ALLOC_MASK;
3877 #ifdef UDF_DBG
3878 /* if(UDFIsADirectory(FileInfo) && (UDFGetFileSize(FileInfo) < 0x28) &&
3879  !UDFIsDeleted(UDFDirIndex(DirInfo->Dloc->DirIndex, FileInfo->Index)) ) {
3880  BrutePoint();
3881  }*/
3882 // ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
3883  if(FileInfo->Dloc->FELoc.Offset) {
3884  BrutePoint();
3885  }
3886  if(FileInfo->Dloc->AllocLoc.Mapping) {
3887  ASSERT(AllocMode != ICB_FLAG_AD_IN_ICB);
3888  }
3889 #endif // UDF_DBG
3890 retry_flush_FE:
3891  UDFPrint((" FlushFE: %x\n", FileInfo->Dloc->FELoc.Mapping[0].extLocation));
3892 #ifndef UDF_READ_ONLY_BUILD
3894  if(FileInfo->Dloc->DataLoc.Modified ||
3895  FileInfo->Dloc->AllocLoc.Modified) {
3896  ASSERT(PartNum != (uint32)(-1));
3897  // prepare new AllocDescs for flushing...
3898  if(!OS_SUCCESS(status = UDFBuildAllocDescs(Vcb, PartNum, FileInfo, &NewAllocDescs))) {
3899  UDFPrint((" FlushFE: UDFBuildAllocDescs() faliled (%x)\n", status));
3900  if(NewAllocDescs)
3901  MyFreePool__(NewAllocDescs);
3902  return status;
3903  }
3904 #ifdef UDF_DBG
3905  if(Vcb->CompatFlags & UDF_VCB_IC_W2K_COMPAT_ALLOC_DESCS) {
3906  ASSERT(UDFGetFileSize(FileInfo) <= UDFGetExtentLength(FileInfo->Dloc->DataLoc.Mapping));
3907  } else {
3908  ASSERT(((UDFGetFileSize(FileInfo)+Vcb->LBlockSize-1) & (Vcb->LBlockSize-1)) ==
3909  ((UDFGetExtentLength(FileInfo->Dloc->DataLoc.Mapping)+Vcb->LBlockSize-1) & (Vcb->LBlockSize-1)));
3910  }
3911  AllocMode = ((PFILE_ENTRY)(FileInfo->Dloc->FileEntry))->icbTag.flags & ICB_FLAG_ALLOC_MASK;
3912 #endif // UDF_DBG
3913  // initiate update of lengthAllocDescs
3914  FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
3915  if(NewAllocDescs) {
3916  ASSERT(AllocMode != ICB_FLAG_AD_IN_ICB);
3917  status = UDFPadLastSector(Vcb, &(FileInfo->Dloc->AllocLoc));
3918  // ... and flush it
3919  status = UDFWriteExtent(Vcb, &(FileInfo->Dloc->AllocLoc), 0, (uint32)(FileInfo->Dloc->AllocLoc.Length), FALSE, NewAllocDescs, &WrittenBytes);
3920  MyFreePool__(NewAllocDescs);
3921  if(!OS_SUCCESS(status)) {
3922  UDFPrint((" FlushFE: UDFWriteExtent() faliled (%x)\n", status));
3923  return status;
3924  }
3925 #ifdef UDF_DBG
3926  } else {
3927  ASSERT(AllocMode == ICB_FLAG_AD_IN_ICB);
3928 #endif // UDF_DBG
3929  }
3930  FileInfo->Dloc->DataLoc.Modified = FALSE;
3931  FileInfo->Dloc->AllocLoc.Modified = FALSE;
3932  } else {
3933 #if defined(UDF_DBG) && !defined(UDF_CHECK_UTIL)
3934  if(Vcb->CompatFlags & UDF_VCB_IC_W2K_COMPAT_ALLOC_DESCS) {
3935  ASSERT(UDFGetFileSize(FileInfo) <= UDFGetExtentLength(FileInfo->Dloc->DataLoc.Mapping));
3936  } else {
3937  ASSERT(((UDFGetFileSize(FileInfo)+Vcb->LBlockSize-1) & (Vcb->LBlockSize-1)) ==
3938  ((UDFGetExtentLength(FileInfo->Dloc->DataLoc.Mapping)+Vcb->LBlockSize-1) & (Vcb->LBlockSize-1)));
3939  }
3940 #endif // UDF_DBG
3941  }
3942 /* if(FileInfo->Fcb &&
3943  ((FileInfo->Dloc->FELoc.Mapping[0].extLocation > Vcb->LastLBA) ||
3944  UDFGetFreeBit(((uint32*)(Vcb->FSBM_Bitmap)), FileInfo->Dloc->FELoc.Mapping[0].extLocation)) ) {
3945  BrutePoint();
3946  }*/
3947 /* if(FileInfo->Dloc->FELoc.Mapping[0].extLocation) {
3948  ASSERT( FileInfo->Dloc->FileEntry->tagLocation ==
3949  (FileInfo->Dloc->FELoc.Mapping[0].extLocation - 0x580));
3950  }*/
3951  if((FileInfo->Dloc->FE_Flags & UDF_FE_FLAG_FE_MODIFIED) ||
3952  FileInfo->Dloc->FELoc.Modified) {
3953  ASSERT(PartNum != (uint32)(-1));
3954  ASSERT(!PartNum);
3955  if(PartNum == (uint32)(-1) || PartNum == (uint32)(-2)) {
3956  UDFPrint((" bad PartNum: %d\n", PartNum));
3957  }
3958  // update lengthAllocDescs in FE
3960 /* ASSERT( FileInfo->Dloc->FileEntry->tagLocation ==
3961  (FileInfo->Dloc->FELoc.Mapping[0].extLocation - 0x580));*/
3962  // flush FileEntry
3963 
3964  // if FE is located in remapped block, place it to reliable space
3965  lba = FileInfo->Dloc->FELoc.Mapping[0].extLocation;
3966  if(Vcb->BSBM_Bitmap) {
3967  if(UDFGetBadBit((uint32*)(Vcb->BSBM_Bitmap), lba)) {
3968  AdPrint((" bad block under FE @%x\n", lba));
3969  goto relocate_FE;
3970  }
3971  }
3972 
3973  AdPrint((" setup tag: @%x\n", lba));
3974  ASSERT( lba );
3975  UDFSetUpTag(Vcb, FileInfo->Dloc->FileEntry, (uint16)(FileInfo->Dloc->FileEntryLen),
3976  UDFPhysLbaToPart(Vcb, PartNum, lba));
3977  status = UDFWriteExtent(Vcb, &(FileInfo->Dloc->FELoc), 0,
3978  (uint32)(FileInfo->Dloc->FELoc.Length), FALSE,
3979  (int8*)(FileInfo->Dloc->FileEntry), &WrittenBytes);
3980  if(!OS_SUCCESS(status)) {
3981  UDFPrint((" FlushFE: UDFWriteExtent(2) faliled (%x)\n", status));
3983 relocate_FE:
3984  UDFPrint((" try to relocate\n"));
3985 
3986  EXTENT_INFO _FEExtInfo;
3987  // calculate the length required
3988 
3989  // allocate block for FE
3990  if(OS_SUCCESS(UDFAllocateFESpace(Vcb, FileInfo->ParentFile, PartNum, &_FEExtInfo, (uint32)(FileInfo->Dloc->FELoc.Length)) )) {
3991  UDFPrint((" relocate %x -> %x\n",
3992  lba,
3993  _FEExtInfo.Mapping[0].extLocation));
3994 
3995  UDFMarkSpaceAsXXX(Vcb, 0, FileInfo->Dloc->FELoc.Mapping, AS_BAD);
3996 
3997  UDFRelocateDloc(Vcb, FileInfo->Dloc, _FEExtInfo.Mapping[0].extLocation);
3998  MyFreePool__(FileInfo->Dloc->FELoc.Mapping);
3999  FileInfo->Dloc->FELoc.Mapping = _FEExtInfo.Mapping;
4000 
4001  FileInfo->Dloc->FELoc.Modified = TRUE;
4002  FileInfo->Dloc->FE_Flags |= UDF_FE_FLAG_FE_MODIFIED;
4003 
4004  AllocMode = ((PFILE_ENTRY)(FileInfo->Dloc->FileEntry))->icbTag.flags & ICB_FLAG_ALLOC_MASK;
4005  if(AllocMode == ICB_FLAG_AD_IN_ICB) {
4006  UDFPrint((" IN-ICB data lost\n"));
4007  FileInfo->Dloc->DataLoc.Mapping[0].extLocation = _FEExtInfo.Mapping[0].extLocation;
4008  FileInfo->Dloc->DataLoc.Modified = TRUE;
4009  } else {
4010  FileInfo->Dloc->AllocLoc.Mapping[0].extLocation = _FEExtInfo.Mapping[0].extLocation;
4011  FileInfo->Dloc->AllocLoc.Modified = TRUE;
4012  }
4013 
4014  if(FileInfo->Index >= 2) {
4015  PDIR_INDEX_ITEM DirNdx;
4017  if(DirNdx) {
4018  UDFPrint((" update reference in FI\n"));
4019  DirNdx->FileEntryLoc.logicalBlockNum =
4020  FileInfo->FileIdent->icb.extLocation.logicalBlockNum =
4021  UDFPhysLbaToPart(Vcb, PartNum, _FEExtInfo.Mapping[0].extLocation);
4022  DirNdx->FI_Flags |= UDF_FI_FLAG_FI_MODIFIED;
4023  }
4024  }
4025  // this will update
4026  UDFPrint((" retry flush...\n"));
4027  goto retry_flush_FE;
4028  }
4029  }
4030  BrutePoint();
4031  return status;
4032  }
4033  FileInfo->Dloc->FE_Flags &= ~UDF_FE_FLAG_FE_MODIFIED;
4034  FileInfo->Dloc->FELoc.Modified = FALSE;
4035  } else {
4036  ASSERT((FileInfo->Dloc->FileEntry->descVersion == 2) ||
4037  (FileInfo->Dloc->FileEntry->descVersion == 3));
4038  }
4039 #endif //UDF_READ_ONLY_BUILD
4040 #ifdef UDF_DBG
4041  if(FileInfo->Dloc->AllocLoc.Mapping) {
4042  ASSERT(AllocMode != ICB_FLAG_AD_IN_ICB);
4043  } else {
4044  ASSERT(AllocMode == ICB_FLAG_AD_IN_ICB);
4045  }
4046 #endif // UDF_DBG
4047  return STATUS_SUCCESS;
4048 } // end UDFFlushFE()
OSSTATUS UDFAllocateFESpace(IN PVCB Vcb, IN PUDF_FILE_INFO DirInfo, IN uint32 PartNum, IN PEXTENT_INFO FEExtInfo, IN uint32 Len)
Definition: extent.cpp:1563
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
OSSTATUS UDFPadLastSector(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo)
Definition: udf_info.cpp:2962
unsigned int uint32
Definition: types.h:32
void UDFSetUpTag(IN PVCB Vcb, IN tag *Tag, IN uint16 DataLen, IN uint32 TagLoc)
Definition: udf_info.cpp:936
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
struct _FILE_ENTRY * PFILE_ENTRY
uint32 extLocation
Definition: ecma_167.h:129
int64 UDFGetFileSize(IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1236
#define UDF_FI_FLAG_FI_MODIFIED
FileIdent was modified & should be flushed.
Definition: udf_rel.h:217
lb_addr FileEntryLoc
Definition: udf_rel.h:178
#define lba
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
OSSTATUS UDFBuildAllocDescs(IN PVCB Vcb, IN uint32 PartNum, IN OUT PUDF_FILE_INFO FileInfo, OUT int8 **AllocData)
Definition: extent.cpp:2628
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:1092
#define OSSTATUS
Definition: env_spec_w32.h:57
int64 UDFGetExtentLength(IN PEXTENT_MAP Extent)
Definition: extent.cpp:142
#define UDF_FE_FLAG_FE_MODIFIED
Was modified & should be flushed.
Definition: udf_rel.h:323
#define AS_BAD
Definition: udf_info.h:329
#define ICB_FLAG_AD_IN_ICB
Definition: ecma_167.h:496
void UDFRelocateDloc(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc, IN uint32 NewLba)
Definition: dirtree.cpp:1374
#define UDFGetBadBit(arr, bit)
Definition: udf_info.h:1205
void UDFSetAllocDescLen(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1277
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define UDF_VCB_IC_W2K_COMPAT_ALLOC_DESCS
Definition: udf_common.h:501
#define BrutePoint()
Definition: env_spec_w32.h:504
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
#define UDFMarkSpaceAsXXX(Vcb, FileInfo, Map, asXXX)
Definition: udf_info.h:322
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short uint16
Definition: types.h:30
uint32 logicalBlockNum
Definition: ecma_167.h:362
OSSTATUS UDFWriteExtent(IN PVCB Vcb, IN PEXTENT_INFO ExtInfo, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
Definition: extent.cpp:3186
OSSTATUS UDFReTagDirectory(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:895
uint8 FI_Flags
Definition: udf_rel.h:199
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
#define ICB_FLAG_ALLOC_MASK
Definition: ecma_167.h:480
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159
char int8
Definition: platform.h:10
Definition: ps.c:97

Referenced by UDFCloseFile__(), UDFCreateFile__(), and UDFFlushFile__().

◆ UDFFlushFI()

OSSTATUS UDFFlushFI ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo,
IN uint32  PartNum 
)

Definition at line 4051 of file udf_info.cpp.

4056 {
4057  PUDF_FILE_INFO DirInfo = FileInfo->ParentFile;
4058  PDIR_INDEX_ITEM DirNdx;
4059  OSSTATUS status;
4060  SIZE_T WrittenBytes;
4061  // use WrittenBytes variable to store LBA of FI to be recorded
4062  #define lba WrittenBytes
4063 
4064 // ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
4065  // some files has no FI
4066  if(!DirInfo || UDFIsAStreamDir(FileInfo))
4067  return STATUS_SUCCESS;
4068  DirNdx = UDFDirIndex(DirInfo->Dloc->DirIndex, FileInfo->Index);
4069 // ASSERT(FileInfo->FileIdent->lengthFileIdent < 0x80);
4070 #ifdef UDF_DBG
4071  if(DirNdx->FileCharacteristics & FILE_DELETED) {
4072  ASSERT(FileInfo->FileIdent->fileCharacteristics & FILE_DELETED);
4073  }
4074 #endif // UDF_DBG
4075  UDFPrint((" FlushFI: offs %x\n", (ULONG)(DirNdx->Offset)));
4076 #ifndef UDF_READ_ONLY_BUILD
4077  if((DirNdx->FI_Flags & UDF_FI_FLAG_FI_MODIFIED)) {
4078  // flush FileIdent
4079  ASSERT(PartNum != (uint32)(-1));
4080  FileInfo->FileIdent->fileCharacteristics = DirNdx->FileCharacteristics;
4082  DirNdx->Offset, NULL, NULL, NULL, NULL);
4083  AdPrint((" FI lba %x\n", lba));
4084  // check if requested Offset is allocated
4085  if(lba == (uint32)LBA_OUT_OF_EXTENT) {
4086  // write 1 byte
4087  if(!OS_SUCCESS(status = UDFWriteFile__(Vcb, DirInfo, DirNdx->Offset, 1, FALSE, (int8*)(FileInfo->FileIdent), &WrittenBytes) )) {
4088  BrutePoint();
4089  return status;
4090  }
4092  DirNdx->Offset, NULL, NULL, NULL, NULL);
4093  AdPrint((" allocated FI lba %x\n", lba));
4094  // check if requested Offset is allocated
4095  if(lba == (uint32)LBA_OUT_OF_EXTENT) {
4096  BrutePoint();
4097  return STATUS_UNSUCCESSFUL;
4098  }
4099  }
4100  // init structure
4101  UDFSetUpTag(Vcb, &(FileInfo->FileIdent->descTag), (uint16)(FileInfo->FileIdentLen),
4102  UDFPhysLbaToPart(Vcb, PartNum, lba));
4103  // record data
4104  if(!OS_SUCCESS(status = UDFWriteFile__(Vcb, DirInfo, DirNdx->Offset, FileInfo->FileIdentLen, FALSE, (int8*)(FileInfo->FileIdent), &WrittenBytes) )) {
4105  BrutePoint();
4106  return status;
4107  }
4108  DirNdx->FI_Flags &= ~UDF_FI_FLAG_FI_MODIFIED;
4109  }
4110 #endif //UDF_READ_ONLY_BUILD
4111  return STATUS_SUCCESS;
4112 } // end UDFFlushFI()
#define UDFPrint(Args)
Definition: udffs.h:225
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
unsigned int uint32
Definition: types.h:32
PDIR_INDEX_HDR DirIndex
Definition: udf_rel.h:312
void UDFSetUpTag(IN PVCB Vcb, IN tag *Tag, IN uint16 DataLen, IN uint32 TagLoc)
Definition: udf_info.cpp:936
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
PUDF_DATALOC_INFO Dloc
Definition: udf_rel.h:367
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
#define UDF_FI_FLAG_FI_MODIFIED
FileIdent was modified & should be flushed.
Definition: udf_rel.h:217
#define lba
PEXTENT_MAP Mapping
Definition: udf_rel.h:66
#define OSSTATUS
Definition: env_spec_w32.h:57
uint8 FileCharacteristics
Definition: udf_rel.h:182
smooth NULL
Definition: ftsmooth.c:416
#define FILE_DELETED
Definition: ecma_167.h:440
#define UDFIsAStreamDir(FI)
Definition: udf_info.h:998
EXTENT_INFO DataLoc
Definition: udf_rel.h:262
#define Vcb
Definition: cdprocs.h:1425
#define BrutePoint()
Definition: env_spec_w32.h:504
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
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
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
uint32 Offset
Definition: udf_rel.h:161
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short uint16
Definition: types.h:30
unsigned int ULONG
Definition: retypes.h:1
uint8 FI_Flags
Definition: udf_rel.h:199
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
uint32 UDFPhysLbaToPart(IN PVCB Vcb, IN uint32 PartNum, IN uint32 Addr)
Definition: alloc.cpp:46
char int8
Definition: platform.h:10
#define LBA_OUT_OF_EXTENT
Definition: udf_rel.h:426
Definition: ps.c:97

Referenced by UDFCloseFile__(), UDFCreateFile__(), UDFFlushFile__(), and UDFRenameMoveFile__().

◆ UDFFlushFile__()

OSSTATUS UDFFlushFile__ ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo,
IN ULONG  FlushFlags 
)

Definition at line 4119 of file udf_info.cpp.

4124 {
4126 
4127  if(!FileInfo) return STATUS_SUCCESS;
4128  OSSTATUS status;
4129  uint32 PartNum;
4130 
4131  ASSERT(FileInfo->Dloc->FELoc.Mapping[0].extLocation);
4132  PartNum = UDFGetPartNumByPhysLba(Vcb, FileInfo->Dloc->FELoc.Mapping[0].extLocation);
4133  if(PartNum == (uint32)-1) {
4134  UDFPrint((" Is DELETED ?\n"));
4135  if(FileInfo->ParentFile) {
4136  PartNum = UDFGetPartNumByPhysLba(Vcb, FileInfo->ParentFile->Dloc->FELoc.Mapping[0].extLocation);
4137  } else {
4138  BrutePoint();
4139  }
4140  }
4141 #ifdef UDF_CHECK_DISK_ALLOCATION
4142  if( FileInfo->Fcb &&
4143  UDFGetFreeBit(((uint32*)(Vcb->FSBM_Bitmap)), FileInfo->Dloc->FELoc.Mapping[0].extLocation)) {
4144 
4145  if(UDFIsAStreamDir(FileInfo)) {
4146  if(!UDFIsSDirDeleted(FileInfo)) {
4147  UDFPrint((" Not DELETED SDir\n"));
4148  BrutePoint();
4149  }
4150  ASSERT(!FileInfo->Dloc->FELoc.Modified);
4151  } else
4152  if(!FileInfo->FileIdent ||
4153  !(FileInfo->FileIdent->fileCharacteristics & FILE_DELETED)) {
4154  if(!FileInfo->FileIdent)
4155  AdPrint((" No FileIdent\n"));
4156  if(FileInfo->FileIdent &&
4157  !(FileInfo->FileIdent->fileCharacteristics & FILE_DELETED))
4158  AdPrint((" Not DELETED\n"));
4159  AdPrint(("Flushing to Discarded block %x\n", FileInfo->Dloc->FELoc.Mapping[0].extLocation));
4160  BrutePoint();
4161  }
4162  }
4163 #endif // UDF_CHECK_DISK_ALLOCATION
4164 
4165  // flush FE and pre-allocation charge for directories
4166  if(FileInfo->Dloc &&
4167  FileInfo->Dloc->DirIndex) {
4168  // if Lite Flush is used, keep preallocations
4169  if(!(FlushFlags & UDF_FLUSH_FLAGS_LITE)) {
4170 full_flush:
4171  UDFFlushFESpace(Vcb, FileInfo->Dloc);
4172  if(FileInfo->Dloc->DataLoc.Flags & EXTENT_FLAG_PREALLOCATED) {
4173  FileInfo->Dloc->DataLoc.Flags |= EXTENT_FLAG_CUT_PREALLOCATED;
4174  status = UDFResizeExtent(Vcb, PartNum, UDFGetFileSize(FileInfo), FALSE, &(FileInfo->Dloc->DataLoc));
4175  FileInfo->Dloc->DataLoc.Flags &= ~(EXTENT_FLAG_PREALLOCATED | EXTENT_FLAG_CUT_PREALLOCATED);
4176  if(OS_SUCCESS(status)) {
4177  AdPrint(("Dir pre-alloc truncated (Flush)\n"));
4178  FileInfo->Dloc->DataLoc.Modified = TRUE;
4179  }
4180  }
4181  }
4182  }
4183  // flush FE
4184  if(!OS_SUCCESS(status = UDFFlushFE(Vcb, FileInfo, PartNum))) {
4185  UDFPrint(("Error flushing FE\n"));
4186  BrutePoint();
4187  if(FlushFlags & UDF_FLUSH_FLAGS_LITE) {
4188  UDFPrint((" flush pre-alloc\n"));
4189  FlushFlags &= ~UDF_FLUSH_FLAGS_LITE;
4190  goto full_flush;
4191  }
4192  if(FileInfo->Index >= 2) {
4193  PDIR_INDEX_ITEM DirNdx;
4195  if(DirNdx) {
4196  UDFPrint(("Recovery: mark as deleted & flush FI\n"));
4197  DirNdx->FI_Flags |= UDF_FI_FLAG_FI_MODIFIED;
4198  DirNdx->FileCharacteristics |= FILE_DELETED;
4199  FileInfo->FileIdent->fileCharacteristics |= FILE_DELETED;
4200  UDFFlushFI(Vcb, FileInfo, PartNum);
4201  }
4202  }
4203  return status;
4204  }
4205  if(!OS_SUCCESS(status = UDFFlushFI(Vcb, FileInfo, PartNum)))
4206  return status;
4207 
4208  ASSERT((FileInfo->Dloc->FileEntry->descVersion == 2) ||
4209  (FileInfo->Dloc->FileEntry->descVersion == 3));
4210 
4211  return STATUS_SUCCESS;
4212 } // end UDFFlushFile__()
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
unsigned int uint32
Definition: types.h:32
OSSTATUS UDFResizeExtent(IN PVCB Vcb, IN uint32 PartNum, IN int64 Length, IN BOOLEAN AlwaysInIcb, OUT PEXTENT_INFO ExtInfo)
Definition: extent.cpp:2235
OSSTATUS UDFFlushFI(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
Definition: udf_info.cpp:4051
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
#define UDF_FLUSH_FLAGS_LITE
Definition: struct.h:341
int64 UDFGetFileSize(IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1236
#define UDF_FI_FLAG_FI_MODIFIED
FileIdent was modified & should be flushed.
Definition: udf_rel.h:217
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:1092
#define OSSTATUS
Definition: env_spec_w32.h:57
uint8 FileCharacteristics
Definition: udf_rel.h:182
#define FILE_DELETED
Definition: ecma_167.h:440
#define UDFIsAStreamDir(FI)
Definition: udf_info.h:998
#define Vcb
Definition: cdprocs.h:1425
#define BrutePoint()
Definition: env_spec_w32.h:504
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
#define UDFIsSDirDeleted(FI)
Definition: udf_info.h:1004
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
OSSTATUS UDFFlushFE(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN uint32 PartNum)
Definition: udf_info.cpp:3864
#define EXTENT_FLAG_CUT_PREALLOCATED
Definition: udf_rel.h:80
void UDFFlushFESpace(IN PVCB Vcb, IN PUDF_DATALOC_INFO Dloc, IN BOOLEAN Discard)
Definition: extent.cpp:1776
#define UDFGetFreeBit(arr, bit)
Definition: udf_info.h:1199
#define EXTENT_FLAG_PREALLOCATED
Definition: udf_rel.h:79
uint32 __fastcall UDFGetPartNumByPhysLba(IN PVCB Vcb, IN uint32 Lba)
Definition: alloc.cpp:201
uint8 FI_Flags
Definition: udf_rel.h:199
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by UDFCleanUpFcbChain(), UDFCommonCleanup(), UDFCommonCreate(), UDFFlushADirectory(), UDFFlushAFile(), UDFRecordVAT(), UDFRenameMoveFile__(), UDFUnlinkAllFilesInDir(), UDFUnlinkFile__(), UDFUpdateNonAllocated(), and UDFWriteSecurity().

◆ UDFGetFileEALength()

uint32 UDFGetFileEALength ( IN PUDF_FILE_INFO  FileInfo)

Definition at line 1420 of file udf_info.cpp.

1423 {
1424  uint16 Ident;
1425 
1427 
1428  if(!FileInfo->Dloc->FileEntry)
1429  return 1;
1430  Ident = FileInfo->Dloc->FileEntry->tagIdent;
1431 
1432  if(Ident == TID_FILE_ENTRY) {
1433  return ((PFILE_ENTRY)(FileInfo->Dloc->FileEntry))->lengthExtendedAttr;
1434  } else if(Ident == TID_EXTENDED_FILE_ENTRY) {
1435  return ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->lengthExtendedAttr;
1436  }
1437  return 0;
1438 } // end UDFGetFileEALength()
#define TID_EXTENDED_FILE_ENTRY
Definition: ecma_167.h:175
Definition: ecma_167.h:742
Definition: ecma_167.h:513
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
unsigned short uint16
Definition: types.h:30
#define TID_FILE_ENTRY
Definition: ecma_167.h:170

Referenced by UDFHardLinkFile__(), and UDFRenameMoveFile__().

◆ UDFGetFileLinkCount()

uint16 UDFGetFileLinkCount ( IN PUDF_FILE_INFO  FileInfo)

Definition at line 1355 of file udf_info.cpp.

1358 {
1359  uint16 Ident;
1360  uint16 d;
1361 
1363 
1364  if(!FileInfo->Dloc->FileEntry)
1365  return 1;
1366  Ident = FileInfo->Dloc->FileEntry->tagIdent;
1367  // UDF engine assumes that LinkCount is a counter
1368  // of FileIdents, referencing this FE.
1369  // UDF 2.0 states, that it should be counter of ALL
1370  // references (including SDir) - 1.
1371  // Thus we'll write to media UDF-required value, but return
1372  // cooked value to callers
1373  d = UDFHasAStreamDir(FileInfo) ? 0 : 1;
1374  if(Ident == TID_FILE_ENTRY) {
1375  return ((PFILE_ENTRY)(FileInfo->Dloc->FileEntry))->fileLinkCount + d;
1376  } else if(Ident == TID_EXTENDED_FILE_ENTRY) {
1377  return ((PEXTENDED_FILE_ENTRY)(FileInfo->Dloc->FileEntry))->fileLinkCount + d;
1378  }
1379  return UDF_INVALID_LINK_COUNT;
1380 } // end UDFGetFileLinkCount()
#define UDF_INVALID_LINK_COUNT
Definition: udf_rel.h:508
#define TID_EXTENDED_FILE_ENTRY
Definition: ecma_167.h:175
Definition: ecma_167.h:742
#define d
Definition: ke_i.h:81
Definition: ecma_167.h:513
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
unsigned short uint16
Definition: types.h:30
#define UDFHasAStreamDir(FI)
Definition: udf_info.h:1000
#define TID_FILE_ENTRY
Definition: ecma_167.h:170

Referenced by UDFCleanUpFile__(), UDFCloseFile__(), UDFCommonCleanup(), UDFFileDirInfoToNT(), UDFGetStandardInformation(), UDFHardLinkFile__(), UDFMarkStreamsForDeletion(), UDFOpenFile__(), UDFPrepareForRenameMoveLink(), UDFRenameMoveFile__(), UDFSetDispositionInformation(), UDFSetEOF(), and UDFUnlinkFile__().

◆ UDFGetFileSize()

int64 UDFGetFileSize ( IN