Skip to content

Commit 40d47c2

Browse files
committed
Added EFI_FILE_PROTOCOL Flush() dummy implementation
The ext4 driver implements EFI_FILE_PROTOCOL_REVISION but was missing the required Flush() function. According to UEFI Specification v2.10, Section 13.5 (File Protocol), all protocol functions must be implemented. Changes: - Adds minimal Flush() function implementation Signed-off-by: Pavel Naberezhnev <[email protected]>
1 parent 3a1e3d4 commit 40d47c2

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

Ext4Pkg/Ext4Dxe/Ext4Dxe.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,28 @@ Ext4WriteFile (
715715
IN VOID *Buffer
716716
);
717717

718+
/**
719+
Flushes all modified data associated with a file to a device
720+
721+
@param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
722+
handle to flush data.
723+
724+
@retval EFI_SUCCESS The data was flushed.
725+
@retval EFI_NO_MEDIA The device has no medium.
726+
@retval EFI_DEVICE_ERROR The device reported an error.
727+
@retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
728+
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
729+
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
730+
@retval EFI_ACCESS_DENIED The file was opened read only.
731+
@retval EFI_VOLUME_FULL The volume is full.
732+
733+
**/
734+
EFI_STATUS
735+
EFIAPI
736+
Ext4Flush (
737+
IN EFI_FILE_PROTOCOL* This
738+
);
739+
718740
/**
719741
Returns a file's current position.
720742

Ext4Pkg/Ext4Dxe/File.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,37 @@ Ext4WriteFile (
558558
return EFI_WRITE_PROTECTED;
559559
}
560560

561+
/**
562+
Flushes all modified data associated with a file to a device
563+
564+
@param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
565+
handle to flush data.
566+
567+
@retval EFI_SUCCESS The data was flushed.
568+
@retval EFI_NO_MEDIA The device has no medium.
569+
@retval EFI_DEVICE_ERROR The device reported an error.
570+
@retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
571+
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
572+
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
573+
@retval EFI_ACCESS_DENIED The file was opened read only.
574+
@retval EFI_VOLUME_FULL The volume is full.
575+
576+
**/
577+
EFI_STATUS
578+
EFIAPI
579+
Ext4Flush (
580+
IN EFI_FILE_PROTOCOL* This
581+
) {
582+
EXT4_FILE *File;
583+
584+
File = EXT4_FILE_FROM_THIS (This);
585+
if (!(File->OpenMode & EFI_FILE_MODE_WRITE)) {
586+
return EFI_ACCESS_DENIED;
587+
}
588+
589+
return EFI_WRITE_PROTECTED;
590+
}
591+
561592
/**
562593
Returns a file's current position.
563594

Ext4Pkg/Ext4Dxe/Partition.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Ext4SetupFile (
8989
File->Protocol.GetPosition = Ext4GetPosition;
9090
File->Protocol.GetInfo = Ext4GetInfo;
9191
File->Protocol.SetInfo = Ext4SetInfo;
92+
File->Protocol.Flush = Ext4Flush;
9293

9394
File->Partition = Partition;
9495
}

0 commit comments

Comments
 (0)