Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Ext4Pkg/Ext4Dxe/Ext4Dxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,27 @@ Ext4WriteFile (
IN VOID *Buffer
);

/**
Flushes all modified data associated with a file to a device

@param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
handle to flush data.

@retval EFI_SUCCESS The data was flushed.
@retval EFI_NO_MEDIA The device has no medium.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
@retval EFI_ACCESS_DENIED The file was opened read only.
@retval EFI_VOLUME_FULL The volume is full.

**/
EFI_STATUS
EFIAPI
Ext4Flush (
IN EFI_FILE_PROTOCOL *This
);

/**
Returns a file's current position.

Expand Down
31 changes: 31 additions & 0 deletions Ext4Pkg/Ext4Dxe/File.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,37 @@ Ext4WriteFile (
return EFI_WRITE_PROTECTED;
}

/**
Flushes all modified data associated with a file to a device

@param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file
handle to flush data.

@retval EFI_SUCCESS The data was flushed.
@retval EFI_NO_MEDIA The device has no medium.
@retval EFI_DEVICE_ERROR The device reported an error.
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
@retval EFI_ACCESS_DENIED The file was opened read only.
@retval EFI_VOLUME_FULL The volume is full.

**/
EFI_STATUS
EFIAPI
Ext4Flush (
IN EFI_FILE_PROTOCOL *This
)
{
EXT4_FILE *File;

File = EXT4_FILE_FROM_THIS (This);
if (!(File->OpenMode & EFI_FILE_MODE_WRITE)) {
return EFI_ACCESS_DENIED;
}

return EFI_WRITE_PROTECTED;
}

/**
Returns a file's current position.

Expand Down
1 change: 1 addition & 0 deletions Ext4Pkg/Ext4Dxe/Partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Ext4SetupFile (
File->Protocol.GetPosition = Ext4GetPosition;
File->Protocol.GetInfo = Ext4GetInfo;
File->Protocol.SetInfo = Ext4SetInfo;
File->Protocol.Flush = Ext4Flush;

File->Partition = Partition;
}
Expand Down
15 changes: 15 additions & 0 deletions Ext4Pkg/Ext4Dxe/Superblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,21 @@ Ext4OpenSuperblock (
// GOOD_OLD_REV
Partition->FeaturesCompat = Partition->FeaturesIncompat = Partition->FeaturesRoCompat = 0;
Partition->InodeSize = EXT4_GOOD_OLD_INODE_SIZE;

//
// We must ensure that Sb->s_feature_incompat is also zero; otherwise,
// we must not mount this file system.
//
if (Sb->s_feature_incompat != 0) {
return EFI_VOLUME_CORRUPTED;
}

//
// Check that Sb->s_inode_size is valid, otherwise the partition is likely corrupted.
//
if (Sb->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
return EFI_VOLUME_CORRUPTED;
}
}

// Now, check for the feature set of the filesystem
Expand Down
4 changes: 2 additions & 2 deletions FatPkg/EnhancedFatDxe/DirectoryManage.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ FatGetDirEntInfo (
Info = Buffer;
Info->Size = ResultSize;
if ((Entry->Attributes & FAT_ATTRIBUTE_DIRECTORY) != 0) {
Cluster = (Entry->FileClusterHigh << 16) | Entry->FileCluster;
Cluster = ((((UINTN) Entry->FileClusterHigh) << 16) | ((UINTN) Entry->FileCluster));
Info->PhysicalSize = FatPhysicalDirSize (Volume, Cluster);
Info->FileSize = Info->PhysicalSize;
} else {
Expand Down Expand Up @@ -1190,7 +1190,7 @@ FatOpenDirEnt (
//
Volume = Parent->Volume;
OFile->FullPathLen = Parent->FullPathLen + 1 + StrLen (DirEnt->FileString);
OFile->FileCluster = ((DirEnt->Entry.FileClusterHigh) << 16) | (DirEnt->Entry.FileCluster);
OFile->FileCluster = (((UINTN) DirEnt->Entry.FileClusterHigh) << 16) | ((UINTN) DirEnt->Entry.FileCluster);
InsertTailList (&Parent->ChildHead, &OFile->ChildLink);
} else {
//
Expand Down
3 changes: 2 additions & 1 deletion FatPkg/EnhancedFatDxe/ReadWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ FatIFileAccess (
}
}

Done:

if (Token != NULL) {
if (!EFI_ERROR (Status)) {
Status = FatQueueTask (IFile, Task);
Expand All @@ -326,7 +328,6 @@ FatIFileAccess (
}
}

Done:
//
// On EFI_SUCCESS case, not calling FatCleanupVolume():
// 1) The Cache flush operation is avoided to enhance
Expand Down
Loading