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 FE_ICB_FILE_TYPE(_Ptr) \
53 (UDF_FILE_ENTRY_TYPE)( \
54 ((UDF_DESCRIPTOR_TAG *)(_Ptr))->TagIdentifier == UdfFileEntry ? \
55 ((UDF_FILE_ENTRY *)(_Ptr))->IcbTag.FileType : \
56 ((UDF_EXTENDED_FILE_ENTRY *)(_Ptr))->IcbTag.FileType)
59 UdfFileEntryDirectory
= 4,
60 UdfFileEntryStandardFile
= 5,
61 UdfFileEntrySymlink
= 12,
62 } UDF_FILE_ENTRY_TYPE
;
64 #define HIDDEN_FILE (1 << 0)
65 #define DIRECTORY_FILE (1 << 1)
66 #define DELETED_FILE (1 << 2)
67 #define PARENT_FILE (1 << 3)
69 #define IS_FID_HIDDEN_FILE(_Fid) \
70 (BOOLEAN)((_Fid)->FileCharacteristics & HIDDEN_FILE)
71 #define IS_FID_DIRECTORY_FILE(_Fid) \
72 (BOOLEAN)((_Fid)->FileCharacteristics & DIRECTORY_FILE)
73 #define IS_FID_DELETED_FILE(_Fid) \
74 (BOOLEAN)((_Fid)->FileCharacteristics & DELETED_FILE)
75 #define IS_FID_PARENT_FILE(_Fid) \
76 (BOOLEAN)((_Fid)->FileCharacteristics & PARENT_FILE)
77 #define IS_FID_NORMAL_FILE(_Fid) \
78 (BOOLEAN)(!IS_FID_DIRECTORY_FILE (_Fid) && \
79 !IS_FID_PARENT_FILE (_Fid))
86 } UDF_FE_RECORDING_FLAGS
;
88 #define GET_FE_RECORDING_FLAGS(_Fe) \
89 ((UDF_FE_RECORDING_FLAGS)((UDF_ICB_TAG *)( \
91 sizeof (UDF_DESCRIPTOR_TAG)))->Flags & 0x07)
94 ExtentRecordedAndAllocated
,
95 ExtentNotRecordedButAllocated
,
96 ExtentNotRecordedNotAllocated
,
100 #define AD_LENGTH(_RecFlags) \
101 ((_RecFlags) == ShortAdsSequence ? \
102 ((UINT64)(sizeof (UDF_SHORT_ALLOCATION_DESCRIPTOR))) : \
103 ((UINT64)(sizeof (UDF_LONG_ALLOCATION_DESCRIPTOR))))
105 #define GET_EXTENT_FLAGS(_RecFlags, _Ad) \
106 ((_RecFlags) == ShortAdsSequence ? \
107 ((UDF_EXTENT_FLAGS)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
109 ((UDF_EXTENT_FLAGS)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength >> \
112 #define GET_EXTENT_LENGTH(_RecFlags, _Ad) \
113 ((_RecFlags) == ShortAdsSequence ? \
114 ((UINT32)((((UDF_SHORT_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
116 ((UINT32)((((UDF_LONG_ALLOCATION_DESCRIPTOR *)(_Ad))->ExtentLength & \
119 #define UDF_FILENAME_LENGTH 128
120 #define UDF_PATH_LENGTH 512
122 #define GET_FID_FROM_ADS(_Data, _Offs) \
123 ((UDF_FILE_IDENTIFIER_DESCRIPTOR *)((UINT8 *)(_Data) + (_Offs)))
125 #define IS_VALID_COMPRESSION_ID(_CompId) \
126 ((BOOLEAN)((_CompId) == 8 || (_CompId) == 16))
128 #define UDF_STANDARD_IDENTIFIER_LENGTH 5
133 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
134 } UDF_STANDARD_IDENTIFIER
;
140 ReadFileAllocateAndRead
,
142 } UDF_READ_FILE_FLAGS
;
146 UDF_READ_FILE_FLAGS Flags
;
151 } UDF_READ_FILE_INFO
;
156 UINT16 TypeAndTimezone
;
164 UINT8 HundredsOfMicroseconds
;
169 UDF_DESCRIPTOR_TAG DescriptorTag
;
170 UINT32 PrevAllocationExtentDescriptor
;
171 UINT32 LengthOfAllocationDescriptors
;
172 } UDF_ALLOCATION_EXTENT_DESCRIPTOR
;
176 UINT8 StandardIdentifier
[UDF_STANDARD_IDENTIFIER_LENGTH
];
177 UINT8 StructureVersion
;
179 UINT8 StructureData
[2040];
180 } UDF_VOLUME_DESCRIPTOR
;
183 UDF_DESCRIPTOR_TAG DescriptorTag
;
184 UDF_TIMESTAMP RecordingDateTime
;
185 UINT32 IntegrityType
;
186 UDF_EXTENT_AD NextIntegrityExtent
;
187 UINT8 LogicalVolumeContentsUse
[32];
188 UINT32 NumberOfPartitions
;
189 UINT32 LengthOfImplementationUse
;
191 } UDF_LOGICAL_VOLUME_INTEGRITY
;
194 UDF_DESCRIPTOR_TAG DescriptorTag
;
195 UINT32 VolumeDescriptorSequenceNumber
;
196 UINT16 PartitionFlags
;
197 UINT16 PartitionNumber
;
198 UDF_ENTITY_ID PartitionContents
;
199 UINT8 PartitionContentsUse
[128];
201 UINT32 PartitionStartingLocation
;
202 UINT32 PartitionLength
;
203 UDF_ENTITY_ID ImplementationIdentifier
;
204 UINT8 ImplementationUse
[128];
206 } UDF_PARTITION_DESCRIPTOR
;
209 UDF_DESCRIPTOR_TAG DescriptorTag
;
210 UDF_TIMESTAMP RecordingDateAndTime
;
211 UINT16 InterchangeLevel
;
212 UINT16 MaximumInterchangeLevel
;
213 UINT32 CharacterSetList
;
214 UINT32 MaximumCharacterSetList
;
215 UINT32 FileSetNumber
;
216 UINT32 FileSetDescriptorNumber
;
217 UDF_CHAR_SPEC LogicalVolumeIdentifierCharacterSet
;
218 UINT8 LogicalVolumeIdentifier
[128];
219 UDF_CHAR_SPEC FileSetCharacterSet
;
220 UINT8 FileSetIdentifier
[32];
221 UINT8 CopyrightFileIdentifier
[32];
222 UINT8 AbstractFileIdentifier
[32];
223 UDF_LONG_ALLOCATION_DESCRIPTOR RootDirectoryIcb
;
224 UDF_ENTITY_ID DomainIdentifier
;
225 UDF_LONG_ALLOCATION_DESCRIPTOR NextExtent
;
226 UDF_LONG_ALLOCATION_DESCRIPTOR SystemStreamDirectoryIcb
;
228 } UDF_FILE_SET_DESCRIPTOR
;
232 UINT32 ExtentPosition
;
233 } UDF_SHORT_ALLOCATION_DESCRIPTOR
;
236 UDF_DESCRIPTOR_TAG DescriptorTag
;
237 UINT16 FileVersionNumber
;
238 UINT8 FileCharacteristics
;
239 UINT8 LengthOfFileIdentifier
;
240 UDF_LONG_ALLOCATION_DESCRIPTOR Icb
;
241 UINT16 LengthOfImplementationUse
;
243 } UDF_FILE_IDENTIFIER_DESCRIPTOR
;
246 UINT32 PriorRecordNumberOfDirectEntries
;
248 UINT16 StrategyParameter
;
249 UINT16 MaximumNumberOfEntries
;
252 UDF_LB_ADDR ParentIcbLocation
;
257 UDF_DESCRIPTOR_TAG DescriptorTag
;
262 UINT16 FileLinkCount
;
264 UINT8 RecordDisplayAttributes
;
266 UINT64 InformationLength
;
267 UINT64 LogicalBlocksRecorded
;
268 UDF_TIMESTAMP AccessTime
;
269 UDF_TIMESTAMP ModificationTime
;
270 UDF_TIMESTAMP AttributeTime
;
272 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
273 UDF_ENTITY_ID ImplementationIdentifier
;
275 UINT32 LengthOfExtendedAttributes
;
276 UINT32 LengthOfAllocationDescriptors
;
277 UINT8 Data
[0]; // L_EA + L_AD
281 UDF_DESCRIPTOR_TAG DescriptorTag
;
286 UINT16 FileLinkCount
;
288 UINT8 RecordDisplayAttributes
;
290 UINT64 InformationLength
;
292 UINT64 LogicalBlocksRecorded
;
293 UDF_TIMESTAMP AccessTime
;
294 UDF_TIMESTAMP ModificationTime
;
295 UDF_TIMESTAMP CreationTime
;
296 UDF_TIMESTAMP AttributeTime
;
299 UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb
;
300 UDF_LONG_ALLOCATION_DESCRIPTOR StreamDirectoryIcb
;
301 UDF_ENTITY_ID ImplementationIdentifier
;
303 UINT32 LengthOfExtendedAttributes
;
304 UINT32 LengthOfAllocationDescriptors
;
305 UINT8 Data
[0]; // L_EA + L_AD
306 } UDF_EXTENDED_FILE_ENTRY
;
310 UINT8 LengthOfComponentIdentifier
;
311 UINT16 ComponentFileVersionNumber
;
312 UINT8 ComponentIdentifier
[0];
313 } UDF_PATH_COMPONENT
;
318 // UDF filesystem driver's private data
321 UINT64 MainVdsStartLocation
;
322 UDF_LOGICAL_VOLUME_DESCRIPTOR LogicalVolDesc
;
323 UDF_PARTITION_DESCRIPTOR PartitionDesc
;
324 UDF_FILE_SET_DESCRIPTOR FileSetDesc
;
330 UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
;
335 UINT64 DirectoryLength
;
337 } UDF_READ_DIRECTORY_INFO
;
339 #define PRIVATE_UDF_FILE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 'f')
341 #define PRIVATE_UDF_FILE_DATA_FROM_THIS(a) \
344 PRIVATE_UDF_FILE_DATA, \
346 PRIVATE_UDF_FILE_DATA_SIGNATURE \
351 BOOLEAN IsRootDirectory
;
354 UDF_READ_DIRECTORY_INFO ReadDirInfo
;
355 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFs
;
356 EFI_FILE_PROTOCOL FileIo
;
357 CHAR16 AbsoluteFileName
[UDF_PATH_LENGTH
];
358 CHAR16 FileName
[UDF_FILENAME_LENGTH
];
361 } PRIVATE_UDF_FILE_DATA
;
363 #define PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 's')
365 #define PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS(a) \
368 PRIVATE_UDF_SIMPLE_FS_DATA, \
370 PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE \
375 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
376 EFI_DISK_IO_PROTOCOL
*DiskIo
;
377 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs
;
378 UDF_VOLUME_INFO Volume
;
382 } PRIVATE_UDF_SIMPLE_FS_DATA
;
387 extern EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding
;
388 extern EFI_COMPONENT_NAME_PROTOCOL gUdfComponentName
;
389 extern EFI_COMPONENT_NAME2_PROTOCOL gUdfComponentName2
;
392 // Function Prototypes
396 Open the root directory on a volume.
398 @param This Protocol instance pointer.
399 @param Root Returns an Open file handle for the root directory
401 @retval EFI_SUCCESS The device was opened.
402 @retval EFI_UNSUPPORTED This volume does not support the file system.
403 @retval EFI_NO_MEDIA The device has no media.
404 @retval EFI_DEVICE_ERROR The device reported an error.
405 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
406 @retval EFI_ACCESS_DENIED The service denied access to the file.
407 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
413 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
414 OUT EFI_FILE_PROTOCOL
**Root
418 Opens a new file relative to the source file's location.
420 @param This The protocol instance pointer.
421 @param NewHandle Returns File Handle for FileName.
422 @param FileName Null terminated string. "\", ".", and ".." are supported.
423 @param OpenMode Open mode for file.
424 @param Attributes Only used for EFI_FILE_MODE_CREATE.
426 @retval EFI_SUCCESS The device was opened.
427 @retval EFI_NOT_FOUND The specified file could not be found on the device.
428 @retval EFI_NO_MEDIA The device has no media.
429 @retval EFI_MEDIA_CHANGED The media has changed.
430 @retval EFI_DEVICE_ERROR The device reported an error.
431 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
432 @retval EFI_ACCESS_DENIED The service denied access to the file.
433 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
434 @retval EFI_VOLUME_FULL The volume is full.
440 IN EFI_FILE_PROTOCOL
*This
,
441 OUT EFI_FILE_PROTOCOL
**NewHandle
,
448 Read data from the file.
450 @param This Protocol instance pointer.
451 @param BufferSize On input size of buffer, on output amount of data in buffer.
452 @param Buffer The buffer in which data is read.
454 @retval EFI_SUCCESS Data was read.
455 @retval EFI_NO_MEDIA The device has no media.
456 @retval EFI_DEVICE_ERROR The device reported an error.
457 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
458 @retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size.
464 IN EFI_FILE_PROTOCOL
*This
,
465 IN OUT UINTN
*BufferSize
,
470 Close the file handle.
472 @param This Protocol instance pointer.
474 @retval EFI_SUCCESS The file was closed.
480 IN EFI_FILE_PROTOCOL
*This
484 Close and delete the file handle.
486 @param This Protocol instance pointer.
488 @retval EFI_SUCCESS The file was closed and deleted.
489 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not
496 IN EFI_FILE_PROTOCOL
*This
500 Write data to a file.
502 @param This Protocol instance pointer.
503 @param BufferSize On input size of buffer, on output amount of data in buffer.
504 @param Buffer The buffer in which data to write.
506 @retval EFI_SUCCESS Data was written.
507 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
508 @retval EFI_NO_MEDIA The device has no media.
509 @retval EFI_DEVICE_ERROR The device reported an error.
510 @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
511 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
512 @retval EFI_WRITE_PROTECTED The device is write protected.
513 @retval EFI_ACCESS_DENIED The file was open for read only.
514 @retval EFI_VOLUME_FULL The volume is full.
520 IN EFI_FILE_PROTOCOL
*This
,
521 IN OUT UINTN
*BufferSize
,
526 Get file's current position.
528 @param This Protocol instance pointer.
529 @param Position Byte position from the start of the file.
531 @retval EFI_SUCCESS Position was updated.
532 @retval EFI_UNSUPPORTED Seek request for directories is not valid.
538 IN EFI_FILE_PROTOCOL
*This
,
543 Set file's current position.
545 @param This Protocol instance pointer.
546 @param Position Byte position from the start of the file.
548 @retval EFI_SUCCESS Position was updated.
549 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
555 IN EFI_FILE_PROTOCOL
*This
,
560 Get information about a file.
562 @param This Protocol instance pointer.
563 @param InformationType Type of information to return in Buffer.
564 @param BufferSize On input size of buffer, on output amount of data in buffer.
565 @param Buffer The buffer to return data.
567 @retval EFI_SUCCESS Data was returned.
568 @retval EFI_UNSUPPORTED InformationType is not supported.
569 @retval EFI_NO_MEDIA The device has no media.
570 @retval EFI_DEVICE_ERROR The device reported an error.
571 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
572 @retval EFI_WRITE_PROTECTED The device is write protected.
573 @retval EFI_ACCESS_DENIED The file was open for read only.
574 @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.
580 IN EFI_FILE_PROTOCOL
*This
,
581 IN EFI_GUID
*InformationType
,
582 IN OUT UINTN
*BufferSize
,
587 Set information about a file.
589 @param This Protocol instance pointer.
590 @param InformationType Type of information in Buffer.
591 @param BufferSize Size of buffer.
592 @param Buffer The data to write.
594 @retval EFI_SUCCESS Data was set.
595 @retval EFI_UNSUPPORTED InformationType is not supported.
596 @retval EFI_NO_MEDIA The device has no media.
597 @retval EFI_DEVICE_ERROR The device reported an error.
598 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
599 @retval EFI_WRITE_PROTECTED The device is write protected.
600 @retval EFI_ACCESS_DENIED The file was open for read only.
606 IN EFI_FILE_PROTOCOL
*This
,
607 IN EFI_GUID
*InformationType
,
613 Flush data back for the file handle.
615 @param This Protocol instance pointer.
617 @retval EFI_SUCCESS Data was flushed.
618 @retval EFI_UNSUPPORTED Writes to Open directory are not supported.
619 @retval EFI_NO_MEDIA The device has no media.
620 @retval EFI_DEVICE_ERROR The device reported an error.
621 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
622 @retval EFI_WRITE_PROTECTED The device is write protected.
623 @retval EFI_ACCESS_DENIED The file was open for read only.
624 @retval EFI_VOLUME_FULL The volume is full.
630 IN EFI_FILE_PROTOCOL
*This
634 Read volume information on a medium which contains a valid UDF file system.
636 @param[in] BlockIo BlockIo interface.
637 @param[in] DiskIo DiskIo interface.
638 @param[out] Volume UDF volume information structure.
640 @retval EFI_SUCCESS Volume information read.
641 @retval EFI_NO_MEDIA The device has no media.
642 @retval EFI_DEVICE_ERROR The device reported an error.
643 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
644 @retval EFI_OUT_OF_RESOURCES The volume was not read due to lack of resources.
648 ReadUdfVolumeInformation (
649 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
650 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
651 OUT UDF_VOLUME_INFO
*Volume
655 Find the root directory on an UDF volume.
657 @param[in] BlockIo BlockIo interface.
658 @param[in] DiskIo DiskIo interface.
659 @param[in] Volume UDF volume information structure.
660 @param[out] File Root directory file.
662 @retval EFI_SUCCESS Root directory found.
663 @retval EFI_NO_MEDIA The device has no media.
664 @retval EFI_DEVICE_ERROR The device reported an error.
665 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
666 @retval EFI_OUT_OF_RESOURCES The root directory was not found due to lack of
672 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
673 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
674 IN UDF_VOLUME_INFO
*Volume
,
675 OUT UDF_FILE_INFO
*File
679 Find either a File Entry or a Extended File Entry from a given ICB.
681 @param[in] BlockIo BlockIo interface.
682 @param[in] DiskIo DiskIo interface.
683 @param[in] Volume UDF volume information structure.
684 @param[in] Icb ICB of the FID.
685 @param[out] FileEntry File Entry or Extended File Entry.
687 @retval EFI_SUCCESS File Entry or Extended File Entry found.
688 @retval EFI_NO_MEDIA The device has no media.
689 @retval EFI_DEVICE_ERROR The device reported an error.
690 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
691 @retval EFI_OUT_OF_RESOURCES The FE/EFE entry was not found due to lack of
697 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
698 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
699 IN UDF_VOLUME_INFO
*Volume
,
700 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
705 Find a file given its absolute path on an UDF volume.
707 @param[in] BlockIo BlockIo interface.
708 @param[in] DiskIo DiskIo interface.
709 @param[in] Volume UDF volume information structure.
710 @param[in] FilePath File's absolute path.
711 @param[in] Root Root directory file.
712 @param[in] Parent Parent directory file.
713 @param[in] Icb ICB of Parent.
714 @param[out] File Found file.
716 @retval EFI_SUCCESS FilePath was found.
717 @retval EFI_NO_MEDIA The device has no media.
718 @retval EFI_DEVICE_ERROR The device reported an error.
719 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
720 @retval EFI_OUT_OF_RESOURCES The FilePath file was not found due to lack of
726 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
727 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
728 IN UDF_VOLUME_INFO
*Volume
,
730 IN UDF_FILE_INFO
*Root
,
731 IN UDF_FILE_INFO
*Parent
,
732 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*Icb
,
733 OUT UDF_FILE_INFO
*File
737 Read a directory entry at a time on an UDF volume.
739 @param[in] BlockIo BlockIo interface.
740 @param[in] DiskIo DiskIo interface.
741 @param[in] Volume UDF volume information structure.
742 @param[in] ParentIcb ICB of the parent file.
743 @param[in] FileEntryData FE/EFE of the parent file.
744 @param[in, out] ReadDirInfo Next read directory listing structure
746 @param[out] FoundFid File Identifier Descriptor pointer.
748 @retval EFI_SUCCESS Directory entry read.
749 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
750 @retval EFI_NO_MEDIA The device has no media.
751 @retval EFI_DEVICE_ERROR The device reported an error.
752 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
753 @retval EFI_OUT_OF_RESOURCES The directory entry was not read due to lack of
759 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
760 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
761 IN UDF_VOLUME_INFO
*Volume
,
762 IN UDF_LONG_ALLOCATION_DESCRIPTOR
*ParentIcb
,
763 IN VOID
*FileEntryData
,
764 IN OUT UDF_READ_DIRECTORY_INFO
*ReadDirInfo
,
765 OUT UDF_FILE_IDENTIFIER_DESCRIPTOR
**FoundFid
769 Get a filename (encoded in OSTA-compressed format) from a File Identifier
770 Descriptor on an UDF volume.
772 @param[in] FileIdentifierDesc File Identifier Descriptor pointer.
773 @param[out] FileName Decoded filename.
775 @retval EFI_SUCCESS Filename decoded and read.
776 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
780 IN UDF_FILE_IDENTIFIER_DESCRIPTOR
*FileIdentifierDesc
,
785 Resolve a symlink file on an UDF volume.
787 @param[in] BlockIo BlockIo interface.
788 @param[in] DiskIo DiskIo interface.
789 @param[in] Volume UDF volume information structure.
790 @param[in] Parent Parent file.
791 @param[in] FileEntryData FE/EFE structure pointer.
792 @param[out] File Resolved file.
794 @retval EFI_SUCCESS Symlink file resolved.
795 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
796 @retval EFI_NO_MEDIA The device has no media.
797 @retval EFI_DEVICE_ERROR The device reported an error.
798 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
799 @retval EFI_OUT_OF_RESOURCES The symlink file was not resolved due to lack of
805 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
806 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
807 IN UDF_VOLUME_INFO
*Volume
,
808 IN UDF_FILE_INFO
*Parent
,
809 IN VOID
*FileEntryData
,
810 OUT UDF_FILE_INFO
*File
814 Clean up in-memory UDF file information.
816 @param[in] File File information pointer.
820 CleanupFileInformation (
821 IN UDF_FILE_INFO
*File
825 Find a file from its absolute path on an UDF volume.
827 @param[in] BlockIo BlockIo interface.
828 @param[in] DiskIo DiskIo interface.
829 @param[in] Volume UDF volume information structure.
830 @param[in] File File information structure.
831 @param[out] Size Size of the file.
833 @retval EFI_SUCCESS File size calculated and set in Size.
834 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
835 @retval EFI_NO_MEDIA The device has no media.
836 @retval EFI_DEVICE_ERROR The device reported an error.
837 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
838 @retval EFI_OUT_OF_RESOURCES The file size was not calculated due to lack of
844 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
845 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
846 IN UDF_VOLUME_INFO
*Volume
,
847 IN UDF_FILE_INFO
*File
,
852 Set information about a file on an UDF volume.
854 @param[in] File File pointer.
855 @param[in] FileSize Size of the file.
856 @param[in] FileName Filename of the file.
857 @param[in, out] BufferSize Size of the returned file infomation.
858 @param[out] Buffer Data of the returned file information.
860 @retval EFI_SUCCESS File information set.
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 information was not set due to lack of
870 IN UDF_FILE_INFO
*File
,
873 IN OUT UINTN
*BufferSize
,
878 Get volume and free space size information of an UDF volume.
880 @param[in] BlockIo BlockIo interface.
881 @param[in] DiskIo DiskIo interface.
882 @param[in] Volume UDF volume information structure.
883 @param[out] VolumeSize Volume size.
884 @param[out] FreeSpaceSize Free space size.
886 @retval EFI_SUCCESS Volume and free space size calculated.
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 volume and free space size were not
891 calculated due to lack of resources.
896 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
897 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
898 IN UDF_VOLUME_INFO
*Volume
,
899 OUT UINT64
*VolumeSize
,
900 OUT UINT64
*FreeSpaceSize
904 Seek a file and read its data into memory on an UDF volume.
906 @param[in] BlockIo BlockIo interface.
907 @param[in] DiskIo DiskIo interface.
908 @param[in] Volume UDF volume information structure.
909 @param[in] File File information structure.
910 @param[in] FileSize Size of the file.
911 @param[in, out] FilePosition File position.
912 @param[in, out] Buffer File data.
913 @param[in, out] BufferSize Read size.
915 @retval EFI_SUCCESS File seeked and read.
916 @retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.
917 @retval EFI_NO_MEDIA The device has no media.
918 @retval EFI_DEVICE_ERROR The device reported an error.
919 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
920 @retval EFI_OUT_OF_RESOURCES The file's recorded data was not read due to lack
926 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
927 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
928 IN UDF_VOLUME_INFO
*Volume
,
929 IN UDF_FILE_INFO
*File
,
931 IN OUT UINT64
*FilePosition
,
933 IN OUT UINT64
*BufferSize
937 Check if ControllerHandle supports an UDF file system.
939 @param[in] This Protocol instance pointer.
940 @param[in] ControllerHandle Handle of device to test.
942 @retval EFI_SUCCESS UDF file system found.
943 @retval EFI_UNSUPPORTED UDF file system not found.
947 SupportUdfFileSystem (
948 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
949 IN EFI_HANDLE ControllerHandle
953 Mangle a filename by cutting off trailing whitespaces, "\\", "." and "..".
955 @param[in] FileName Filename.
957 @retval The mangled Filename.
966 Test to see if this driver supports ControllerHandle. Any ControllerHandle
967 than contains a BlockIo and DiskIo protocol can be supported.
969 @param This Protocol instance pointer.
970 @param ControllerHandle Handle of device to test
971 @param RemainingDevicePath Optional parameter use to pick a specific child
974 @retval EFI_SUCCESS This driver supports this device
975 @retval EFI_ALREADY_STARTED This driver is already running on this device
976 @retval other This driver does not support this device
981 UdfDriverBindingSupported (
982 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
983 IN EFI_HANDLE ControllerHandle
,
984 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
988 Start this driver on ControllerHandle by opening a Block IO and Disk IO
989 protocol, reading Device Path, and creating a child handle with a
990 Disk IO and device path protocol.
992 @param This Protocol instance pointer.
993 @param ControllerHandle Handle of device to bind driver to
994 @param RemainingDevicePath Optional parameter use to pick a specific child
997 @retval EFI_SUCCESS This driver is added to ControllerHandle
998 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
999 @retval other This driver does not support this device
1004 UdfDriverBindingStart (
1005 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1006 IN EFI_HANDLE ControllerHandle
,
1007 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1011 Stop this driver on ControllerHandle. Support stopping any child handles
1012 created by this driver.
1014 @param This Protocol instance pointer.
1015 @param ControllerHandle Handle of device to stop driver on
1016 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1017 children is zero stop the entire bus driver.
1018 @param ChildHandleBuffer List of Child Handles to Stop.
1020 @retval EFI_SUCCESS This driver is removed ControllerHandle
1021 @retval other This driver was not removed from this device
1026 UdfDriverBindingStop (
1027 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1028 IN EFI_HANDLE ControllerHandle
,
1029 IN UINTN NumberOfChildren
,
1030 IN EFI_HANDLE
*ChildHandleBuffer
1034 // EFI Component Name Functions
1037 Retrieves a Unicode string that is the user readable name of the driver.
1039 This function retrieves the user readable name of a driver in the form of a
1040 Unicode string. If the driver specified by This has a user readable name in
1041 the language specified by Language, then a pointer to the driver name is
1042 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
1043 by This does not support the language specified by Language,
1044 then EFI_UNSUPPORTED is returned.
1046 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1047 EFI_COMPONENT_NAME_PROTOCOL instance.
1049 @param Language[in] A pointer to a Null-terminated ASCII string
1050 array indicating the language. This is the
1051 language of the driver name that the caller is
1052 requesting, and it must match one of the
1053 languages specified in SupportedLanguages. The
1054 number of languages supported by a driver is up
1055 to the driver writer. Language is specified
1056 in RFC 4646 or ISO 639-2 language code format.
1058 @param DriverName[out] A pointer to the Unicode string to return.
1059 This Unicode string is the name of the
1060 driver specified by This in the language
1061 specified by Language.
1063 @retval EFI_SUCCESS The Unicode string for the Driver specified by
1064 This and the language specified by Language was
1065 returned in DriverName.
1067 @retval EFI_INVALID_PARAMETER Language is NULL.
1069 @retval EFI_INVALID_PARAMETER DriverName is NULL.
1071 @retval EFI_UNSUPPORTED The driver specified by This does not support
1072 the language specified by Language.
1077 UdfComponentNameGetDriverName (
1078 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1080 OUT CHAR16
**DriverName
1084 Retrieves a Unicode string that is the user readable name of the controller
1085 that is being managed by a driver.
1087 This function retrieves the user readable name of the controller specified by
1088 ControllerHandle and ChildHandle in the form of a Unicode string. If the
1089 driver specified by This has a user readable name in the language specified by
1090 Language, then a pointer to the controller name is returned in ControllerName,
1091 and EFI_SUCCESS is returned. If the driver specified by This is not currently
1092 managing the controller specified by ControllerHandle and ChildHandle,
1093 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
1094 support the language specified by Language, then EFI_UNSUPPORTED is returned.
1096 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
1097 EFI_COMPONENT_NAME_PROTOCOL instance.
1099 @param ControllerHandle[in] The handle of a controller that the driver
1100 specified by This is managing. This handle
1101 specifies the controller whose name is to be
1104 @param ChildHandle[in] The handle of the child controller to retrieve
1105 the name of. This is an optional parameter that
1106 may be NULL. It will be NULL for device
1107 drivers. It will also be NULL for a bus drivers
1108 that wish to retrieve the name of the bus
1109 controller. It will not be NULL for a bus
1110 driver that wishes to retrieve the name of a
1113 @param Language[in] A pointer to a Null-terminated ASCII string
1114 array indicating the language. This is the
1115 language of the driver name that the caller is
1116 requesting, and it must match one of the
1117 languages specified in SupportedLanguages. The
1118 number of languages supported by a driver is up
1119 to the driver writer. Language is specified in
1120 RFC 4646 or ISO 639-2 language code format.
1122 @param ControllerName[out] A pointer to the Unicode string to return.
1123 This Unicode string is the name of the
1124 controller specified by ControllerHandle and
1125 ChildHandle in the language specified by
1126 Language from the point of view of the driver
1129 @retval EFI_SUCCESS The Unicode string for the user readable name in
1130 the language specified by Language for the
1131 driver specified by This was returned in
1134 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
1136 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
1139 @retval EFI_INVALID_PARAMETER Language is NULL.
1141 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
1143 @retval EFI_UNSUPPORTED The driver specified by This is not currently
1144 managing the controller specified by
1145 ControllerHandle and ChildHandle.
1147 @retval EFI_UNSUPPORTED The driver specified by This does not support
1148 the language specified by Language.
1153 UdfComponentNameGetControllerName (
1154 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
1155 IN EFI_HANDLE ControllerHandle
,
1156 IN EFI_HANDLE ChildHandle OPTIONAL
,
1158 OUT CHAR16
**ControllerName