mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-11 21:02:34 +00:00
Merge pull request #1724 from devimc/topic/data/revert1405
data: Revert pull request #1405
This commit is contained in:
commit
9a65c18eca
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017-2019 Intel Corporation
|
# Copyright (c) 2017-2018 Intel Corporation
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -14,7 +14,6 @@ typeset -r script_version="@VERSION@ (commit @COMMIT@)"
|
|||||||
typeset -r unknown="unknown"
|
typeset -r unknown="unknown"
|
||||||
|
|
||||||
typeset -r osbuilder_file="/var/lib/osbuilder/osbuilder.yaml"
|
typeset -r osbuilder_file="/var/lib/osbuilder/osbuilder.yaml"
|
||||||
typeset -r dax_header_size_bytes=$((2 * 1024 * 1024))
|
|
||||||
|
|
||||||
# Maximum number of errors to show for a single system component
|
# Maximum number of errors to show for a single system component
|
||||||
# (such as runtime or proxy).
|
# (such as runtime or proxy).
|
||||||
@ -401,34 +400,19 @@ get_image_details()
|
|||||||
local contents
|
local contents
|
||||||
local expected
|
local expected
|
||||||
|
|
||||||
local found_valid_image=0
|
loop_device=$(loopmount_image "$img")
|
||||||
|
if [ -z "$loop_device" ]; then
|
||||||
# Newer images contain a dax header, but check for both types.
|
echo "$unknown"
|
||||||
for use_dax_offset in true false
|
return
|
||||||
do
|
|
||||||
loop_device=$(loopmount_image "$img" "$use_dax_offset")
|
|
||||||
[ -z "$loop_device" ] && continue
|
|
||||||
|
|
||||||
partitions=$(get_partitions "$loop_device")
|
|
||||||
if [ -z "$partitions" ]; then
|
|
||||||
release_device "$loop_device"
|
|
||||||
continue
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
partitions=$(get_partitions "$loop_device")
|
||||||
count=$(echo "$partitions"|wc -l)
|
count=$(echo "$partitions"|wc -l)
|
||||||
|
|
||||||
expected=1
|
expected=1
|
||||||
|
|
||||||
if [ "$count" -ne "$expected" ]; then
|
if [ "$count" -ne "$expected" ]; then
|
||||||
release_device "$loop_device"
|
release_device "$loop_device"
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
found_valid_image=1
|
|
||||||
break
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$found_valid_image" = 0 ]; then
|
|
||||||
echo "$unknown"
|
echo "$unknown"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -450,8 +434,7 @@ get_image_details()
|
|||||||
unmount_partition "$mountpoint"
|
unmount_partition "$mountpoint"
|
||||||
release_device "$loop_device"
|
release_device "$loop_device"
|
||||||
|
|
||||||
# Supplement the output with details of whether the header was found
|
echo "$contents"
|
||||||
printf -- "%s\ndax-nvdimm-header: \"%s\"\n" "${contents}" "$use_dax_offset"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parameter 1: Path to the initrd file.
|
# Parameter 1: Path to the initrd file.
|
||||||
@ -526,16 +509,10 @@ loopmount_image()
|
|||||||
{
|
{
|
||||||
local img="$1"
|
local img="$1"
|
||||||
[ -n "$img" ] || die "need image file"
|
[ -n "$img" ] || die "need image file"
|
||||||
local use_dax_offset="$2"
|
|
||||||
[ -n "$use_dax_offset" ] || die "need dax offset value"
|
|
||||||
|
|
||||||
local device_path
|
local device_path
|
||||||
|
|
||||||
local offset=0
|
losetup -fP "$img"
|
||||||
|
|
||||||
[ "$use_dax_offset" = true ] && offset="$dax_header_size_bytes"
|
|
||||||
|
|
||||||
losetup -fP -o "$offset" "$img"
|
|
||||||
|
|
||||||
device_path=$(losetup -j "$img" |\
|
device_path=$(losetup -j "$img" |\
|
||||||
cut -d: -f1 |\
|
cut -d: -f1 |\
|
||||||
|
Loading…
Reference in New Issue
Block a user