2 UDF/ECMA-167 file system driver.
4 Copyright (C) 2014-2017 Paulo Alcantara <pcacjr@zytor.com>
6 This program and the accompanying materials are licensed and made available
7 under the terms and conditions of the BSD License which accompanies this
8 distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
12 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Protocol/BlockIo.h>
22 #include <Protocol/ComponentName.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/DriverBinding.h>
25 #include <Protocol/DiskIo.h>
26 #include <Protocol/SimpleFileSystem.h>
28 #include <Guid/FileInfo.h>
29 #include <Guid/FileSystemInfo.h>
30 #include <Guid/FileSystemVolumeLabelInfo.h>
32 #include <Library/DebugLib.h>
33 #include <Library/UefiDriverEntryPoint.h>
34 #include <Library/BaseLib.h>
35 #include <Library/UefiLib.h>
36 #include <Library/BaseMemoryLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/UefiBootServicesTableLib.h>
39 #include <Library/DevicePathLib.h>
41 #include <IndustryStandard/ElTorito.h>
42 #include <IndustryStandard/Udf.h>
45 // C5BD4D42-1A76-4996-8956-73CDA326CD0A
47 #define EFI_UDF_DEVICE_PATH_GUID \
48 { 0xC5BD4D42, 0x1A76, 0x4996, \
49 { 0x89, 0x56, 0x73, 0xCD, 0xA3, 0x26, 0xCD, 0x0A } \
52 #define UDF_DEFAULT_LV_NUM 0
54 #define IS_PVD(_Pointer) \
55 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 1))
56 #define IS_PD(_Pointer) \
57 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 5))
58 #define IS_LVD(_Pointer) \
59 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 6))
60 #define IS_TD(_Pointer) \
61 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 8))
62 #define IS_FSD(_Pointer) \
63 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 256))
64 #define IS_FE(_Pointer) \
65 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 261))
66 #define IS_EFE(_Pointer) \
67 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 266))
68 #define IS_FID(_Pointer) \
69 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 257))
70 #define IS_AED(_Pointer) \
71 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 258))
72 #define IS_LVID(_Pointer) \
73 ((BOOLEAN)(_GET_TAG_ID (_Pointer) == 9))
75 #define _GET_FILETYPE(_Pointer) \
77 (((UDF_FILE_ENTRY *)(_Pointer))->IcbTag.FileType) \
79 (((UDF_EXTENDED_FILE_ENTRY *)(_Pointer))->IcbTag.FileType))
81 #define IS_FE_DIRECTORY(_Pointer) \
82 ((BOOLEAN)(_GET_FILETYPE (_Pointer) == 4))
83 #define IS_FE_STANDARD_FILE(_Pointer) \
84 ((BOOLEAN)(_GET_FILETYPE (_Pointer) == 5))
85 #define IS_FE_SYMLINK(_Pointer) \
86 ((BOOLEAN)(_GET_FILETYPE (_Pointer) == 12))
88 #define HIDDEN_FILE (1 << 0)
89 #define DIRECTORY_FILE (1 << 1)
90 #define DELETED_FILE (1 << 2)
91 #define PARENT_FILE (1 << 3)
93 #define _GET_FILE_CHARS(_Pointer) \
94 (((UDF_FILE_IDENTIFIER_DESCRIPTOR *)(_Pointer))->FileCharacteristics)
96 #define IS_FID_HIDDEN_FILE(_Pointer) \
97 ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & HIDDEN_FILE))
98 #define IS_FID_DIRECTORY_FILE(_Pointer) \
99 ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & DIRECTORY_FILE))
100 #define IS_FID_DELETED_FILE(_Pointer) \
101 ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & DELETED_FILE))
102 #define IS_FID_PARENT_FILE(_Pointer) \
103 ((BOOLEAN)(_GET_FILE_CHARS (_Pointer) & PARENT_FILE))
104 #define IS_FID_NORMAL_FILE(_Pointer) \
105 ((BOOLEAN)(!IS_FID_DIRECTORY_FILE (_Pointer) && \
106 !IS_FID_PARENT_FILE (_Pointer)))
111 EXTENDED_ADS_SEQUENCE
,
113 } UDF_FE_RECORDING_FLAGS
;
115 #define GET_FE_RECORDING_FLAGS(_Fe) \
116 ((UDF_FE_RECORDING_FLAGS)((UDF_ICB_TAG *)( \
118 sizeof (UDF_DESCRIPTOR_TAG)))->Flags & 0x07)
121 EXTENT_RECORDED_AND_ALLOCATED
,
122 EXTENT_NOT_RECORDED_BUT_ALLOCATED
,
123 EXTENT_NOT_RECORDED_NOT_ALLOCATED
,
124 EXTENT_IS_NEXT_EXTENT
,
127 #define AD_LENGTH(_RecFlags) \
128 ((_RecFlags) == SHORT_ADS_SEQUENCE ? \
129 ((UINT64)(sizeof (UDF_SHORT_ALLOCATION_DESCRIPTOR))) : \
130 ((UINT64)(sizeof (UDF_LONG_ALLOCATION_DESCRIPTOR))))
132 #define GET_EXTENT_FLAGS(_RecFlags, _Ad) \
133 ((_RecFlags) == SHORT_ADS_SEQUENCE ? \
134 ((UDF_EXTENT_FLAGS)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
136 ((UDF_EXTENT_FLAGS)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
139 #define GET_EXTENT_LENGTH(_RecFlags, _Ad) \
140 ((_RecFlags) == SHORT_ADS_SEQUENCE ? \
141 ((UINT32)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
143 ((UINT32)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
146 #define UDF_FILENAME_LENGTH 128
147 #define UDF_PATH_LENGTH 512
149 #define GET_FID_FROM_ADS(_Data, _Offs) \
150 ((UDF_FILE_IDENTIFIER_DESCRIPTOR *)((UINT8 *)(_Data) + (_Offs)))
152 #define IS_VALID_COMPRESSION_ID(_CompId) \
153 ((BOOLEAN)((_CompId) == 8 || (_CompId) == 16))
155 #define LV_BLOCK_SIZE(_Vol, _LvNum) \
156 (_Vol)->LogicalVolDescs[(_LvNum)]->LogicalBlockSize
158 #define UDF_STANDARD_IDENTIFIER_LENGTH 5
160 #define LV_UDF_REVISION(_Lv) \
161 *(UINT16 *)(UINTN)(_Lv)->DomainIdentifier.IdentifierSuffix
166 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
167 } UDF_STANDARD_IDENTIFIER
;
172 READ_FILE_GET_FILESIZE
,
173 READ_FILE_ALLOCATE_AND_READ
,
174 READ_FILE_SEEK_AND_READ
,
175 } UDF_READ_FILE_FLAGS
;
179 UDF_READ_FILE_FLAGS Flags
;
184 } UDF_READ_FILE_INFO
;
189 UINT8 CharacterSetType
;
190 UINT8 CharacterSetInfo
[63];
195 UINT8 Identifier
[23];
196 UINT8 IdentifierSuffix
[8];
200 UINT16 TypeAndTimezone
;
208 UINT8 HundredsOfMicroseconds
;
213 UINT32 LogicalBlockNumber
;
214 UINT16 PartitionReferenceNumber
;
219 UDF_LB_ADDR ExtentLocation
;
220 UINT8 ImplementationUse
[6];
221 } UDF_LONG_ALLOCATION_DESCRIPTOR
;
224 UDF_DESCRIPTOR_TAG DescriptorTag
;
225 UINT32 PrevAllocationExtentDescriptor
;
226 UINT32 LengthOfAllocationDescriptors
;
227 } UDF_ALLOCATION_EXTENT_DESCRIPTOR
;
231 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
232 UINT8 StructureVersion
;
234 UINT8 StructureData
[2040];
235 } UDF_VOLUME_DESCRIPTOR
;
238 UDF_DESCRIPTOR_TAG DescriptorTag
;
239 UINT32 VolumeDescriptorSequenceNumber
;
240 UINT16 PartitionFlags
;
241 UINT16 PartitionNumber
;
242 UDF_ENTITY_ID PartitionContents
;
243 UINT8 PartitionContentsUse
[128];
245 UINT32 PartitionStartingLocation
;
246 UINT32 PartitionLength
;
247 UDF_ENTITY_ID ImplementationIdentifier
;
248 UINT8 ImplementationUse
[128];
250 } UDF_PARTITION_DESCRIPTOR
;
253 UDF_DESCRIPTOR_TAG DescriptorTag
;
254 UINT32 VolumeDescriptorSequenceNumber
;
255 UDF_CHAR_SPEC DescriptorCharacterSet
;
256 UINT8 LogicalVolumeIdentifier
[128];
257 UINT32 LogicalBlockSize
;
258 UDF_ENTITY_ID DomainIdentifier
;
259 UDF_LONG_ALLOCATION_DESCRIPTOR LogicalVolumeContentsUse
;
260 UINT32 MapTableLength
;
261 UINT32 NumberOfPartitionMaps
;
262 UDF_ENTITY_ID ImplementationIdentifier
;
263 UINT8 ImplementationUse
[128];
264 UDF_EXTENT_AD IntegritySequenceExtent
;
265 UINT8 PartitionMaps
[6];
266 } UDF_LOGICAL_VOLUME_DESCRIPTOR
;
269 UDF_DESCRIPTOR_TAG DescriptorTag
;
270 UDF_TIMESTAMP RecordingDateTime
;
271 UINT32 IntegrityType
;
272 UDF_EXTENT_AD NextIntegrityExtent
;
273 UINT8 LogicalVolumeContentsUse
[32];
274 UINT32 NumberOfPartitions
;
275 UINT32 LengthOfImplementationUse
;
277 } UDF_LOGICAL_VOLUME_INTEGRITY
;
280 UDF_DESCRIPTOR_TAG DescriptorTag
;
281 UDF_TIMESTAMP RecordingDateAndTime
;
282 UINT16 InterchangeLevel
;
283 UINT16 MaximumInterchangeLevel
;
284 UINT32 CharacterSetList
;
285 UINT32 MaximumCharacterSetList
;
286 UINT32 FileSetNumber
;
287 UINT32 FileSetDescriptorNumber
;
288 UDF_CHAR_SPEC LogicalVolumeIdentifierCharacterSet
;
289 UINT8 LogicalVolumeIdentifier
[128];
290 UDF_CHAR_SPEC FileSetCharacterSet
;
291 UINT8 FileSetIdentifier
[32];
292 UINT8 CopyrightFileIdentifier
[32];
293 UINT8 AbstractFileIdentifier
[32];
294 UDF_LONG_ALLOCATION_DESCRIPTOR RootDirectoryIcb
;
295 UDF_ENTITY_ID DomainIdentifier
;
296 UDF_LONG_ALLOCATION_DESCRIPTOR NextExtent
;
297 UDF_LONG_ALLOCATION_DESCRIPTOR SystemStreamDirectoryIcb
;
299 } UDF_FILE_SET_DESCRIPTOR
;
303 UINT32 ExtentPosition
;
304 } UDF_SHORT_ALLOCATION_DESCRIPTOR
;
307 UDF_DESCRIPTOR_TAG DescriptorTag
;
308 UINT16 FileVersionNumber
;
309 UINT8 FileCharacteristics
;
310 UINT8 LengthOfFileIdentifier
;
311 UDF_LONG_ALLOCATION_DESCRIPTOR Icb
;
312 UINT16 LengthOfImplementationUse
;
314 } UDF_FILE_IDENTIFIER_DESCRIPTOR
;
317 UINT32 PriorRecordNumberOfDirectEntries
;
319 UINT16 StrategyParameter
;
320 UINT16 MaximumNumberOfEntries
;
323 UDF_LB_ADDR ParentIcbLocation
;
328 UDF_DESCRIPTOR_TAG DescriptorTag
;
333 UINT16 FileLinkCount
;
335 UINT8 RecordDisplayAttributes
;
337 UINT64 InformationLength
;
338 UINT64 LogicalBlocksRecorded
;
339 UDF_TIMESTAMP AccessTime
;
340 UDF_TIMESTAMP ModificationTime
;
341 UDF_TIMESTAMP AttributeTime
;
343 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
344 UDF_ENTITY_ID ImplementationIdentifier
;
346 UINT32 LengthOfExtendedAttributes
;
347 UINT32 LengthOfAllocationDescriptors
;
348 UINT8 Data
[0]; // L_EA + L_AD
352 UDF_DESCRIPTOR_TAG DescriptorTag
;
357 UINT16 FileLinkCount
;
359 UINT8 RecordDisplayAttributes
;
361 UINT64 InformationLength
;
363 UINT64 LogicalBlocksRecorded
;
364 UDF_TIMESTAMP AccessTime
;
365 UDF_TIMESTAMP ModificationTime
;
366 UDF_TIMESTAMP CreationTime
;
367 UDF_TIMESTAMP AttributeTime
;
370 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
371 UDF_LONG_ALLOCATION_DESCRIPTOR StreamDirectoryIcb
;
372 UDF_ENTITY_ID ImplementationIdentifier
;
374 UINT32 LengthOfExtendedAttributes
;
375 UINT32 LengthOfAllocationDescriptors
;
376 UINT8 Data
[0]; // L_EA + L_AD
377 } UDF_EXTENDED_FILE_ENTRY
;
381 UINT8 LengthOfComponentIdentifier
;
382 UINT16 ComponentFileVersionNumber
;
383 UINT8 ComponentIdentifier
[0];
384 } UDF_PATH_COMPONENT
;
389 // UDF filesystem driver's private data
392 UDF_LOGICAL_VOLUME_DESCRIPTOR
**LogicalVolDescs
;
393 UINTN LogicalVolDescsNo
;
394 UDF_PARTITION_DESCRIPTOR
**PartitionDescs
;
395 UINTN PartitionDescsNo
;
396 UDF_FILE_SET_DESCRIPTOR
**FileSetDescs
;
397 UINTN FileSetDescsNo
;
403 UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
;
408 UINT64 DirectoryLength
;
410 } UDF_READ_DIRECTORY_INFO
;
412 #define PRIVATE_UDF_FILE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 'f')
414 #define PRIVATE_UDF_FILE_DATA_FROM_THIS(a) \
417 PRIVATE_UDF_FILE_DATA, \
419 PRIVATE_UDF_FILE_DATA_SIGNATURE \
424 BOOLEAN IsRootDirectory
;
427 UDF_READ_DIRECTORY_INFO ReadDirInfo
;
428 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFs
;
429 EFI_FILE_PROTOCOL FileIo
;
430 CHAR16 AbsoluteFileName
[UDF_PATH_LENGTH
];
431 CHAR16 FileName
[UDF_FILENAME_LENGTH
];
434 } PRIVATE_UDF_FILE_DATA
;
436 #define PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 's')
438 #define PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS(a) \
441 PRIVATE_UDF_SIMPLE_FS_DATA, \
443 PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE \
448 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
449 EFI_DISK_IO_PROTOCOL
*DiskIo
;
450 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs
;
451 UDF_VOLUME_INFO Volume
;
455 } PRIVATE_UDF_SIMPLE_FS_DATA
;
460 extern EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding
;
461 extern EFI_COMPONENT_NAME_PROTOCOL gUdfComponentName
;
462 extern EFI_COMPONENT_NAME2_PROTOCOL gUdfComponentName2
;
465 // Function Prototypes
469 Open the root directory on a volume.
471 @param This Protocol instance pointer.
472 @param Root Returns an Open file handle for the root directory
474 @retval EFI_SUCCESS The device was opened.
475 @retval EFI_UNSUPPORTED This volume does not support the file system.
476 @retval EFI_NO_MEDIA The device has no media.
477 @retval EFI_DEVICE_ERROR The device reported an error.
478 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
479 @retval EFI_ACCESS_DENIED The service denied access to the file.
480 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
486 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
487 OUT EFI_FILE_PROTOCOL
**Root
491 Opens a new file relative to the source file's location.
493 @param This The protocol instance pointer.
494 @param NewHandle Returns File Handle for FileName.
495 @param FileName Null terminated string. "\", ".", and ".." are supported.
496 @param OpenMode Open mode for file.
497 @param Attributes Only used for EFI_FILE_MODE_CREATE.
499 @retval EFI_SUCCESS The device was opened.
500 @retval EFI_NOT_FOUND The specified file could not be found on the device.
501 @retval EFI_NO_MEDIA The device has no media.
502 @retval EFI_MEDIA_CHANGED The media has changed.
503 @retval EFI_DEVICE_ERROR The device reported an error.
504 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
505 @retval EFI_ACCESS_DENIED The service denied access to the file.
506 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
507 @retval EFI_VOLUME_FULL The volume is full.
513 IN EFI_FILE_PROTOCOL
*This
,
514 OUT EFI_FILE_PROTOCOL
**NewHandle
,
521 Read data from the file.
523 @param This Protocol instance pointer.
524 @param BufferSize On input size of buffer, on output amount of data in buffer.
525 @param Buffer The buffer in which data is read.
527 @retval EFI_SUCCESS Data was read.
528 @retval EFI_NO_MEDIA The device has no media.
529 @retval EFI_DEVICE_ERROR The device reported an error.
530 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
531 @retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size.
537 IN EFI_FILE_PROTOCOL
*This
,
538 IN OUT UINTN
*BufferSize
,
543 Close the file handle.
545 @param This Protocol instance pointer.
547 @retval EFI_SUCCESS The file was closed.
553 IN EFI_FILE_PROTOCOL
*This
557 Close and delete the file handle.
559 @param This Protocol instance pointer.
561 @retval EFI_SUCCESS The file was closed and deleted.
562 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not
569 IN EFI_FILE_PROTOCOL
*This
573 Write data to a file.
575 @param This Protocol instance pointer.
576 @param BufferSize On input size of buffer, on output amount of data in buffer.
577 @param Buffer The buffer in which data to write.
579 @retval EFI_SUCCESS Data was written.
580 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
581 @retval EFI_NO_MEDIA The device has no media.
582 @retval EFI_DEVICE_ERROR The device reported an error.
583 @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
584 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
585 @retval EFI_WRITE_PROTECTED The device is write protected.
586 @retval EFI_ACCESS_DENIED The file was open for read only.
587 @retval EFI_VOLUME_FULL The volume is full.
593 IN EFI_FILE_PROTOCOL
*This
,
594 IN OUT UINTN
*BufferSize
,
599 Get file's current position.
601 @param This Protocol instance pointer.
602 @param Position Byte position from the start of the file.
604 @retval EFI_SUCCESS Position was updated.
605 @retval EFI_UNSUPPORTED Seek request for directories is not valid.
611 IN EFI_FILE_PROTOCOL
*This
,
616 Set file's current position.
618 @param This Protocol instance pointer.
619 @param Position Byte position from the start of the file.
621 @retval EFI_SUCCESS Position was updated.
622 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
628 IN EFI_FILE_PROTOCOL
*This
,
633 Get information about a file.
635 @param This Protocol instance pointer.
636 @param InformationType Type of information to return in Buffer.
637 @param BufferSize On input size of buffer, on output amount of data in buffer.
638 @param Buffer The buffer to return data.
640 @retval EFI_SUCCESS Data was returned.
641 @retval EFI_UNSUPPORTED InformationType is not supported.
642 @retval EFI_NO_MEDIA The device has no media.
643 @retval EFI_DEVICE_ERROR The device reported an error.
644 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
645 @retval EFI_WRITE_PROTECTED The device is write protected.
646 @retval EFI_ACCESS_DENIED The file was open for read only.
647 @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.
653 IN EFI_FILE_PROTOCOL
*This
,
654 IN EFI_GUID
*InformationType
,
655 IN OUT UINTN
*BufferSize
,
660 Set information about a file.
662 @param This Protocol instance pointer.
663 @param InformationType Type of information in Buffer.
664 @param BufferSize Size of buffer.
665 @param Buffer The data to write.
667 @retval EFI_SUCCESS Data was set.
668 @retval EFI_UNSUPPORTED InformationType is not supported.
669 @retval EFI_NO_MEDIA The device has no media.
670 @retval EFI_DEVICE_ERROR The device reported an error.
671 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
672 @retval EFI_WRITE_PROTECTED The device is write protected.
673 @retval EFI_ACCESS_DENIED The file was open for read only.
679 IN EFI_FILE_PROTOCOL
*This
,
680 IN EFI_GUID
*InformationType
,
686 Flush data back for the file handle.
688 @param This Protocol instance pointer.
690 @retval EFI_SUCCESS Data was flushed.
691 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
692 @retval EFI_NO_MEDIA The device has no media.
693 @retval EFI_DEVICE_ERROR The device reported an error.
694 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
695 @retval EFI_WRITE_PROTECTED The device is write protected.
696 @retval EFI_ACCESS_DENIED The file was open for read only.
697 @retval EFI_VOLUME_FULL The volume is full.
703 IN EFI_FILE_PROTOCOL
*This
707 Read volume information on a medium which contains a valid UDF file system.
709 @param[in] BlockIo BlockIo interface.
710 @param[in] DiskIo DiskIo interface.
711 @param[out] Volume UDF volume information structure.
713 @retval EFI_SUCCESS Volume information read.
714 @retval EFI_NO_MEDIA The device has no media.
715 @retval EFI_DEVICE_ERROR The device reported an error.
716 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
717 @retval EFI_OUT_OF_RESOURCES The volume was not read due to lack of resources.
721 ReadUdfVolumeInformation (
722 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
723 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
724 OUT UDF_VOLUME_INFO
*Volume
728 Find the root directory on an UDF volume.
730 @param[in] BlockIo BlockIo interface.
731 @param[in] DiskIo DiskIo interface.
732 @param[in] Volume UDF volume information structure.
733 @param[out] File Root directory file.
735 @retval EFI_SUCCESS Root directory found.
736 @retval EFI_NO_MEDIA The device has no media.
737 @retval EFI_DEVICE_ERROR The device reported an error.
738 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
739 @retval EFI_OUT_OF_RESOURCES The root directory was not found due to lack of
745 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
746 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
747 IN UDF_VOLUME_INFO
*Volume
,
748 OUT UDF_FILE_INFO
*File
752 Find either a File Entry or a Extended File Entry from a given ICB.
754 @param[in] BlockIo BlockIo interface.
755 @param[in] DiskIo DiskIo interface.
756 @param[in] Volume UDF volume information structure.
757 @param[in] Icb ICB of the FID.
758 @param[out] FileEntry File Entry or Extended File Entry.
760 @retval EFI_SUCCESS File Entry or Extended File Entry found.
761 @retval EFI_NO_MEDIA The device has no media.
762 @retval EFI_DEVICE_ERROR The device reported an error.
763 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
764 @retval EFI_OUT_OF_RESOURCES The FE/EFE entry was not found due to lack of
770 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
771 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
772 IN UDF_VOLUME_INFO
*Volume
,
773 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
778 Find a file given its absolute path on an UDF volume.
780 @param[in] BlockIo BlockIo interface.
781 @param[in] DiskIo DiskIo interface.
782 @param[in] Volume UDF volume information structure.
783 @param[in] FilePath File's absolute path.
784 @param[in] Root Root directory file.
785 @param[in] Parent Parent directory file.
786 @param[in] Icb ICB of Parent.
787 @param[out] File Found file.
789 @retval EFI_SUCCESS FilePath was found.
790 @retval EFI_NO_MEDIA The device has no media.
791 @retval EFI_DEVICE_ERROR The device reported an error.
792 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
793 @retval EFI_OUT_OF_RESOURCES The FilePath file was not found due to lack of
799 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
800 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
801 IN UDF_VOLUME_INFO
*Volume
,
803 IN UDF_FILE_INFO
*Root
,
804 IN UDF_FILE_INFO
*Parent
,
805 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
806 OUT UDF_FILE_INFO
*File
810 Read a directory entry at a time on an UDF volume.
812 @param[in] BlockIo BlockIo interface.
813 @param[in] DiskIo DiskIo interface.
814 @param[in] Volume UDF volume information structure.
815 @param[in] ParentIcb ICB of the parent file.
816 @param[in] FileEntryData FE/EFE of the parent file.
817 @param[in, out] ReadDirInfo Next read directory listing structure
819 @param[out] FoundFid File Identifier Descriptor pointer.
821 @retval EFI_SUCCESS Directory entry read.
822 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
823 @retval EFI_NO_MEDIA The device has no media.
824 @retval EFI_DEVICE_ERROR The device reported an error.
825 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
826 @retval EFI_OUT_OF_RESOURCES The directory entry was not read due to lack of
832 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
833 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
834 IN UDF_VOLUME_INFO
*Volume
,
835 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*ParentIcb
,
836 IN VOID
*FileEntryData
,
837 IN OUT UDF_READ_DIRECTORY_INFO
*ReadDirInfo
,
838 OUT UDF_FILE_IDENTIFIER_DESCRIPTOR
**FoundFid
842 Get a filename (encoded in OSTA-compressed format) from a File Identifier
843 Descriptor on an UDF volume.
845 @param[in] FileIdentifierDesc File Identifier Descriptor pointer.
846 @param[out] FileName Decoded filename.
848 @retval EFI_SUCCESS Filename decoded and read.
849 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
853 IN UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
,
858 Resolve a symlink file on an UDF volume.
860 @param[in] BlockIo BlockIo interface.
861 @param[in] DiskIo DiskIo interface.
862 @param[in] Volume UDF volume information structure.
863 @param[in] Parent Parent file.
864 @param[in] FileEntryData FE/EFE structure pointer.
865 @param[out] File Resolved file.
867 @retval EFI_SUCCESS Symlink file resolved.
868 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
869 @retval EFI_NO_MEDIA The device has no media.
870 @retval EFI_DEVICE_ERROR The device reported an error.
871 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
872 @retval EFI_OUT_OF_RESOURCES The symlink file was not resolved due to lack of
878 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
879 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
880 IN UDF_VOLUME_INFO
*Volume
,
881 IN UDF_FILE_INFO
*Parent
,
882 IN VOID
*FileEntryData
,
883 OUT UDF_FILE_INFO
*File
887 Clean up in-memory UDF volume information.
889 @param[in] Volume Volume information pointer.
893 CleanupVolumeInformation (
894 IN UDF_VOLUME_INFO
*Volume
898 Clean up in-memory UDF file information.
900 @param[in] File File information pointer.
904 CleanupFileInformation (
905 IN UDF_FILE_INFO
*File
909 Find a file from its absolute path on an UDF volume.
911 @param[in] BlockIo BlockIo interface.
912 @param[in] DiskIo DiskIo interface.
913 @param[in] Volume UDF volume information structure.
914 @param[in] File File information structure.
915 @param[out] Size Size of the file.
917 @retval EFI_SUCCESS File size calculated and set in Size.
918 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
919 @retval EFI_NO_MEDIA The device has no media.
920 @retval EFI_DEVICE_ERROR The device reported an error.
921 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
922 @retval EFI_OUT_OF_RESOURCES The file size was not calculated due to lack of
928 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
929 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
930 IN UDF_VOLUME_INFO
*Volume
,
931 IN UDF_FILE_INFO
*File
,
936 Set information about a file on an UDF volume.
938 @param[in] File File pointer.
939 @param[in] FileSize Size of the file.
940 @param[in] FileName Filename of the file.
941 @param[in, out] BufferSize Size of the returned file infomation.
942 @param[out] Buffer Data of the returned file information.
944 @retval EFI_SUCCESS File information set.
945 @retval EFI_NO_MEDIA The device has no media.
946 @retval EFI_DEVICE_ERROR The device reported an error.
947 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
948 @retval EFI_OUT_OF_RESOURCES The file information was not set due to lack of
954 IN UDF_FILE_INFO
*File
,
957 IN OUT UINTN
*BufferSize
,
962 Get volume and free space size information of an UDF volume.
964 @param[in] BlockIo BlockIo interface.
965 @param[in] DiskIo DiskIo interface.
966 @param[in] Volume UDF volume information structure.
967 @param[out] VolumeSize Volume size.
968 @param[out] FreeSpaceSize Free space size.
970 @retval EFI_SUCCESS Volume and free space size calculated.
971 @retval EFI_NO_MEDIA The device has no media.
972 @retval EFI_DEVICE_ERROR The device reported an error.
973 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
974 @retval EFI_OUT_OF_RESOURCES The volume and free space size were not
975 calculated due to lack of resources.
980 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
981 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
982 IN UDF_VOLUME_INFO
*Volume
,
983 OUT UINT64
*VolumeSize
,
984 OUT UINT64
*FreeSpaceSize
988 Seek a file and read its data into memory on an UDF volume.
990 @param[in] BlockIo BlockIo interface.
991 @param[in] DiskIo DiskIo interface.
992 @param[in] Volume UDF volume information structure.
993 @param[in] File File information structure.
994 @param[in] FileSize Size of the file.
995 @param[in, out] FilePosition File position.
996 @param[in, out] Buffer File data.
997 @param[in, out] BufferSize Read size.
999 @retval EFI_SUCCESS File seeked and read.
1000 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
1001 @retval EFI_NO_MEDIA The device has no media.
1002 @retval EFI_DEVICE_ERROR The device reported an error.
1003 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
1004 @retval EFI_OUT_OF_RESOURCES The file's recorded data was not read due to lack
1010 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
1011 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
1012 IN UDF_VOLUME_INFO
*Volume
,
1013 IN UDF_FILE_INFO
*File
,
1015 IN OUT UINT64
*FilePosition
,
1016 IN OUT VOID
*Buffer
,
1017 IN OUT UINT64
*BufferSize
1021 Check if ControllerHandle supports an UDF file system.
1023 @param[in] This Protocol instance pointer.
1024 @param[in] ControllerHandle Handle of device to test.
1026 @retval EFI_SUCCESS UDF file system found.
1027 @retval EFI_UNSUPPORTED UDF file system not found.
1031 SupportUdfFileSystem (
1032 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1033 IN EFI_HANDLE ControllerHandle
1037 Mangle a filename by cutting off trailing whitespaces, "\\", "." and "..".
1039 @param[in] FileName Filename.
1041 @retval The mangled Filename.
1050 Test to see if this driver supports ControllerHandle. Any ControllerHandle
1051 than contains a BlockIo and DiskIo protocol can be supported.
1053 @param This Protocol instance pointer.
1054 @param ControllerHandle Handle of device to test
1055 @param RemainingDevicePath Optional parameter use to pick a specific child
1058 @retval EFI_SUCCESS This driver supports this device
1059 @retval EFI_ALREADY_STARTED This driver is already running on this device
1060 @retval other This driver does not support this device
1065 UdfDriverBindingSupported (
1066 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1067 IN EFI_HANDLE ControllerHandle
,
1068 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1072 Start this driver on ControllerHandle by opening a Block IO and Disk IO
1073 protocol, reading Device Path, and creating a child handle with a
1074 Disk IO and device path protocol.
1076 @param This Protocol instance pointer.
1077 @param ControllerHandle Handle of device to bind driver to
1078 @param RemainingDevicePath Optional parameter use to pick a specific child
1081 @retval EFI_SUCCESS This driver is added to ControllerHandle
1082 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
1083 @retval other This driver does not support this device
1088 UdfDriverBindingStart (
1089 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1090 IN EFI_HANDLE ControllerHandle
,
1091 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1095 Stop this driver on ControllerHandle. Support stopping any child handles
1096 created by this driver.
1098 @param This Protocol instance pointer.
1099 @param ControllerHandle Handle of device to stop driver on
1100 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1101 children is zero stop the entire bus driver.
1102 @param ChildHandleBuffer List of Child Handles to Stop.
1104 @retval EFI_SUCCESS This driver is removed ControllerHandle
1105 @retval other This driver was not removed from this device
1110 UdfDriverBindingStop (
1111 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1112 IN EFI_HANDLE ControllerHandle
,
1113 IN UINTN NumberOfChildren
,
1114 IN EFI_HANDLE
*ChildHandleBuffer
1118 // EFI Component Name Functions
1121 Retrieves a Unicode string that is the user readable name of the driver.
1123 This function retrieves the user readable name of a driver in the form of a
1124 Unicode string. If the driver specified by This has a user readable name in
1125 the language specified by Language, then a pointer to the driver name is
1126 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
1127 by This does not support the language specified by Language,
1128 then EFI_UNSUPPORTED is returned.
1130 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1131 EFI_COMPONENT_NAME_PROTOCOL instance.
1133 @param Language[in] A pointer to a Null-terminated ASCII string
1134 array indicating the language. This is the
1135 language of the driver name that the caller is
1136 requesting, and it must match one of the
1137 languages specified in SupportedLanguages. The
1138 number of languages supported by a driver is up
1139 to the driver writer. Language is specified
1140 in RFC 4646 or ISO 639-2 language code format.
1142 @param DriverName[out] A pointer to the Unicode string to return.
1143 This Unicode string is the name of the
1144 driver specified by This in the language
1145 specified by Language.
1147 @retval EFI_SUCCESS The Unicode string for the Driver specified by
1148 This and the language specified by Language was
1149 returned in DriverName.
1151 @retval EFI_INVALID_PARAMETER Language is NULL.
1153 @retval EFI_INVALID_PARAMETER DriverName is NULL.
1155 @retval EFI_UNSUPPORTED The driver specified by This does not support
1156 the language specified by Language.
1161 UdfComponentNameGetDriverName (
1162 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1164 OUT CHAR16
**DriverName
1168 Retrieves a Unicode string that is the user readable name of the controller
1169 that is being managed by a driver.
1171 This function retrieves the user readable name of the controller specified by
1172 ControllerHandle and ChildHandle in the form of a Unicode string. If the
1173 driver specified by This has a user readable name in the language specified by
1174 Language, then a pointer to the controller name is returned in ControllerName,
1175 and EFI_SUCCESS is returned. If the driver specified by This is not currently
1176 managing the controller specified by ControllerHandle and ChildHandle,
1177 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
1178 support the language specified by Language, then EFI_UNSUPPORTED is returned.
1180 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1181 EFI_COMPONENT_NAME_PROTOCOL instance.
1183 @param ControllerHandle[in] The handle of a controller that the driver
1184 specified by This is managing. This handle
1185 specifies the controller whose name is to be
1188 @param ChildHandle[in] The handle of the child controller to retrieve
1189 the name of. This is an optional parameter that
1190 may be NULL. It will be NULL for device
1191 drivers. It will also be NULL for a bus drivers
1192 that wish to retrieve the name of the bus
1193 controller. It will not be NULL for a bus
1194 driver that wishes to retrieve the name of a
1197 @param Language[in] A pointer to a Null-terminated ASCII string
1198 array indicating the language. This is the
1199 language of the driver name that the caller is
1200 requesting, and it must match one of the
1201 languages specified in SupportedLanguages. The
1202 number of languages supported by a driver is up
1203 to the driver writer. Language is specified in
1204 RFC 4646 or ISO 639-2 language code format.
1206 @param ControllerName[out] A pointer to the Unicode string to return.
1207 This Unicode string is the name of the
1208 controller specified by ControllerHandle and
1209 ChildHandle in the language specified by
1210 Language from the point of view of the driver
1213 @retval EFI_SUCCESS The Unicode string for the user readable name in
1214 the language specified by Language for the
1215 driver specified by This was returned in
1218 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
1220 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
1223 @retval EFI_INVALID_PARAMETER Language is NULL.
1225 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
1227 @retval EFI_UNSUPPORTED The driver specified by This is not currently
1228 managing the controller specified by
1229 ControllerHandle and ChildHandle.
1231 @retval EFI_UNSUPPORTED The driver specified by This does not support
1232 the language specified by Language.
1237 UdfComponentNameGetControllerName (
1238 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1239 IN EFI_HANDLE ControllerHandle
,
1240 IN EFI_HANDLE ChildHandle OPTIONAL
,
1242 OUT CHAR16
**ControllerName