mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-23 19:46:31 +01:00
fix(payload-discovery): mount proc and probe devices from /proc/partitions with magic-based selection
This commit is contained in:
parent
5eac7edb91
commit
17e88a89a8
1 changed files with 15 additions and 8 deletions
|
|
@ -7,21 +7,28 @@ set -ex
|
|||
|
||||
if [ "${PAYLOAD_REQUIRED}" = True ]; then
|
||||
mkdir -p /external/distfiles
|
||||
found_payload=0
|
||||
mkdir -p /proc
|
||||
mount -t proc proc /proc >/dev/null 2>&1 || :
|
||||
|
||||
# Probe all block devices reported by the running kernel instead of
|
||||
# assuming fixed names like /dev/sdb or /dev/hdb.
|
||||
if [ ! -r /proc/partitions ]; then
|
||||
echo "payload-import failed: /proc/partitions is unavailable." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
found_payload=0
|
||||
while read -r major minor blocks name; do
|
||||
case "${name}" in
|
||||
""|name|ram*|loop*|fd*|sr*|md*)
|
||||
""|name|ram*|loop*|fd*|sr*|md*|dm-*|nbd*)
|
||||
continue
|
||||
;;
|
||||
*[0-9])
|
||||
# Skip partitions (sda1, vdb2, ...); payload is attached as a whole disk.
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
dev_path="/dev/${name}"
|
||||
if [ ! -b "${dev_path}" ]; then
|
||||
mknod -m 600 "${dev_path}" b "${major}" "${minor}" || :
|
||||
fi
|
||||
mknod -m 600 "${dev_path}" b "${major}" "${minor}" >/dev/null 2>&1 || :
|
||||
|
||||
if payload-import --probe "${dev_path}"; then
|
||||
payload-import --device "${dev_path}" /external/distfiles
|
||||
|
|
@ -31,7 +38,7 @@ if [ "${PAYLOAD_REQUIRED}" = True ]; then
|
|||
done < /proc/partitions
|
||||
|
||||
if [ "${found_payload}" != 1 ]; then
|
||||
echo "payload-import failed: no payload image found on detected block devices." >&2
|
||||
echo "payload-import failed: no payload image found on probed block devices." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue