2 UDF/ECMA-167 file system driver.
4 Copyright (C) 2014-2017 Paulo Alcantara <pcacjr@zytor.com>
5 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
16 #include <Protocol/BlockIo.h>
17 #include <Protocol/ComponentName.h>
18 #include <Protocol/DevicePath.h>
19 #include <Protocol/DriverBinding.h>
20 #include <Protocol/DiskIo.h>
21 #include <Protocol/SimpleFileSystem.h>
23 #include <Guid/FileInfo.h>
24 #include <Guid/FileSystemInfo.h>
25 #include <Guid/FileSystemVolumeLabelInfo.h>
27 #include <Library/DebugLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/BaseLib.h>
30 #include <Library/UefiLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/MemoryAllocationLib.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/DevicePathLib.h>
36 #include <IndustryStandard/ElTorito.h>
37 #include <IndustryStandard/Udf.h>
40 // C5BD4D42-1A76-4996-8956-73CDA326CD0A
42 #define EFI_UDF_DEVICE_PATH_GUID \
43 { 0xC5BD4D42, 0x1A76, 0x4996, \
44 { 0x89, 0x56, 0x73, 0xCD, 0xA3, 0x26, 0xCD, 0x0A } \
47 #define FE_ICB_FILE_TYPE(_Ptr) \
48 (UDF_FILE_ENTRY_TYPE)( \
49 ((UDF_DESCRIPTOR_TAG *)(_Ptr))->TagIdentifier == UdfFileEntry ? \
50 ((UDF_FILE_ENTRY *)(_Ptr))->IcbTag.FileType : \
51 ((UDF_EXTENDED_FILE_ENTRY *)(_Ptr))->IcbTag.FileType)
54 UdfFileEntryDirectory
= 4,
55 UdfFileEntryStandardFile
= 5,
56 UdfFileEntrySymlink
= 12,
57 } UDF_FILE_ENTRY_TYPE
;
59 #define HIDDEN_FILE (1 << 0)
60 #define DIRECTORY_FILE (1 << 1)
61 #define DELETED_FILE (1 << 2)
62 #define PARENT_FILE (1 << 3)
64 #define IS_FID_HIDDEN_FILE(_Fid) \
65 (BOOLEAN)((_Fid)->FileCharacteristics & HIDDEN_FILE)
66 #define IS_FID_DIRECTORY_FILE(_Fid) \
67 (BOOLEAN)((_Fid)->FileCharacteristics & DIRECTORY_FILE)
68 #define IS_FID_DELETED_FILE(_Fid) \
69 (BOOLEAN)((_Fid)->FileCharacteristics & DELETED_FILE)
70 #define IS_FID_PARENT_FILE(_Fid) \
71 (BOOLEAN)((_Fid)->FileCharacteristics & PARENT_FILE)
72 #define IS_FID_NORMAL_FILE(_Fid) \
73 (BOOLEAN)(!IS_FID_DIRECTORY_FILE (_Fid) && \
74 !IS_FID_PARENT_FILE (_Fid))
81 } UDF_FE_RECORDING_FLAGS
;
83 #define GET_FE_RECORDING_FLAGS(_Fe) \
84 ((UDF_FE_RECORDING_FLAGS)((UDF_ICB_TAG *)( \
86 sizeof (UDF_DESCRIPTOR_TAG)))->Flags & 0x07)
89 ExtentRecordedAndAllocated
,
90 ExtentNotRecordedButAllocated
,
91 ExtentNotRecordedNotAllocated
,
95 #define AD_LENGTH(_RecFlags) \
96 ((_RecFlags) == ShortAdsSequence ? \
97 ((UINT64)(sizeof (UDF_SHORT_ALLOCATION_DESCRIPTOR))) : \
98 ((UINT64)(sizeof (UDF_LONG_ALLOCATION_DESCRIPTOR))))
100 #define GET_EXTENT_FLAGS(_RecFlags, _Ad) \
101 ((_RecFlags) == ShortAdsSequence ? \
102 ((UDF_EXTENT_FLAGS)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
104 ((UDF_EXTENT_FLAGS)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
107 #define GET_EXTENT_LENGTH(_RecFlags, _Ad) \
108 ((_RecFlags) == ShortAdsSequence ? \
109 ((UINT32)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
111 ((UINT32)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
114 #define UDF_FILENAME_LENGTH 128
115 #define UDF_PATH_LENGTH 512
117 #define GET_FID_FROM_ADS(_Data, _Offs) \
118 ((UDF_FILE_IDENTIFIER_DESCRIPTOR *)((UINT8 *)(_Data) + (_Offs)))
120 #define IS_VALID_COMPRESSION_ID(_CompId) \
121 ((BOOLEAN)((_CompId) == 8 || (_CompId) == 16))
123 #define UDF_STANDARD_IDENTIFIER_LENGTH 5
128 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
129 } UDF_STANDARD_IDENTIFIER
;
135 ReadFileAllocateAndRead
,
137 } UDF_READ_FILE_FLAGS
;
141 UDF_READ_FILE_FLAGS Flags
;
146 } UDF_READ_FILE_INFO
;
151 UINT16 TypeAndTimezone
;
159 UINT8 HundredsOfMicroseconds
;
164 UDF_DESCRIPTOR_TAG DescriptorTag
;
165 UINT32 PrevAllocationExtentDescriptor
;
166 UINT32 LengthOfAllocationDescriptors
;
167 } UDF_ALLOCATION_EXTENT_DESCRIPTOR
;
171 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
172 UINT8 StructureVersion
;
174 UINT8 StructureData
[2040];
175 } UDF_VOLUME_DESCRIPTOR
;
178 UDF_DESCRIPTOR_TAG DescriptorTag
;
179 UDF_TIMESTAMP RecordingDateTime
;
180 UINT32 IntegrityType
;
181 UDF_EXTENT_AD NextIntegrityExtent
;
182 UINT8 LogicalVolumeContentsUse
[32];
183 UINT32 NumberOfPartitions
;
184 UINT32 LengthOfImplementationUse
;
186 } UDF_LOGICAL_VOLUME_INTEGRITY
;
189 UDF_DESCRIPTOR_TAG DescriptorTag
;
190 UINT32 VolumeDescriptorSequenceNumber
;
191 UINT16 PartitionFlags
;
192 UINT16 PartitionNumber
;
193 UDF_ENTITY_ID PartitionContents
;
194 UINT8 PartitionContentsUse
[128];
196 UINT32 PartitionStartingLocation
;
197 UINT32 PartitionLength
;
198 UDF_ENTITY_ID ImplementationIdentifier
;
199 UINT8 ImplementationUse
[128];
201 } UDF_PARTITION_DESCRIPTOR
;
204 UDF_DESCRIPTOR_TAG DescriptorTag
;
205 UDF_TIMESTAMP RecordingDateAndTime
;
206 UINT16 InterchangeLevel
;
207 UINT16 MaximumInterchangeLevel
;
208 UINT32 CharacterSetList
;
209 UINT32 MaximumCharacterSetList
;
210 UINT32 FileSetNumber
;
211 UINT32 FileSetDescriptorNumber
;
212 UDF_CHAR_SPEC LogicalVolumeIdentifierCharacterSet
;
213 UINT8 LogicalVolumeIdentifier
[128];
214 UDF_CHAR_SPEC FileSetCharacterSet
;
215 UINT8 FileSetIdentifier
[32];
216 UINT8 CopyrightFileIdentifier
[32];
217 UINT8 AbstractFileIdentifier
[32];
218 UDF_LONG_ALLOCATION_DESCRIPTOR RootDirectoryIcb
;
219 UDF_ENTITY_ID DomainIdentifier
;
220 UDF_LONG_ALLOCATION_DESCRIPTOR NextExtent
;
221 UDF_LONG_ALLOCATION_DESCRIPTOR SystemStreamDirectoryIcb
;
223 } UDF_FILE_SET_DESCRIPTOR
;
227 UINT32 ExtentPosition
;
228 } UDF_SHORT_ALLOCATION_DESCRIPTOR
;
231 UDF_DESCRIPTOR_TAG DescriptorTag
;
232 UINT16 FileVersionNumber
;
233 UINT8 FileCharacteristics
;
234 UINT8 LengthOfFileIdentifier
;
235 UDF_LONG_ALLOCATION_DESCRIPTOR Icb
;
236 UINT16 LengthOfImplementationUse
;
238 } UDF_FILE_IDENTIFIER_DESCRIPTOR
;
241 UINT32 PriorRecordNumberOfDirectEntries
;
243 UINT16 StrategyParameter
;
244 UINT16 MaximumNumberOfEntries
;
247 UDF_LB_ADDR ParentIcbLocation
;
252 UDF_DESCRIPTOR_TAG DescriptorTag
;
257 UINT16 FileLinkCount
;
259 UINT8 RecordDisplayAttributes
;
261 UINT64 InformationLength
;
262 UINT64 LogicalBlocksRecorded
;
263 UDF_TIMESTAMP AccessTime
;
264 UDF_TIMESTAMP ModificationTime
;
265 UDF_TIMESTAMP AttributeTime
;
267 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
268 UDF_ENTITY_ID ImplementationIdentifier
;
270 UINT32 LengthOfExtendedAttributes
;
271 UINT32 LengthOfAllocationDescriptors
;
272 UINT8 Data
[0]; // L_EA + L_AD
276 UDF_DESCRIPTOR_TAG DescriptorTag
;
281 UINT16 FileLinkCount
;
283 UINT8 RecordDisplayAttributes
;
285 UINT64 InformationLength
;
287 UINT64 LogicalBlocksRecorded
;
288 UDF_TIMESTAMP AccessTime
;
289 UDF_TIMESTAMP ModificationTime
;
290 UDF_TIMESTAMP CreationTime
;
291 UDF_TIMESTAMP AttributeTime
;
294 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
295 UDF_LONG_ALLOCATION_DESCRIPTOR StreamDirectoryIcb
;
296 UDF_ENTITY_ID ImplementationIdentifier
;
298 UINT32 LengthOfExtendedAttributes
;
299 UINT32 LengthOfAllocationDescriptors
;
300 UINT8 Data
[0]; // L_EA + L_AD
301 } UDF_EXTENDED_FILE_ENTRY
;
305 UINT8 LengthOfComponentIdentifier
;
306 UINT16 ComponentFileVersionNumber
;
307 UINT8 ComponentIdentifier
[0];
308 } UDF_PATH_COMPONENT
;
313 // UDF filesystem driver's private data
316 UINT64 MainVdsStartLocation
;
317 UDF_LOGICAL_VOLUME_DESCRIPTOR LogicalVolDesc
;
318 UDF_PARTITION_DESCRIPTOR PartitionDesc
;
319 UDF_FILE_SET_DESCRIPTOR FileSetDesc
;
325 UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
;
330 UINT64 DirectoryLength
;
332 } UDF_READ_DIRECTORY_INFO
;
334 #define PRIVATE_UDF_FILE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 'f')
336 #define PRIVATE_UDF_FILE_DATA_FROM_THIS(a) \
339 PRIVATE_UDF_FILE_DATA, \
341 PRIVATE_UDF_FILE_DATA_SIGNATURE \
346 BOOLEAN IsRootDirectory
;
349 UDF_READ_DIRECTORY_INFO ReadDirInfo
;
350 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFs
;
351 EFI_FILE_PROTOCOL FileIo
;
352 CHAR16 AbsoluteFileName
[UDF_PATH_LENGTH
];
353 CHAR16 FileName
[UDF_FILENAME_LENGTH
];
356 } PRIVATE_UDF_FILE_DATA
;
358 #define PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 's')
360 #define PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS(a) \
363 PRIVATE_UDF_SIMPLE_FS_DATA, \
365 PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE \
370 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
371 EFI_DISK_IO_PROTOCOL
*DiskIo
;
372 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs
;
373 UDF_VOLUME_INFO Volume
;
377 } PRIVATE_UDF_SIMPLE_FS_DATA
;
382 extern EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding
;
383 extern EFI_COMPONENT_NAME_PROTOCOL gUdfComponentName
;
384 extern EFI_COMPONENT_NAME2_PROTOCOL gUdfComponentName2
;
387 // Function Prototypes
391 Open the root directory on a volume.
393 @param This Protocol instance pointer.
394 @param Root Returns an Open file handle for the root directory
396 @retval EFI_SUCCESS The device was opened.
397 @retval EFI_UNSUPPORTED This volume does not support the file system.
398 @retval EFI_NO_MEDIA The device has no media.
399 @retval EFI_DEVICE_ERROR The device reported an error.
400 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
401 @retval EFI_ACCESS_DENIED The service denied access to the file.
402 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
408 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
409 OUT EFI_FILE_PROTOCOL
**Root
413 Opens a new file relative to the source file's location.
415 @param This The protocol instance pointer.
416 @param NewHandle Returns File Handle for FileName.
417 @param FileName Null terminated string. "\", ".", and ".." are supported.
418 @param OpenMode Open mode for file.
419 @param Attributes Only used for EFI_FILE_MODE_CREATE.
421 @retval EFI_SUCCESS The device was opened.
422 @retval EFI_NOT_FOUND The specified file could not be found on the device.
423 @retval EFI_NO_MEDIA The device has no media.
424 @retval EFI_MEDIA_CHANGED The media has changed.
425 @retval EFI_DEVICE_ERROR The device reported an error.
426 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
427 @retval EFI_ACCESS_DENIED The service denied access to the file.
428 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
429 @retval EFI_VOLUME_FULL The volume is full.
435 IN EFI_FILE_PROTOCOL
*This
,
436 OUT EFI_FILE_PROTOCOL
**NewHandle
,
443 Read data from the file.
445 @param This Protocol instance pointer.
446 @param BufferSize On input size of buffer, on output amount of data in buffer.
447 @param Buffer The buffer in which data is read.
449 @retval EFI_SUCCESS Data was read.
450 @retval EFI_NO_MEDIA The device has no media.
451 @retval EFI_DEVICE_ERROR The device reported an error.
452 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
453 @retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size.
459 IN EFI_FILE_PROTOCOL
*This
,
460 IN OUT UINTN
*BufferSize
,
465 Close the file handle.
467 @param This Protocol instance pointer.
469 @retval EFI_SUCCESS The file was closed.
475 IN EFI_FILE_PROTOCOL
*This
479 Close and delete the file handle.
481 @param This Protocol instance pointer.
483 @retval EFI_SUCCESS The file was closed and deleted.
484 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not
491 IN EFI_FILE_PROTOCOL
*This
495 Write data to a file.
497 @param This Protocol instance pointer.
498 @param BufferSize On input size of buffer, on output amount of data in buffer.
499 @param Buffer The buffer in which data to write.
501 @retval EFI_SUCCESS Data was written.
502 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
503 @retval EFI_NO_MEDIA The device has no media.
504 @retval EFI_DEVICE_ERROR The device reported an error.
505 @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
506 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
507 @retval EFI_WRITE_PROTECTED The device is write protected.
508 @retval EFI_ACCESS_DENIED The file was open for read only.
509 @retval EFI_VOLUME_FULL The volume is full.
515 IN EFI_FILE_PROTOCOL
*This
,
516 IN OUT UINTN
*BufferSize
,
521 Get file's current position.
523 @param This Protocol instance pointer.
524 @param Position Byte position from the start of the file.
526 @retval EFI_SUCCESS Position was updated.
527 @retval EFI_UNSUPPORTED Seek request for directories is not valid.
533 IN EFI_FILE_PROTOCOL
*This
,
538 Set file's current position.
540 @param This Protocol instance pointer.
541 @param Position Byte position from the start of the file.
543 @retval EFI_SUCCESS Position was updated.
544 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
550 IN EFI_FILE_PROTOCOL
*This
,
555 Get information about a file.
557 @attention This is boundary function that may receive untrusted input.
558 @attention The input is from FileSystem.
560 The File Set Descriptor is external input, so this routine will do basic
561 validation for File Set Descriptor and report status.
563 @param This Protocol instance pointer.
564 @param InformationType Type of information to return in Buffer.
565 @param BufferSize On input size of buffer, on output amount of data in
567 @param Buffer The buffer to return data.
569 @retval EFI_SUCCESS Data was returned.
570 @retval EFI_UNSUPPORTED InformationType is not supported.
571 @retval EFI_NO_MEDIA The device has no media.
572 @retval EFI_DEVICE_ERROR The device reported an error.
573 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
574 @retval EFI_WRITE_PROTECTED The device is write protected.
575 @retval EFI_ACCESS_DENIED The file was open for read only.
576 @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in
583 IN EFI_FILE_PROTOCOL
*This
,
584 IN EFI_GUID
*InformationType
,
585 IN OUT UINTN
*BufferSize
,
590 Set information about a file.
592 @param This Protocol instance pointer.
593 @param InformationType Type of information in Buffer.
594 @param BufferSize Size of buffer.
595 @param Buffer The data to write.
597 @retval EFI_SUCCESS Data was set.
598 @retval EFI_UNSUPPORTED InformationType is not supported.
599 @retval EFI_NO_MEDIA The device has no media.
600 @retval EFI_DEVICE_ERROR The device reported an error.
601 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
602 @retval EFI_WRITE_PROTECTED The device is write protected.
603 @retval EFI_ACCESS_DENIED The file was open for read only.
609 IN EFI_FILE_PROTOCOL
*This
,
610 IN EFI_GUID
*InformationType
,
616 Flush data back for the file handle.
618 @param This Protocol instance pointer.
620 @retval EFI_SUCCESS Data was flushed.
621 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
622 @retval EFI_NO_MEDIA The device has no media.
623 @retval EFI_DEVICE_ERROR The device reported an error.
624 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
625 @retval EFI_WRITE_PROTECTED The device is write protected.
626 @retval EFI_ACCESS_DENIED The file was open for read only.
627 @retval EFI_VOLUME_FULL The volume is full.
633 IN EFI_FILE_PROTOCOL
*This
637 Read volume information on a medium which contains a valid UDF file system.
639 @param[in] BlockIo BlockIo interface.
640 @param[in] DiskIo DiskIo interface.
641 @param[out] Volume UDF volume information structure.
643 @retval EFI_SUCCESS Volume information read.
644 @retval EFI_NO_MEDIA The device has no media.
645 @retval EFI_DEVICE_ERROR The device reported an error.
646 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
647 @retval EFI_OUT_OF_RESOURCES The volume was not read due to lack of resources.
651 ReadUdfVolumeInformation (
652 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
653 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
654 OUT UDF_VOLUME_INFO
*Volume
658 Find the root directory on an UDF volume.
660 @param[in] BlockIo BlockIo interface.
661 @param[in] DiskIo DiskIo interface.
662 @param[in] Volume UDF volume information structure.
663 @param[out] File Root directory file.
665 @retval EFI_SUCCESS Root directory found.
666 @retval EFI_NO_MEDIA The device has no media.
667 @retval EFI_DEVICE_ERROR The device reported an error.
668 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
669 @retval EFI_OUT_OF_RESOURCES The root directory was not found due to lack of
675 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
676 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
677 IN UDF_VOLUME_INFO
*Volume
,
678 OUT UDF_FILE_INFO
*File
682 Find either a File Entry or a Extended File Entry from a given ICB.
684 @param[in] BlockIo BlockIo interface.
685 @param[in] DiskIo DiskIo interface.
686 @param[in] Volume UDF volume information structure.
687 @param[in] Icb ICB of the FID.
688 @param[out] FileEntry File Entry or Extended File Entry.
690 @retval EFI_SUCCESS File Entry or Extended File Entry found.
691 @retval EFI_NO_MEDIA The device has no media.
692 @retval EFI_DEVICE_ERROR The device reported an error.
693 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
694 @retval EFI_OUT_OF_RESOURCES The FE/EFE entry was not found due to lack of
700 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
701 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
702 IN UDF_VOLUME_INFO
*Volume
,
703 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
708 Find a file given its absolute path on an UDF volume.
710 @param[in] BlockIo BlockIo interface.
711 @param[in] DiskIo DiskIo interface.
712 @param[in] Volume UDF volume information structure.
713 @param[in] FilePath File's absolute path.
714 @param[in] Root Root directory file.
715 @param[in] Parent Parent directory file.
716 @param[in] Icb ICB of Parent.
717 @param[out] File Found file.
719 @retval EFI_SUCCESS FilePath was found.
720 @retval EFI_NO_MEDIA The device has no media.
721 @retval EFI_DEVICE_ERROR The device reported an error.
722 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
723 @retval EFI_OUT_OF_RESOURCES The FilePath file was not found due to lack of
729 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
730 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
731 IN UDF_VOLUME_INFO
*Volume
,
733 IN UDF_FILE_INFO
*Root
,
734 IN UDF_FILE_INFO
*Parent
,
735 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
736 OUT UDF_FILE_INFO
*File
740 Read a directory entry at a time on an UDF volume.
742 @param[in] BlockIo BlockIo interface.
743 @param[in] DiskIo DiskIo interface.
744 @param[in] Volume UDF volume information structure.
745 @param[in] ParentIcb ICB of the parent file.
746 @param[in] FileEntryData FE/EFE of the parent file.
747 @param[in, out] ReadDirInfo Next read directory listing structure
749 @param[out] FoundFid File Identifier Descriptor pointer.
751 @retval EFI_SUCCESS Directory entry read.
752 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
753 @retval EFI_NO_MEDIA The device has no media.
754 @retval EFI_DEVICE_ERROR The device reported an error.
755 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
756 @retval EFI_OUT_OF_RESOURCES The directory entry was not read due to lack of
762 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
763 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
764 IN UDF_VOLUME_INFO
*Volume
,
765 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*ParentIcb
,
766 IN VOID
*FileEntryData
,
767 IN OUT UDF_READ_DIRECTORY_INFO
*ReadDirInfo
,
768 OUT UDF_FILE_IDENTIFIER_DESCRIPTOR
**FoundFid
772 Get a filename (encoded in OSTA-compressed format) from a File Identifier
773 Descriptor on an UDF volume.
775 @attention This is boundary function that may receive untrusted input.
776 @attention The input is from FileSystem.
778 The File Identifier Descriptor is external input, so this routine will do
779 basic validation for File Identifier Descriptor and report status.
781 @param[in] FileIdentifierDesc File Identifier Descriptor pointer.
782 @param[in] CharMax The maximum number of FileName Unicode char,
783 including terminating null char.
784 @param[out] FileName Decoded filename.
786 @retval EFI_SUCCESS Filename decoded and read.
787 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
788 @retval EFI_BUFFER_TOO_SMALL The string buffer FileName cannot hold the
793 IN UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
,
799 Resolve a symlink file on an UDF volume.
801 @attention This is boundary function that may receive untrusted input.
802 @attention The input is from FileSystem.
804 The Path Component is external input, so this routine will do basic
805 validation for Path Component and report status.
807 @param[in] BlockIo BlockIo interface.
808 @param[in] DiskIo DiskIo interface.
809 @param[in] Volume UDF volume information structure.
810 @param[in] Parent Parent file.
811 @param[in] FileEntryData FE/EFE structure pointer.
812 @param[out] File Resolved file.
814 @retval EFI_SUCCESS Symlink file resolved.
815 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
816 @retval EFI_NO_MEDIA The device has no media.
817 @retval EFI_DEVICE_ERROR The device reported an error.
818 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
819 @retval EFI_OUT_OF_RESOURCES The symlink file was not resolved due to lack of
825 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
826 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
827 IN UDF_VOLUME_INFO
*Volume
,
828 IN UDF_FILE_INFO
*Parent
,
829 IN VOID
*FileEntryData
,
830 OUT UDF_FILE_INFO
*File
834 Clean up in-memory UDF file information.
836 @param[in] File File information pointer.
840 CleanupFileInformation (
841 IN UDF_FILE_INFO
*File
845 Find a file from its absolute path on an UDF volume.
847 @param[in] BlockIo BlockIo interface.
848 @param[in] DiskIo DiskIo interface.
849 @param[in] Volume UDF volume information structure.
850 @param[in] File File information structure.
851 @param[out] Size Size of the file.
853 @retval EFI_SUCCESS File size calculated and set in Size.
854 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
855 @retval EFI_NO_MEDIA The device has no media.
856 @retval EFI_DEVICE_ERROR The device reported an error.
857 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
858 @retval EFI_OUT_OF_RESOURCES The file size was not calculated due to lack of
864 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
865 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
866 IN UDF_VOLUME_INFO
*Volume
,
867 IN UDF_FILE_INFO
*File
,
872 Set information about a file on an UDF volume.
874 @param[in] File File pointer.
875 @param[in] FileSize Size of the file.
876 @param[in] FileName Filename of the file.
877 @param[in, out] BufferSize Size of the returned file infomation.
878 @param[out] Buffer Data of the returned file information.
880 @retval EFI_SUCCESS File information set.
881 @retval EFI_NO_MEDIA The device has no media.
882 @retval EFI_DEVICE_ERROR The device reported an error.
883 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
884 @retval EFI_OUT_OF_RESOURCES The file information was not set due to lack of
890 IN UDF_FILE_INFO
*File
,
893 IN OUT UINTN
*BufferSize
,
898 Get volume label of an UDF volume.
900 @attention This is boundary function that may receive untrusted input.
901 @attention The input is from FileSystem.
903 The File Set Descriptor is external input, so this routine will do basic
904 validation for File Set Descriptor and report status.
906 @param[in] Volume Volume information pointer.
907 @param[in] CharMax The maximum number of Unicode char in String,
908 including terminating null char.
909 @param[out] String String buffer pointer to store the volume label.
911 @retval EFI_SUCCESS Volume label is returned.
912 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
913 @retval EFI_BUFFER_TOO_SMALL The string buffer String cannot hold the
919 IN UDF_VOLUME_INFO
*Volume
,
925 Get volume and free space size information of an UDF volume.
927 @attention This is boundary function that may receive untrusted input.
928 @attention The input is from FileSystem.
930 The Logical Volume Descriptor and the Logical Volume Integrity Descriptor are
931 external inputs, so this routine will do basic validation for both descriptors
934 @param[in] BlockIo BlockIo interface.
935 @param[in] DiskIo DiskIo interface.
936 @param[in] Volume UDF volume information structure.
937 @param[out] VolumeSize Volume size.
938 @param[out] FreeSpaceSize Free space size.
940 @retval EFI_SUCCESS Volume and free space size calculated.
941 @retval EFI_NO_MEDIA The device has no media.
942 @retval EFI_DEVICE_ERROR The device reported an error.
943 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
944 @retval EFI_OUT_OF_RESOURCES The volume and free space size were not
945 calculated due to lack of resources.
950 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
951 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
952 IN UDF_VOLUME_INFO
*Volume
,
953 OUT UINT64
*VolumeSize
,
954 OUT UINT64
*FreeSpaceSize
958 Seek a file and read its data into memory on an UDF volume.
960 @param[in] BlockIo BlockIo interface.
961 @param[in] DiskIo DiskIo interface.
962 @param[in] Volume UDF volume information structure.
963 @param[in] File File information structure.
964 @param[in] FileSize Size of the file.
965 @param[in, out] FilePosition File position.
966 @param[in, out] Buffer File data.
967 @param[in, out] BufferSize Read size.
969 @retval EFI_SUCCESS File seeked and read.
970 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
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 file's recorded data was not read due to lack
980 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
981 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
982 IN UDF_VOLUME_INFO
*Volume
,
983 IN UDF_FILE_INFO
*File
,
985 IN OUT UINT64
*FilePosition
,
987 IN OUT UINT64
*BufferSize
991 Check if ControllerHandle supports an UDF file system.
993 @param[in] This Protocol instance pointer.
994 @param[in] ControllerHandle Handle of device to test.
996 @retval EFI_SUCCESS UDF file system found.
997 @retval EFI_UNSUPPORTED UDF file system not found.
1001 SupportUdfFileSystem (
1002 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1003 IN EFI_HANDLE ControllerHandle
1007 Mangle a filename by cutting off trailing whitespaces, "\\", "." and "..".
1009 @param[in] FileName Filename.
1011 @retval The mangled Filename.
1020 Test to see if this driver supports ControllerHandle. Any ControllerHandle
1021 than contains a BlockIo and DiskIo protocol can be supported.
1023 @param This Protocol instance pointer.
1024 @param ControllerHandle Handle of device to test
1025 @param RemainingDevicePath Optional parameter use to pick a specific child
1028 @retval EFI_SUCCESS This driver supports this device
1029 @retval EFI_ALREADY_STARTED This driver is already running on this device
1030 @retval other This driver does not support this device
1035 UdfDriverBindingSupported (
1036 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1037 IN EFI_HANDLE ControllerHandle
,
1038 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1042 Start this driver on ControllerHandle by opening a Block IO and Disk IO
1043 protocol, reading Device Path, and creating a child handle with a
1044 Disk IO and device path protocol.
1046 @param This Protocol instance pointer.
1047 @param ControllerHandle Handle of device to bind driver to
1048 @param RemainingDevicePath Optional parameter use to pick a specific child
1051 @retval EFI_SUCCESS This driver is added to ControllerHandle
1052 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
1053 @retval other This driver does not support this device
1058 UdfDriverBindingStart (
1059 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1060 IN EFI_HANDLE ControllerHandle
,
1061 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1065 Stop this driver on ControllerHandle. Support stopping any child handles
1066 created by this driver.
1068 @param This Protocol instance pointer.
1069 @param ControllerHandle Handle of device to stop driver on
1070 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1071 children is zero stop the entire bus driver.
1072 @param ChildHandleBuffer List of Child Handles to Stop.
1074 @retval EFI_SUCCESS This driver is removed ControllerHandle
1075 @retval other This driver was not removed from this device
1080 UdfDriverBindingStop (
1081 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1082 IN EFI_HANDLE ControllerHandle
,
1083 IN UINTN NumberOfChildren
,
1084 IN EFI_HANDLE
*ChildHandleBuffer
1088 // EFI Component Name Functions
1092 Retrieves a Unicode string that is the user readable name of the driver.
1094 This function retrieves the user readable name of a driver in the form of a
1095 Unicode string. If the driver specified by This has a user readable name in
1096 the language specified by Language, then a pointer to the driver name is
1097 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
1098 by This does not support the language specified by Language,
1099 then EFI_UNSUPPORTED is returned.
1101 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1102 EFI_COMPONENT_NAME_PROTOCOL instance.
1104 @param Language[in] A pointer to a Null-terminated ASCII string
1105 array indicating the language. This is the
1106 language of the driver name that the caller is
1107 requesting, and it must match one of the
1108 languages specified in SupportedLanguages. The
1109 number of languages supported by a driver is up
1110 to the driver writer. Language is specified
1111 in RFC 4646 or ISO 639-2 language code format.
1113 @param DriverName[out] A pointer to the Unicode string to return.
1114 This Unicode string is the name of the
1115 driver specified by This in the language
1116 specified by Language.
1118 @retval EFI_SUCCESS The Unicode string for the Driver specified by
1119 This and the language specified by Language was
1120 returned in DriverName.
1122 @retval EFI_INVALID_PARAMETER Language is NULL.
1124 @retval EFI_INVALID_PARAMETER DriverName is NULL.
1126 @retval EFI_UNSUPPORTED The driver specified by This does not support
1127 the language specified by Language.
1132 UdfComponentNameGetDriverName (
1133 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1135 OUT CHAR16
**DriverName
1139 Retrieves a Unicode string that is the user readable name of the controller
1140 that is being managed by a driver.
1142 This function retrieves the user readable name of the controller specified by
1143 ControllerHandle and ChildHandle in the form of a Unicode string. If the
1144 driver specified by This has a user readable name in the language specified by
1145 Language, then a pointer to the controller name is returned in ControllerName,
1146 and EFI_SUCCESS is returned. If the driver specified by This is not currently
1147 managing the controller specified by ControllerHandle and ChildHandle,
1148 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
1149 support the language specified by Language, then EFI_UNSUPPORTED is returned.
1151 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1152 EFI_COMPONENT_NAME_PROTOCOL instance.
1154 @param ControllerHandle[in] The handle of a controller that the driver
1155 specified by This is managing. This handle
1156 specifies the controller whose name is to be
1159 @param ChildHandle[in] The handle of the child controller to retrieve
1160 the name of. This is an optional parameter that
1161 may be NULL. It will be NULL for device
1162 drivers. It will also be NULL for a bus drivers
1163 that wish to retrieve the name of the bus
1164 controller. It will not be NULL for a bus
1165 driver that wishes to retrieve the name of a
1168 @param Language[in] A pointer to a Null-terminated ASCII string
1169 array indicating the language. This is the
1170 language of the driver name that the caller is
1171 requesting, and it must match one of the
1172 languages specified in SupportedLanguages. The
1173 number of languages supported by a driver is up
1174 to the driver writer. Language is specified in
1175 RFC 4646 or ISO 639-2 language code format.
1177 @param ControllerName[out] A pointer to the Unicode string to return.
1178 This Unicode string is the name of the
1179 controller specified by ControllerHandle and
1180 ChildHandle in the language specified by
1181 Language from the point of view of the driver
1184 @retval EFI_SUCCESS The Unicode string for the user readable name in
1185 the language specified by Language for the
1186 driver specified by This was returned in
1189 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
1191 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
1194 @retval EFI_INVALID_PARAMETER Language is NULL.
1196 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
1198 @retval EFI_UNSUPPORTED The driver specified by This is not currently
1199 managing the controller specified by
1200 ControllerHandle and ChildHandle.
1202 @retval EFI_UNSUPPORTED The driver specified by This does not support
1203 the language specified by Language.
1208 UdfComponentNameGetControllerName (
1209 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1210 IN EFI_HANDLE ControllerHandle
,
1211 IN EFI_HANDLE ChildHandle OPTIONAL
,
1213 OUT CHAR16
**ControllerName