refactor(firmware): use od to read qcow2 magic bytes
- Replace head-based check with od -tx1 to read first 4 bytes as hex - Compare hex string to 514649fb to detect qcow2 reliably - Avoid null-byte warnings from command substitution; keep same true/false output Fixes #1796 Signed-off-by: Martin Wimpress <martin@wimpress.org>
This commit is contained in:
parent
1534e2cf8e
commit
59f908ea6d
7
quickemu
7
quickemu
|
|
@ -625,8 +625,11 @@ function configure_ram() {
|
|||
|
||||
function is_firmware_qcow2() {
|
||||
# Check for the magic bytes that indicate the firmware is in qcow2 format,
|
||||
# otherwise default to assuming firmware files are in raw format
|
||||
[ "$(head -c 4 "$1")" = "QFI"$'\xfb' ] && echo "true" || echo "false"
|
||||
# otherwise default to assuming firmware files are in raw format.
|
||||
# Use od to read bytes as hex to avoid null byte warnings in command substitution.
|
||||
local magic
|
||||
magic=$(od -An -tx1 -N4 "$1" 2>/dev/null | tr -d ' ')
|
||||
[ "$magic" = "514649fb" ] && echo "true" || echo "false"
|
||||
}
|
||||
|
||||
function configure_bios() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue