aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ipq806x
diff options
context:
space:
mode:
authorStefan Lippers-Hollmann <s.l-h@gmx.de>2018-01-18 22:27:08 +0100
committerJohn Crispin <john@phrozen.org>2018-02-13 12:45:00 +0100
commit42fe7b3bbe682fc7902580226986abe10ffee8ea (patch)
treeed13dc294dcbb49a80e6048b1049091f08a71198 /target/linux/ipq806x
parentb36cf0be302b6fc86754be56f478d1d3354c6cfb (diff)
downloadupstream-42fe7b3bbe682fc7902580226986abe10ffee8ea.tar.gz
upstream-42fe7b3bbe682fc7902580226986abe10ffee8ea.tar.bz2
upstream-42fe7b3bbe682fc7902580226986abe10ffee8ea.zip
ipq806x: request the first free loop device dynamically for the nbg6817 sysupgrade
Instead of hardcoding /dev/loop0, it's safer to query for the first free loop device and assign that dynamically. While /dev/loop0 is a reasonable assumption immediately following "losetup --detach-all", detaching the mounted overlay is no longer strictly necessary once dual-boot support has been added for the nbg6817. Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Diffstat (limited to 'target/linux/ipq806x')
-rw-r--r--target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
index dcd66ea2ca..cf2acfcc17 100644
--- a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
+++ b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
@@ -47,23 +47,24 @@ zyxel_do_flash() {
}
# Mount loop for rootfs_data
- losetup -o $offset /dev/loop0 "${rootfs}" || {
+ local loopdev="$(losetup -f)"
+ losetup -o $offset $loopdev $rootfs || {
echo "Failed to mount looped rootfs_data."
sleep 10
reboot -f
}
echo "Format new rootfs_data at position ${offset}."
- mkfs.ext4 -F -L rootfs_data /dev/loop0
+ mkfs.ext4 -F -L rootfs_data $loopdev
mkdir /tmp/new_root
- mount -t ext4 /dev/loop0 /tmp/new_root && {
+ mount -t ext4 $loopdev /tmp/new_root && {
echo "Saving config to rootfs_data at position ${offset}."
cp -v /tmp/sysupgrade.tgz /tmp/new_root/
umount /tmp/new_root
}
# Cleanup
- losetup -d /dev/loop0 >/dev/null 2>&1
+ losetup -d $loopdev >/dev/null 2>&1
sync
umount -a
reboot -f