Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getEndPos in uefi.protocol.file #21723

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion lib/std/os/uefi/protocol/file.zig
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ pub const File = extern struct {
fn getEndPos(self: *const File) GetSeekPosError!u64 {
// preserve the old file position
var pos: u64 = undefined;
var end_pos: u64 = undefined;
if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError;
// seek to end of file to get position = file size
if (.Success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError;
// get the position
if (.Success != self.getPosition(&end_pos)) return GetSeekPosError.GetSeekPosError;
// restore the old position
if (.Success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError;
// return the file size = position
return pos;
return end_pos;
}

pub fn setPosition(self: *const File, position: u64) Status {
Expand Down