mirror of
https://github.com/linuxboot/linuxboot
synced 2024-11-21 23:59:59 +00:00
Change FV creation to take a list of files instead of using fv_append()
This commit is contained in:
parent
764b3bfc22
commit
503688a835
@ -55,37 +55,32 @@ GetOptions(
|
||||
#my $guid = EFI::guid($guid_str)
|
||||
# or die "$guid_str: Unable to parse GUID\n";
|
||||
|
||||
my $fv = EFI::fv($compress_size || $size);
|
||||
|
||||
# Read entire files at a time and append a new file
|
||||
# for each input read.
|
||||
local $/ = undef;
|
||||
my @ffs;
|
||||
my $length_sum = 0;
|
||||
|
||||
while(<>)
|
||||
{
|
||||
my $offset = EFI::fv_append(\$fv, $_)
|
||||
or die "$ARGV: Unable to append\n";
|
||||
push @ffs, $_;
|
||||
$length_sum += length $_;
|
||||
|
||||
warn sprintf "%s: 0x%x bytes offset %x\n",
|
||||
warn sprintf "%s: 0x%x bytes\n",
|
||||
$ARGV,
|
||||
length $_,
|
||||
$offset
|
||||
if $verbose > 1;
|
||||
}
|
||||
|
||||
warn sprintf "%s: 0x%08x out of %08x bytes in FV%s\n",
|
||||
$output,
|
||||
length($fv),
|
||||
$length_sum,
|
||||
$compress_size || $size,
|
||||
$compress_size ? " (uncompressed)" : "",
|
||||
if $verbose > 0;
|
||||
|
||||
EFI::fv_pad(\$fv)
|
||||
or die sprintf "%s: data size 0x%x > volume size 0x%x\n",
|
||||
$output,
|
||||
length $fv,
|
||||
$compress_size || $size
|
||||
;
|
||||
my $fv = EFI::fv($compress_size || $size, @ffs)
|
||||
or die "$output: Unable to create FV\n";
|
||||
|
||||
if ($compress_size)
|
||||
{
|
||||
@ -98,14 +93,7 @@ if ($compress_size)
|
||||
$size,
|
||||
if $verbose > 0;
|
||||
|
||||
my $outer_fv = EFI::fv($size);
|
||||
EFI::fv_append(\$outer_fv, $ffs_lz)
|
||||
or die sprintf "%s: Unable to append 0x%08x compressed bytes\n",
|
||||
$output,
|
||||
length($ffs_lz),
|
||||
;
|
||||
|
||||
EFI::fv_pad(\$outer_fv)
|
||||
my $outer_fv = EFI::fv($size, $ffs_lz)
|
||||
or die sprintf "%s: Unable to append 0x%08x compressed bytes\n",
|
||||
$output,
|
||||
length($ffs_lz),
|
||||
|
20
lib/EFI.pm
20
lib/EFI.pm
@ -386,7 +386,7 @@ sub compress
|
||||
}
|
||||
|
||||
|
||||
# Create a FV header for a given file size
|
||||
# Create a FV for a given file size with the included files
|
||||
sub fv
|
||||
{
|
||||
my $size = shift;
|
||||
@ -423,10 +423,24 @@ sub fv
|
||||
|
||||
substr($fv_hdr, 0x32, 2) = pack("v", $sum & 0xFFFF);
|
||||
|
||||
return $fv_hdr;
|
||||
for my $ffs (@_)
|
||||
{
|
||||
next if fv_append(\$fv_hdr, $ffs);
|
||||
|
||||
warn "FV append failed\n";
|
||||
return;
|
||||
}
|
||||
|
||||
return $fv_hdr if fv_pad(\$fv_hdr);
|
||||
|
||||
warn "FV pad failed\n";
|
||||
return;
|
||||
}
|
||||
|
||||
# Add files to an existing FV
|
||||
|
||||
# Append a file to an FV, adding an initial pad if necessary
|
||||
# This is used internally by EFI::fv() and should not need to be called
|
||||
# by users of the EFI library.
|
||||
sub fv_append
|
||||
{
|
||||
my $fv_ref = shift;
|
||||
|
Loading…
Reference in New Issue
Block a user