Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Embed bios and uefi binaries #395

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

Merged
merged 9 commits into from
Dec 28, 2023
Merged
Prev Previous commit
Next Next commit
Run cargo fmt
  • Loading branch information
mysteriouslyseeing committed Oct 17, 2023
commit 8be25883dbb4ac87707f9af318482a5a2b57c19c
16 changes: 3 additions & 13 deletions 16 src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,8 @@ impl DiskImageBuilder {
let stage_3 = FileDataSource::Data(BIOS_STAGE_3.to_vec());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The to_vec call copies the data to the heap whenever this function is invoked. I think we could avoid this copy by introducing a new FileDataSource::Bytes(&'static [u8]) variant, which could be used with statics and const data.

let stage_4 = FileDataSource::Data(BIOS_STAGE_4.to_vec());
let mut internal_files = BTreeMap::new();
internal_files.insert(
BIOS_STAGE_3_NAME,
stage_3,
);
internal_files.insert(
BIOS_STAGE_4_NAME,
stage_4,
);
internal_files.insert(BIOS_STAGE_3_NAME, stage_3);
internal_files.insert(BIOS_STAGE_4_NAME, stage_4);
let fat_partition = self
.create_fat_filesystem_image(internal_files)
.context("failed to create FAT partition")?;
Expand Down Expand Up @@ -192,10 +186,7 @@ impl DiskImageBuilder {
}

let mut internal_files = BTreeMap::new();
internal_files.insert(
UEFI_BOOT_FILENAME,
get_uefi_bootloader(),
);
internal_files.insert(UEFI_BOOT_FILENAME, get_uefi_bootloader());
let fat_partition = self
.create_fat_filesystem_image(internal_files)
.context("failed to create FAT partition")?;
Expand Down Expand Up @@ -240,7 +231,6 @@ impl DiskImageBuilder {

let to = tftp_path.join(UEFI_TFTP_BOOT_FILENAME);
write_uefi_bootloader(&to)?;


for f in &self.files {
let to = tftp_path.join(f.0.deref());
Expand Down
16 changes: 9 additions & 7 deletions 16 src/mbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ pub fn create_mbr_disk(
boot_partition_path: &Path,
out_mbr_path: &Path,
) -> anyhow::Result<()> {
let second_stage = File::open(second_stage_path).context("failed to open second stage binary")?;
let second_stage =
File::open(second_stage_path).context("failed to open second stage binary")?;
create_mbr_disk_with_readers(
File::open(bootsector_path).context("failed to open boot sector")?,
SecondStageData {
size: second_stage.metadata()
.context("failed to read file metadata of second stage")?
.len(),
reader: second_stage
size: second_stage
.metadata()
.context("failed to read file metadata of second stage")?
.len(),
reader: second_stage,
},
boot_partition_path,
out_mbr_path
out_mbr_path,
)
}

Expand All @@ -44,7 +46,7 @@ pub fn create_mbr_disk(
reader: Cursor::new(second_stage_binary),
},
boot_partition_path,
out_mbr_path
out_mbr_path,
)
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.