MdeModulePkg/UDF: Fix creation of UDF logical partition
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / UdfDxe / Udf.h
index 44c843fd4d33c7ab9cc24ef401c7daff44ffccaa..d441539d162de92e5a56b21d0519b870e639ca1b 100644 (file)
     { 0x89, 0x56, 0x73, 0xCD, 0xA3, 0x26, 0xCD, 0x0A }  \\r
   }\r
 \r
-#define UDF_DEFAULT_LV_NUM 0\r
-\r
-#define IS_PVD(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 1))\r
-#define IS_PD(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 5))\r
-#define IS_LVD(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 6))\r
-#define IS_TD(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 8))\r
-#define IS_FSD(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 256))\r
-#define IS_FE(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 261))\r
-#define IS_EFE(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 266))\r
-#define IS_FID(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 257))\r
-#define IS_AED(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 258))\r
-#define IS_LVID(_Pointer) \\r
-  ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 9))\r
-\r
-#define _GET_FILETYPE(_Pointer) \\r
-  (IS_FE (_Pointer) ? \\r
-   (((UDF_FILE_ENTRY *)(_Pointer))->IcbTag.FileType) \\r
-   : \\r
-   (((UDF_EXTENDED_FILE_ENTRY *)(_Pointer))->IcbTag.FileType))\r
-\r
-#define IS_FE_DIRECTORY(_Pointer) \\r
-  ((BOOLEAN)(_GET_FILETYPE (_Pointer) == 4))\r
-#define IS_FE_STANDARD_FILE(_Pointer) \\r
-  ((BOOLEAN)(_GET_FILETYPE (_Pointer) == 5))\r
-#define IS_FE_SYMLINK(_Pointer) \\r
-  ((BOOLEAN)(_GET_FILETYPE (_Pointer) == 12))\r
+#define FE_ICB_FILE_TYPE(_Ptr)                                      \\r
+  (UDF_FILE_ENTRY_TYPE)(                                            \\r
+    ((UDF_DESCRIPTOR_TAG *)(_Ptr))->TagIdentifier == UdfFileEntry ? \\r
+    ((UDF_FILE_ENTRY *)(_Ptr))->IcbTag.FileType :                   \\r
+    ((UDF_EXTENDED_FILE_ENTRY *)(_Ptr))->IcbTag.FileType)\r
+\r
+typedef enum {\r
+  UdfFileEntryDirectory = 4,\r
+  UdfFileEntryStandardFile = 5,\r
+  UdfFileEntrySymlink = 12,\r
+} UDF_FILE_ENTRY_TYPE;\r
 \r
 #define HIDDEN_FILE     (1 << 0)\r
 #define DIRECTORY_FILE  (1 << 1)\r
 #define DELETED_FILE    (1 << 2)\r
 #define PARENT_FILE     (1 << 3)\r
 \r
-#define _GET_FILE_CHARS(_Pointer) \\r
-  (((UDF_FILE_IDENTIFIER_DESCRIPTOR *)(_Pointer))->FileCharacteristics)\r
-\r
-#define IS_FID_HIDDEN_FILE(_Pointer) \\r
-  ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & HIDDEN_FILE))\r
-#define IS_FID_DIRECTORY_FILE(_Pointer) \\r
-  ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & DIRECTORY_FILE))\r
-#define IS_FID_DELETED_FILE(_Pointer) \\r
-  ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & DELETED_FILE))\r
-#define IS_FID_PARENT_FILE(_Pointer) \\r
-  ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & PARENT_FILE))\r
-#define IS_FID_NORMAL_FILE(_Pointer) \\r
-  ((BOOLEAN)(!IS_FID_DIRECTORY_FILE (_Pointer) && \\r
-         !IS_FID_PARENT_FILE (_Pointer)))\r
+#define IS_FID_HIDDEN_FILE(_Fid) \\r
+  (BOOLEAN)((_Fid)->FileCharacteristics & HIDDEN_FILE)\r
+#define IS_FID_DIRECTORY_FILE(_Fid) \\r
+  (BOOLEAN)((_Fid)->FileCharacteristics & DIRECTORY_FILE)\r
+#define IS_FID_DELETED_FILE(_Fid) \\r
+  (BOOLEAN)((_Fid)->FileCharacteristics & DELETED_FILE)\r
+#define IS_FID_PARENT_FILE(_Fid) \\r
+  (BOOLEAN)((_Fid)->FileCharacteristics & PARENT_FILE)\r
+#define IS_FID_NORMAL_FILE(_Fid) \\r
+  (BOOLEAN)(!IS_FID_DIRECTORY_FILE (_Fid) && \\r
+            !IS_FID_PARENT_FILE (_Fid))\r
 \r
 typedef enum {\r
   ShortAdsSequence,\r
@@ -152,14 +125,8 @@ typedef enum {
 #define IS_VALID_COMPRESSION_ID(_CompId) \\r
   ((BOOLEAN)((_CompId) == 8 || (_CompId) == 16))\r
 \r
-#define LV_BLOCK_SIZE(_Vol, _LvNum) \\r
-  (_Vol)->LogicalVolDescs[(_LvNum)]->LogicalBlockSize\r
-\r
 #define UDF_STANDARD_IDENTIFIER_LENGTH   5\r
 \r
-#define LV_UDF_REVISION(_Lv) \\r
-  *(UINT16 *)(UINTN)(_Lv)->DomainIdentifier.IdentifierSuffix\r
-\r
 #pragma pack(1)\r
 \r
 typedef struct {\r
@@ -185,17 +152,6 @@ typedef struct {
 \r
 #pragma pack(1)\r
 \r
-typedef struct {\r
-  UINT8           CharacterSetType;\r
-  UINT8           CharacterSetInfo[63];\r
-} UDF_CHAR_SPEC;\r
-\r
-typedef struct {\r
-  UINT8           Flags;\r
-  UINT8           Identifier[23];\r
-  UINT8           IdentifierSuffix[8];\r
-} UDF_ENTITY_ID;\r
-\r
 typedef struct {\r
   UINT16          TypeAndTimezone;\r
   INT16           Year;\r
@@ -209,17 +165,6 @@ typedef struct {
   UINT8           Microseconds;\r
 } UDF_TIMESTAMP;\r
 \r
-typedef struct {\r
-  UINT32        LogicalBlockNumber;\r
-  UINT16        PartitionReferenceNumber;\r
-} UDF_LB_ADDR;\r
-\r
-typedef struct {\r
-  UINT32                           ExtentLength;\r
-  UDF_LB_ADDR                      ExtentLocation;\r
-  UINT8                            ImplementationUse[6];\r
-} UDF_LONG_ALLOCATION_DESCRIPTOR;\r
-\r
 typedef struct {\r
   UDF_DESCRIPTOR_TAG                 DescriptorTag;\r
   UINT32                             PrevAllocationExtentDescriptor;\r
@@ -234,6 +179,17 @@ typedef struct {
   UINT8                   StructureData[2040];\r
 } UDF_VOLUME_DESCRIPTOR;\r
 \r
+typedef struct {\r
+  UDF_DESCRIPTOR_TAG             DescriptorTag;\r
+  UDF_TIMESTAMP                  RecordingDateTime;\r
+  UINT32                         IntegrityType;\r
+  UDF_EXTENT_AD                  NextIntegrityExtent;\r
+  UINT8                          LogicalVolumeContentsUse[32];\r
+  UINT32                         NumberOfPartitions;\r
+  UINT32                         LengthOfImplementationUse;\r
+  UINT8                          Data[0];\r
+} UDF_LOGICAL_VOLUME_INTEGRITY;\r
+\r
 typedef struct {\r
   UDF_DESCRIPTOR_TAG         DescriptorTag;\r
   UINT32                     VolumeDescriptorSequenceNumber;\r
@@ -249,33 +205,6 @@ typedef struct {
   UINT8                      Reserved[156];\r
 } UDF_PARTITION_DESCRIPTOR;\r
 \r
-typedef struct {\r
-  UDF_DESCRIPTOR_TAG              DescriptorTag;\r
-  UINT32                          VolumeDescriptorSequenceNumber;\r
-  UDF_CHAR_SPEC                   DescriptorCharacterSet;\r
-  UINT8                           LogicalVolumeIdentifier[128];\r
-  UINT32                          LogicalBlockSize;\r
-  UDF_ENTITY_ID                   DomainIdentifier;\r
-  UDF_LONG_ALLOCATION_DESCRIPTOR  LogicalVolumeContentsUse;\r
-  UINT32                          MapTableLength;\r
-  UINT32                          NumberOfPartitionMaps;\r
-  UDF_ENTITY_ID                   ImplementationIdentifier;\r
-  UINT8                           ImplementationUse[128];\r
-  UDF_EXTENT_AD                   IntegritySequenceExtent;\r
-  UINT8                           PartitionMaps[6];\r
-} UDF_LOGICAL_VOLUME_DESCRIPTOR;\r
-\r
-typedef struct {\r
-  UDF_DESCRIPTOR_TAG             DescriptorTag;\r
-  UDF_TIMESTAMP                  RecordingDateTime;\r
-  UINT32                         IntegrityType;\r
-  UDF_EXTENT_AD                  NextIntegrityExtent;\r
-  UINT8                          LogicalVolumeContentsUse[32];\r
-  UINT32                         NumberOfPartitions;\r
-  UINT32                         LengthOfImplementationUse;\r
-  UINT8                          Data[0];\r
-} UDF_LOGICAL_VOLUME_INTEGRITY;\r
-\r
 typedef struct {\r
   UDF_DESCRIPTOR_TAG              DescriptorTag;\r
   UDF_TIMESTAMP                   RecordingDateAndTime;\r
@@ -389,12 +318,10 @@ typedef struct {
 // UDF filesystem driver's private data\r
 //\r
 typedef struct {\r
-  UDF_LOGICAL_VOLUME_DESCRIPTOR  **LogicalVolDescs;\r
-  UINTN                          LogicalVolDescsNo;\r
-  UDF_PARTITION_DESCRIPTOR       **PartitionDescs;\r
-  UINTN                          PartitionDescsNo;\r
-  UDF_FILE_SET_DESCRIPTOR        **FileSetDescs;\r
-  UINTN                          FileSetDescsNo;\r
+  UINT64                         MainVdsStartLocation;\r
+  UDF_LOGICAL_VOLUME_DESCRIPTOR  LogicalVolDesc;\r
+  UDF_PARTITION_DESCRIPTOR       PartitionDesc;\r
+  UDF_FILE_SET_DESCRIPTOR        FileSetDesc;\r
   UINTN                          FileEntrySize;\r
 } UDF_VOLUME_INFO;\r
 \r
@@ -883,17 +810,6 @@ ResolveSymlink (
   OUT  UDF_FILE_INFO          *File\r
   );\r
 \r
-/**\r
-  Clean up in-memory UDF volume information.\r
-\r
-  @param[in] Volume Volume information pointer.\r
-\r
-**/\r
-VOID\r
-CleanupVolumeInformation (\r
-  IN UDF_VOLUME_INFO *Volume\r
-  );\r
-\r
 /**\r
   Clean up in-memory UDF file information.\r
 \r