Skip to content

Commit

Permalink
Adds call to mknod if loop dev does not exist after call to `losetup …
Browse files Browse the repository at this point in the history
  • Loading branch information
bamartin125 committed Aug 17, 2023
1 parent 01d24ef commit 446f3e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion export-image/prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then

echo "Creating loop device..."
cnt=0
until LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do
until ensure_next_loopdev && LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do
if [ $cnt -lt 5 ]; then
cnt=$((cnt + 1))
echo "Error in losetup. Retrying..."
Expand Down
2 changes: 1 addition & 1 deletion export-noobs/prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm -rf "${NOOBS_DIR}"

echo "Creating loop device..."
cnt=0
until LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do
until ensure_next_loopdev && LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do
if [ $cnt -lt 5 ]; then
cnt=$((cnt + 1))
echo "Error in losetup. Retrying..."
Expand Down
8 changes: 8 additions & 0 deletions scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ update_issue() {
echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue"
}
export -f update_issue

ensure_next_loopdev() {
local loopdev
loopdev="$(losetup -f)"
loopmaj="$(echo "$loopdev" | sed -E 's/.*[^0-9]*?([0-9]+)$/\1/')"
[[ -b "$loopdev" ]] || mknod "$loopdev" b 7 "$loopmaj"
}
export -f ensure_next_loopdev

0 comments on commit 446f3e3

Please sign in to comment.