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 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include <Protocol/BlockIo.h>
23 #include <Protocol/ComponentName.h>
24 #include <Protocol/DevicePath.h>
25 #include <Protocol/DriverBinding.h>
26 #include <Protocol/DiskIo.h>
27 #include <Protocol/SimpleFileSystem.h>
29 #include <Guid/FileInfo.h>
30 #include <Guid/FileSystemInfo.h>
31 #include <Guid/FileSystemVolumeLabelInfo.h>
33 #include <Library/DebugLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/BaseLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseMemoryLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/UefiBootServicesTableLib.h>
40 #include <Library/DevicePathLib.h>
42 #include <IndustryStandard/ElTorito.h>
43 #include <IndustryStandard/Udf.h>
46 // C5BD4D42-1A76-4996-8956-73CDA326CD0A
48 #define EFI_UDF_DEVICE_PATH_GUID \
49 { 0xC5BD4D42, 0x1A76, 0x4996, \
50 { 0x89, 0x56, 0x73, 0xCD, 0xA3, 0x26, 0xCD, 0x0A } \
53 #define FE_ICB_FILE_TYPE(_Ptr) \
54 (UDF_FILE_ENTRY_TYPE)( \
55 ((UDF_DESCRIPTOR_TAG *)(_Ptr))->TagIdentifier == UdfFileEntry ? \
56 ((UDF_FILE_ENTRY *)(_Ptr))->IcbTag.FileType : \
57 ((UDF_EXTENDED_FILE_ENTRY *)(_Ptr))->IcbTag.FileType)
60 UdfFileEntryDirectory
= 4,
61 UdfFileEntryStandardFile
= 5,
62 UdfFileEntrySymlink
= 12,
63 } UDF_FILE_ENTRY_TYPE
;
65 #define HIDDEN_FILE (1 << 0)
66 #define DIRECTORY_FILE (1 << 1)
67 #define DELETED_FILE (1 << 2)
68 #define PARENT_FILE (1 << 3)
70 #define IS_FID_HIDDEN_FILE(_Fid) \
71 (BOOLEAN)((_Fid)->FileCharacteristics & HIDDEN_FILE)
72 #define IS_FID_DIRECTORY_FILE(_Fid) \
73 (BOOLEAN)((_Fid)->FileCharacteristics & DIRECTORY_FILE)
74 #define IS_FID_DELETED_FILE(_Fid) \
75 (BOOLEAN)((_Fid)->FileCharacteristics & DELETED_FILE)
76 #define IS_FID_PARENT_FILE(_Fid) \
77 (BOOLEAN)((_Fid)->FileCharacteristics & PARENT_FILE)
78 #define IS_FID_NORMAL_FILE(_Fid) \
79 (BOOLEAN)(!IS_FID_DIRECTORY_FILE (_Fid) && \
80 !IS_FID_PARENT_FILE (_Fid))
87 } UDF_FE_RECORDING_FLAGS
;
89 #define GET_FE_RECORDING_FLAGS(_Fe) \
90 ((UDF_FE_RECORDING_FLAGS)((UDF_ICB_TAG *)( \
92 sizeof (UDF_DESCRIPTOR_TAG)))->Flags & 0x07)
95 ExtentRecordedAndAllocated
,
96 ExtentNotRecordedButAllocated
,
97 ExtentNotRecordedNotAllocated
,
101 #define AD_LENGTH(_RecFlags) \
102 ((_RecFlags) == ShortAdsSequence ? \
103 ((UINT64)(sizeof (UDF_SHORT_ALLOCATION_DESCRIPTOR))) : \
104 ((UINT64)(sizeof (UDF_LONG_ALLOCATION_DESCRIPTOR))))
106 #define GET_EXTENT_FLAGS(_RecFlags, _Ad) \
107 ((_RecFlags) == ShortAdsSequence ? \
108 ((UDF_EXTENT_FLAGS)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
110 ((UDF_EXTENT_FLAGS)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
113 #define GET_EXTENT_LENGTH(_RecFlags, _Ad) \
114 ((_RecFlags) == ShortAdsSequence ? \
115 ((UINT32)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
117 ((UINT32)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
120 #define UDF_FILENAME_LENGTH 128
121 #define UDF_PATH_LENGTH 512
123 #define GET_FID_FROM_ADS(_Data, _Offs) \
124 ((UDF_FILE_IDENTIFIER_DESCRIPTOR *)((UINT8 *)(_Data) + (_Offs)))
126 #define IS_VALID_COMPRESSION_ID(_CompId) \
127 ((BOOLEAN)((_CompId) == 8 || (_CompId) == 16))
129 #define UDF_STANDARD_IDENTIFIER_LENGTH 5
134 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
135 } UDF_STANDARD_IDENTIFIER
;
141 ReadFileAllocateAndRead
,
143 } UDF_READ_FILE_FLAGS
;
147 UDF_READ_FILE_FLAGS Flags
;
152 } UDF_READ_FILE_INFO
;
157 UINT16 TypeAndTimezone
;
165 UINT8 HundredsOfMicroseconds
;
170 UDF_DESCRIPTOR_TAG DescriptorTag
;
171 UINT32 PrevAllocationExtentDescriptor
;
172 UINT32 LengthOfAllocationDescriptors
;
173 } UDF_ALLOCATION_EXTENT_DESCRIPTOR
;
177 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
178 UINT8 StructureVersion
;
180 UINT8 StructureData
[2040];
181 } UDF_VOLUME_DESCRIPTOR
;
184 UDF_DESCRIPTOR_TAG DescriptorTag
;
185 UDF_TIMESTAMP RecordingDateTime
;
186 UINT32 IntegrityType
;
187 UDF_EXTENT_AD NextIntegrityExtent
;
188 UINT8 LogicalVolumeContentsUse
[32];
189 UINT32 NumberOfPartitions
;
190 UINT32 LengthOfImplementationUse
;
192 } UDF_LOGICAL_VOLUME_INTEGRITY
;
195 UDF_DESCRIPTOR_TAG DescriptorTag
;
196 UINT32 VolumeDescriptorSequenceNumber
;
197 UINT16 PartitionFlags
;
198 UINT16 PartitionNumber
;
199 UDF_ENTITY_ID PartitionContents
;
200 UINT8 PartitionContentsUse
[128];
202 UINT32 PartitionStartingLocation
;
203 UINT32 PartitionLength
;
204 UDF_ENTITY_ID ImplementationIdentifier
;
205 UINT8 ImplementationUse
[128];
207 } UDF_PARTITION_DESCRIPTOR
;
210 UDF_DESCRIPTOR_TAG DescriptorTag
;
211 UDF_TIMESTAMP RecordingDateAndTime
;
212 UINT16 InterchangeLevel
;
213 UINT16 MaximumInterchangeLevel
;
214 UINT32 CharacterSetList
;
215 UINT32 MaximumCharacterSetList
;
216 UINT32 FileSetNumber
;
217 UINT32 FileSetDescriptorNumber
;
218 UDF_CHAR_SPEC LogicalVolumeIdentifierCharacterSet
;
219 UINT8 LogicalVolumeIdentifier
[128];
220 UDF_CHAR_SPEC FileSetCharacterSet
;
221 UINT8 FileSetIdentifier
[32];
222 UINT8 CopyrightFileIdentifier
[32];
223 UINT8 AbstractFileIdentifier
[32];
224 UDF_LONG_ALLOCATION_DESCRIPTOR RootDirectoryIcb
;
225 UDF_ENTITY_ID DomainIdentifier
;
226 UDF_LONG_ALLOCATION_DESCRIPTOR NextExtent
;
227 UDF_LONG_ALLOCATION_DESCRIPTOR SystemStreamDirectoryIcb
;
229 } UDF_FILE_SET_DESCRIPTOR
;
233 UINT32 ExtentPosition
;
234 } UDF_SHORT_ALLOCATION_DESCRIPTOR
;
237 UDF_DESCRIPTOR_TAG DescriptorTag
;
238 UINT16 FileVersionNumber
;
239 UINT8 FileCharacteristics
;
240 UINT8 LengthOfFileIdentifier
;
241 UDF_LONG_ALLOCATION_DESCRIPTOR Icb
;
242 UINT16 LengthOfImplementationUse
;
244 } UDF_FILE_IDENTIFIER_DESCRIPTOR
;
247 UINT32 PriorRecordNumberOfDirectEntries
;
249 UINT16 StrategyParameter
;
250 UINT16 MaximumNumberOfEntries
;
253 UDF_LB_ADDR ParentIcbLocation
;
258 UDF_DESCRIPTOR_TAG DescriptorTag
;
263 UINT16 FileLinkCount
;
265 UINT8 RecordDisplayAttributes
;
267 UINT64 InformationLength
;
268 UINT64 LogicalBlocksRecorded
;
269 UDF_TIMESTAMP AccessTime
;
270 UDF_TIMESTAMP ModificationTime
;
271 UDF_TIMESTAMP AttributeTime
;
273 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
274 UDF_ENTITY_ID ImplementationIdentifier
;
276 UINT32 LengthOfExtendedAttributes
;
277 UINT32 LengthOfAllocationDescriptors
;
278 UINT8 Data
[0]; // L_EA + L_AD
282 UDF_DESCRIPTOR_TAG DescriptorTag
;
287 UINT16 FileLinkCount
;
289 UINT8 RecordDisplayAttributes
;
291 UINT64 InformationLength
;
293 UINT64 LogicalBlocksRecorded
;
294 UDF_TIMESTAMP AccessTime
;
295 UDF_TIMESTAMP ModificationTime
;
296 UDF_TIMESTAMP CreationTime
;
297 UDF_TIMESTAMP AttributeTime
;
300 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
301 UDF_LONG_ALLOCATION_DESCRIPTOR StreamDirectoryIcb
;
302 UDF_ENTITY_ID ImplementationIdentifier
;
304 UINT32 LengthOfExtendedAttributes
;
305 UINT32 LengthOfAllocationDescriptors
;
306 UINT8 Data
[0]; // L_EA + L_AD
307 } UDF_EXTENDED_FILE_ENTRY
;
311 UINT8 LengthOfComponentIdentifier
;
312 UINT16 ComponentFileVersionNumber
;
313 UINT8 ComponentIdentifier
[0];
314 } UDF_PATH_COMPONENT
;
319 // UDF filesystem driver's private data
322 UINT64 MainVdsStartLocation
;
323 UDF_LOGICAL_VOLUME_DESCRIPTOR LogicalVolDesc
;
324 UDF_PARTITION_DESCRIPTOR PartitionDesc
;
325 UDF_FILE_SET_DESCRIPTOR FileSetDesc
;
331 UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
;
336 UINT64 DirectoryLength
;
338 } UDF_READ_DIRECTORY_INFO
;
340 #define PRIVATE_UDF_FILE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 'f')
342 #define PRIVATE_UDF_FILE_DATA_FROM_THIS(a) \
345 PRIVATE_UDF_FILE_DATA, \
347 PRIVATE_UDF_FILE_DATA_SIGNATURE \
352 BOOLEAN IsRootDirectory
;
355 UDF_READ_DIRECTORY_INFO ReadDirInfo
;
356 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFs
;
357 EFI_FILE_PROTOCOL FileIo
;
358 CHAR16 AbsoluteFileName
[UDF_PATH_LENGTH
];
359 CHAR16 FileName
[UDF_FILENAME_LENGTH
];
362 } PRIVATE_UDF_FILE_DATA
;
364 #define PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 's')
366 #define PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS(a) \
369 PRIVATE_UDF_SIMPLE_FS_DATA, \
371 PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE \
376 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
377 EFI_DISK_IO_PROTOCOL
*DiskIo
;
378 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs
;
379 UDF_VOLUME_INFO Volume
;
383 } PRIVATE_UDF_SIMPLE_FS_DATA
;
388 extern EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding
;
389 extern EFI_COMPONENT_NAME_PROTOCOL gUdfComponentName
;
390 extern EFI_COMPONENT_NAME2_PROTOCOL gUdfComponentName2
;
393 // Function Prototypes
397 Open the root directory on a volume.
399 @param This Protocol instance pointer.
400 @param Root Returns an Open file handle for the root directory
402 @retval EFI_SUCCESS The device was opened.
403 @retval EFI_UNSUPPORTED This volume does not support the file system.
404 @retval EFI_NO_MEDIA The device has no media.
405 @retval EFI_DEVICE_ERROR The device reported an error.
406 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
407 @retval EFI_ACCESS_DENIED The service denied access to the file.
408 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
414 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
415 OUT EFI_FILE_PROTOCOL
**Root
419 Opens a new file relative to the source file's location.
421 @param This The protocol instance pointer.
422 @param NewHandle Returns File Handle for FileName.
423 @param FileName Null terminated string. "\", ".", and ".." are supported.
424 @param OpenMode Open mode for file.
425 @param Attributes Only used for EFI_FILE_MODE_CREATE.
427 @retval EFI_SUCCESS The device was opened.
428 @retval EFI_NOT_FOUND The specified file could not be found on the device.
429 @retval EFI_NO_MEDIA The device has no media.
430 @retval EFI_MEDIA_CHANGED The media has changed.
431 @retval EFI_DEVICE_ERROR The device reported an error.
432 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
433 @retval EFI_ACCESS_DENIED The service denied access to the file.
434 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
435 @retval EFI_VOLUME_FULL The volume is full.
441 IN EFI_FILE_PROTOCOL
*This
,
442 OUT EFI_FILE_PROTOCOL
**NewHandle
,
449 Read data from the file.
451 @param This Protocol instance pointer.
452 @param BufferSize On input size of buffer, on output amount of data in buffer.
453 @param Buffer The buffer in which data is read.
455 @retval EFI_SUCCESS Data was read.
456 @retval EFI_NO_MEDIA The device has no media.
457 @retval EFI_DEVICE_ERROR The device reported an error.
458 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
459 @retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size.
465 IN EFI_FILE_PROTOCOL
*This
,
466 IN OUT UINTN
*BufferSize
,
471 Close the file handle.
473 @param This Protocol instance pointer.
475 @retval EFI_SUCCESS The file was closed.
481 IN EFI_FILE_PROTOCOL
*This
485 Close and delete the file handle.
487 @param This Protocol instance pointer.
489 @retval EFI_SUCCESS The file was closed and deleted.
490 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not
497 IN EFI_FILE_PROTOCOL
*This
501 Write data to a file.
503 @param This Protocol instance pointer.
504 @param BufferSize On input size of buffer, on output amount of data in buffer.
505 @param Buffer The buffer in which data to write.
507 @retval EFI_SUCCESS Data was written.
508 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
509 @retval EFI_NO_MEDIA The device has no media.
510 @retval EFI_DEVICE_ERROR The device reported an error.
511 @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
512 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
513 @retval EFI_WRITE_PROTECTED The device is write protected.
514 @retval EFI_ACCESS_DENIED The file was open for read only.
515 @retval EFI_VOLUME_FULL The volume is full.
521 IN EFI_FILE_PROTOCOL
*This
,
522 IN OUT UINTN
*BufferSize
,
527 Get file's current position.
529 @param This Protocol instance pointer.
530 @param Position Byte position from the start of the file.
532 @retval EFI_SUCCESS Position was updated.
533 @retval EFI_UNSUPPORTED Seek request for directories is not valid.
539 IN EFI_FILE_PROTOCOL
*This
,
544 Set file's current position.
546 @param This Protocol instance pointer.
547 @param Position Byte position from the start of the file.
549 @retval EFI_SUCCESS Position was updated.
550 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
556 IN EFI_FILE_PROTOCOL
*This
,
561 Get information about a file.
563 @attention This is boundary function that may receive untrusted input.
564 @attention The input is from FileSystem.
566 The File Set Descriptor is external input, so this routine will do basic
567 validation for File Set Descriptor and report status.
569 @param This Protocol instance pointer.
570 @param InformationType Type of information to return in Buffer.
571 @param BufferSize On input size of buffer, on output amount of data in
573 @param Buffer The buffer to return data.
575 @retval EFI_SUCCESS Data was returned.
576 @retval EFI_UNSUPPORTED InformationType is not supported.
577 @retval EFI_NO_MEDIA The device has no media.
578 @retval EFI_DEVICE_ERROR The device reported an error.
579 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
580 @retval EFI_WRITE_PROTECTED The device is write protected.
581 @retval EFI_ACCESS_DENIED The file was open for read only.
582 @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in
589 IN EFI_FILE_PROTOCOL
*This
,
590 IN EFI_GUID
*InformationType
,
591 IN OUT UINTN
*BufferSize
,
596 Set information about a file.
598 @param This Protocol instance pointer.
599 @param InformationType Type of information in Buffer.
600 @param BufferSize Size of buffer.
601 @param Buffer The data to write.
603 @retval EFI_SUCCESS Data was set.
604 @retval EFI_UNSUPPORTED InformationType is not supported.
605 @retval EFI_NO_MEDIA The device has no media.
606 @retval EFI_DEVICE_ERROR The device reported an error.
607 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
608 @retval EFI_WRITE_PROTECTED The device is write protected.
609 @retval EFI_ACCESS_DENIED The file was open for read only.
615 IN EFI_FILE_PROTOCOL
*This
,
616 IN EFI_GUID
*InformationType
,
622 Flush data back for the file handle.
624 @param This Protocol instance pointer.
626 @retval EFI_SUCCESS Data was flushed.
627 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
628 @retval EFI_NO_MEDIA The device has no media.
629 @retval EFI_DEVICE_ERROR The device reported an error.
630 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
631 @retval EFI_WRITE_PROTECTED The device is write protected.
632 @retval EFI_ACCESS_DENIED The file was open for read only.
633 @retval EFI_VOLUME_FULL The volume is full.
639 IN EFI_FILE_PROTOCOL
*This
643 Read volume information on a medium which contains a valid UDF file system.
645 @param[in] BlockIo BlockIo interface.
646 @param[in] DiskIo DiskIo interface.
647 @param[out] Volume UDF volume information structure.
649 @retval EFI_SUCCESS Volume information read.
650 @retval EFI_NO_MEDIA The device has no media.
651 @retval EFI_DEVICE_ERROR The device reported an error.
652 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
653 @retval EFI_OUT_OF_RESOURCES The volume was not read due to lack of resources.
657 ReadUdfVolumeInformation (
658 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
659 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
660 OUT UDF_VOLUME_INFO
*Volume
664 Find the root directory on an UDF volume.
666 @param[in] BlockIo BlockIo interface.
667 @param[in] DiskIo DiskIo interface.
668 @param[in] Volume UDF volume information structure.
669 @param[out] File Root directory file.
671 @retval EFI_SUCCESS Root directory found.
672 @retval EFI_NO_MEDIA The device has no media.
673 @retval EFI_DEVICE_ERROR The device reported an error.
674 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
675 @retval EFI_OUT_OF_RESOURCES The root directory was not found due to lack of
681 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
682 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
683 IN UDF_VOLUME_INFO
*Volume
,
684 OUT UDF_FILE_INFO
*File
688 Find either a File Entry or a Extended File Entry from a given ICB.
690 @param[in] BlockIo BlockIo interface.
691 @param[in] DiskIo DiskIo interface.
692 @param[in] Volume UDF volume information structure.
693 @param[in] Icb ICB of the FID.
694 @param[out] FileEntry File Entry or Extended File Entry.
696 @retval EFI_SUCCESS File Entry or Extended File Entry found.
697 @retval EFI_NO_MEDIA The device has no media.
698 @retval EFI_DEVICE_ERROR The device reported an error.
699 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
700 @retval EFI_OUT_OF_RESOURCES The FE/EFE entry was not found due to lack of
706 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
707 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
708 IN UDF_VOLUME_INFO
*Volume
,
709 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
714 Find a file given its absolute path on an UDF volume.
716 @param[in] BlockIo BlockIo interface.
717 @param[in] DiskIo DiskIo interface.
718 @param[in] Volume UDF volume information structure.
719 @param[in] FilePath File's absolute path.
720 @param[in] Root Root directory file.
721 @param[in] Parent Parent directory file.
722 @param[in] Icb ICB of Parent.
723 @param[out] File Found file.
725 @retval EFI_SUCCESS FilePath was found.
726 @retval EFI_NO_MEDIA The device has no media.
727 @retval EFI_DEVICE_ERROR The device reported an error.
728 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
729 @retval EFI_OUT_OF_RESOURCES The FilePath file was not found due to lack of
735 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
736 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
737 IN UDF_VOLUME_INFO
*Volume
,
739 IN UDF_FILE_INFO
*Root
,
740 IN UDF_FILE_INFO
*Parent
,
741 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
742 OUT UDF_FILE_INFO
*File
746 Read a directory entry at a time on an UDF volume.
748 @param[in] BlockIo BlockIo interface.
749 @param[in] DiskIo DiskIo interface.
750 @param[in] Volume UDF volume information structure.
751 @param[in] ParentIcb ICB of the parent file.
752 @param[in] FileEntryData FE/EFE of the parent file.
753 @param[in, out] ReadDirInfo Next read directory listing structure
755 @param[out] FoundFid File Identifier Descriptor pointer.
757 @retval EFI_SUCCESS Directory entry read.
758 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
759 @retval EFI_NO_MEDIA The device has no media.
760 @retval EFI_DEVICE_ERROR The device reported an error.
761 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
762 @retval EFI_OUT_OF_RESOURCES The directory entry was not read due to lack of
768 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
769 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
770 IN UDF_VOLUME_INFO
*Volume
,
771 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*ParentIcb
,
772 IN VOID
*FileEntryData
,
773 IN OUT UDF_READ_DIRECTORY_INFO
*ReadDirInfo
,
774 OUT UDF_FILE_IDENTIFIER_DESCRIPTOR
**FoundFid
778 Get a filename (encoded in OSTA-compressed format) from a File Identifier
779 Descriptor on an UDF volume.
781 @attention This is boundary function that may receive untrusted input.
782 @attention The input is from FileSystem.
784 The File Identifier Descriptor is external input, so this routine will do
785 basic validation for File Identifier Descriptor and report status.
787 @param[in] FileIdentifierDesc File Identifier Descriptor pointer.
788 @param[in] CharMax The maximum number of FileName Unicode char,
789 including terminating null char.
790 @param[out] FileName Decoded filename.
792 @retval EFI_SUCCESS Filename decoded and read.
793 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
794 @retval EFI_BUFFER_TOO_SMALL The string buffer FileName cannot hold the
799 IN UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
,
805 Resolve a symlink file on an UDF volume.
807 @attention This is boundary function that may receive untrusted input.
808 @attention The input is from FileSystem.
810 The Path Component is external input, so this routine will do basic
811 validation for Path Component and report status.
813 @param[in] BlockIo BlockIo interface.
814 @param[in] DiskIo DiskIo interface.
815 @param[in] Volume UDF volume information structure.
816 @param[in] Parent Parent file.
817 @param[in] FileEntryData FE/EFE structure pointer.
818 @param[out] File Resolved file.
820 @retval EFI_SUCCESS Symlink file resolved.
821 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
822 @retval EFI_NO_MEDIA The device has no media.
823 @retval EFI_DEVICE_ERROR The device reported an error.
824 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
825 @retval EFI_OUT_OF_RESOURCES The symlink file was not resolved due to lack of
831 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
832 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
833 IN UDF_VOLUME_INFO
*Volume
,
834 IN UDF_FILE_INFO
*Parent
,
835 IN VOID
*FileEntryData
,
836 OUT UDF_FILE_INFO
*File
840 Clean up in-memory UDF file information.
842 @param[in] File File information pointer.
846 CleanupFileInformation (
847 IN UDF_FILE_INFO
*File
851 Find a file from its absolute path on an UDF volume.
853 @param[in] BlockIo BlockIo interface.
854 @param[in] DiskIo DiskIo interface.
855 @param[in] Volume UDF volume information structure.
856 @param[in] File File information structure.
857 @param[out] Size Size of the file.
859 @retval EFI_SUCCESS File size calculated and set in Size.
860 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
861 @retval EFI_NO_MEDIA The device has no media.
862 @retval EFI_DEVICE_ERROR The device reported an error.
863 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
864 @retval EFI_OUT_OF_RESOURCES The file size was not calculated due to lack of
870 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
871 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
872 IN UDF_VOLUME_INFO
*Volume
,
873 IN UDF_FILE_INFO
*File
,
878 Set information about a file on an UDF volume.
880 @param[in] File File pointer.
881 @param[in] FileSize Size of the file.
882 @param[in] FileName Filename of the file.
883 @param[in, out] BufferSize Size of the returned file infomation.
884 @param[out] Buffer Data of the returned file information.
886 @retval EFI_SUCCESS File information set.
887 @retval EFI_NO_MEDIA The device has no media.
888 @retval EFI_DEVICE_ERROR The device reported an error.
889 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
890 @retval EFI_OUT_OF_RESOURCES The file information was not set due to lack of
896 IN UDF_FILE_INFO
*File
,
899 IN OUT UINTN
*BufferSize
,
904 Get volume and free space size information of an UDF volume.
906 @attention This is boundary function that may receive untrusted input.
907 @attention The input is from FileSystem.
909 The Logical Volume Descriptor and the Logical Volume Integrity Descriptor are
910 external inputs, so this routine will do basic validation for both descriptors
913 @param[in] BlockIo BlockIo interface.
914 @param[in] DiskIo DiskIo interface.
915 @param[in] Volume UDF volume information structure.
916 @param[out] VolumeSize Volume size.
917 @param[out] FreeSpaceSize Free space size.
919 @retval EFI_SUCCESS Volume and free space size calculated.
920 @retval EFI_NO_MEDIA The device has no media.
921 @retval EFI_DEVICE_ERROR The device reported an error.
922 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
923 @retval EFI_OUT_OF_RESOURCES The volume and free space size were not
924 calculated due to lack of resources.
929 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
930 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
931 IN UDF_VOLUME_INFO
*Volume
,
932 OUT UINT64
*VolumeSize
,
933 OUT UINT64
*FreeSpaceSize
937 Seek a file and read its data into memory on an UDF volume.
939 @param[in] BlockIo BlockIo interface.
940 @param[in] DiskIo DiskIo interface.
941 @param[in] Volume UDF volume information structure.
942 @param[in] File File information structure.
943 @param[in] FileSize Size of the file.
944 @param[in, out] FilePosition File position.
945 @param[in, out] Buffer File data.
946 @param[in, out] BufferSize Read size.
948 @retval EFI_SUCCESS File seeked and read.
949 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
950 @retval EFI_NO_MEDIA The device has no media.
951 @retval EFI_DEVICE_ERROR The device reported an error.
952 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
953 @retval EFI_OUT_OF_RESOURCES The file's recorded data was not read due to lack
959 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
960 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
961 IN UDF_VOLUME_INFO
*Volume
,
962 IN UDF_FILE_INFO
*File
,
964 IN OUT UINT64
*FilePosition
,
966 IN OUT UINT64
*BufferSize
970 Check if ControllerHandle supports an UDF file system.
972 @param[in] This Protocol instance pointer.
973 @param[in] ControllerHandle Handle of device to test.
975 @retval EFI_SUCCESS UDF file system found.
976 @retval EFI_UNSUPPORTED UDF file system not found.
980 SupportUdfFileSystem (
981 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
982 IN EFI_HANDLE ControllerHandle
986 Mangle a filename by cutting off trailing whitespaces, "\\", "." and "..".
988 @param[in] FileName Filename.
990 @retval The mangled Filename.
999 Test to see if this driver supports ControllerHandle. Any ControllerHandle
1000 than contains a BlockIo and DiskIo protocol can be supported.
1002 @param This Protocol instance pointer.
1003 @param ControllerHandle Handle of device to test
1004 @param RemainingDevicePath Optional parameter use to pick a specific child
1007 @retval EFI_SUCCESS This driver supports this device
1008 @retval EFI_ALREADY_STARTED This driver is already running on this device
1009 @retval other This driver does not support this device
1014 UdfDriverBindingSupported (
1015 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1016 IN EFI_HANDLE ControllerHandle
,
1017 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1021 Start this driver on ControllerHandle by opening a Block IO and Disk IO
1022 protocol, reading Device Path, and creating a child handle with a
1023 Disk IO and device path protocol.
1025 @param This Protocol instance pointer.
1026 @param ControllerHandle Handle of device to bind driver to
1027 @param RemainingDevicePath Optional parameter use to pick a specific child
1030 @retval EFI_SUCCESS This driver is added to ControllerHandle
1031 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
1032 @retval other This driver does not support this device
1037 UdfDriverBindingStart (
1038 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1039 IN EFI_HANDLE ControllerHandle
,
1040 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1044 Stop this driver on ControllerHandle. Support stopping any child handles
1045 created by this driver.
1047 @param This Protocol instance pointer.
1048 @param ControllerHandle Handle of device to stop driver on
1049 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1050 children is zero stop the entire bus driver.
1051 @param ChildHandleBuffer List of Child Handles to Stop.
1053 @retval EFI_SUCCESS This driver is removed ControllerHandle
1054 @retval other This driver was not removed from this device
1059 UdfDriverBindingStop (
1060 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1061 IN EFI_HANDLE ControllerHandle
,
1062 IN UINTN NumberOfChildren
,
1063 IN EFI_HANDLE
*ChildHandleBuffer
1067 // EFI Component Name Functions
1070 Retrieves a Unicode string that is the user readable name of the driver.
1072 This function retrieves the user readable name of a driver in the form of a
1073 Unicode string. If the driver specified by This has a user readable name in
1074 the language specified by Language, then a pointer to the driver name is
1075 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
1076 by This does not support the language specified by Language,
1077 then EFI_UNSUPPORTED is returned.
1079 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1080 EFI_COMPONENT_NAME_PROTOCOL instance.
1082 @param Language[in] A pointer to a Null-terminated ASCII string
1083 array indicating the language. This is the
1084 language of the driver name that the caller is
1085 requesting, and it must match one of the
1086 languages specified in SupportedLanguages. The
1087 number of languages supported by a driver is up
1088 to the driver writer. Language is specified
1089 in RFC 4646 or ISO 639-2 language code format.
1091 @param DriverName[out] A pointer to the Unicode string to return.
1092 This Unicode string is the name of the
1093 driver specified by This in the language
1094 specified by Language.
1096 @retval EFI_SUCCESS The Unicode string for the Driver specified by
1097 This and the language specified by Language was
1098 returned in DriverName.
1100 @retval EFI_INVALID_PARAMETER Language is NULL.
1102 @retval EFI_INVALID_PARAMETER DriverName is NULL.
1104 @retval EFI_UNSUPPORTED The driver specified by This does not support
1105 the language specified by Language.
1110 UdfComponentNameGetDriverName (
1111 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1113 OUT CHAR16
**DriverName
1117 Retrieves a Unicode string that is the user readable name of the controller
1118 that is being managed by a driver.
1120 This function retrieves the user readable name of the controller specified by
1121 ControllerHandle and ChildHandle in the form of a Unicode string. If the
1122 driver specified by This has a user readable name in the language specified by
1123 Language, then a pointer to the controller name is returned in ControllerName,
1124 and EFI_SUCCESS is returned. If the driver specified by This is not currently
1125 managing the controller specified by ControllerHandle and ChildHandle,
1126 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
1127 support the language specified by Language, then EFI_UNSUPPORTED is returned.
1129 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1130 EFI_COMPONENT_NAME_PROTOCOL instance.
1132 @param ControllerHandle[in] The handle of a controller that the driver
1133 specified by This is managing. This handle
1134 specifies the controller whose name is to be
1137 @param ChildHandle[in] The handle of the child controller to retrieve
1138 the name of. This is an optional parameter that
1139 may be NULL. It will be NULL for device
1140 drivers. It will also be NULL for a bus drivers
1141 that wish to retrieve the name of the bus
1142 controller. It will not be NULL for a bus
1143 driver that wishes to retrieve the name of a
1146 @param Language[in] A pointer to a Null-terminated ASCII string
1147 array indicating the language. This is the
1148 language of the driver name that the caller is
1149 requesting, and it must match one of the
1150 languages specified in SupportedLanguages. The
1151 number of languages supported by a driver is up
1152 to the driver writer. Language is specified in
1153 RFC 4646 or ISO 639-2 language code format.
1155 @param ControllerName[out] A pointer to the Unicode string to return.
1156 This Unicode string is the name of the
1157 controller specified by ControllerHandle and
1158 ChildHandle in the language specified by
1159 Language from the point of view of the driver
1162 @retval EFI_SUCCESS The Unicode string for the user readable name in
1163 the language specified by Language for the
1164 driver specified by This was returned in
1167 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
1169 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
1172 @retval EFI_INVALID_PARAMETER Language is NULL.
1174 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
1176 @retval EFI_UNSUPPORTED The driver specified by This is not currently
1177 managing the controller specified by
1178 ControllerHandle and ChildHandle.
1180 @retval EFI_UNSUPPORTED The driver specified by This does not support
1181 the language specified by Language.
1186 UdfComponentNameGetControllerName (
1187 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1188 IN EFI_HANDLE ControllerHandle
,
1189 IN EFI_HANDLE ChildHandle OPTIONAL
,
1191 OUT CHAR16
**ControllerName