summaryrefslogtreecommitdiff
path: root/scripts/common
diff options
context:
space:
mode:
authorVasilis Tsiligiannis <acinonyx@openwrt.gr>2024-01-04 13:05:51 +0200
committerGitHub <noreply@github.com>2024-01-04 11:05:51 +0000
commit1377e903b864673138908165572a18933400e8eb (patch)
treee077246e16eccd9abbeb0bb097b74ee364a7beb2 /scripts/common
parent02b371de1a87bbe70cfcbd498527067a7d2ee6ca (diff)
Ensure loop device partition nodes are created (#741)
Although the loop block device is created before attaching the image to it, the devices for the partition that the image contains are still not created. This patch creates those devices as well, when they are not already available. Fixes #482 Signed-off-by: Vasilis Tsiligiannis <acinonyx@openwrt.gr>
Diffstat (limited to 'scripts/common')
-rw-r--r--scripts/common14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/common b/scripts/common
index 74c7938..cda5551 100644
--- a/scripts/common
+++ b/scripts/common
@@ -110,3 +110,17 @@ ensure_next_loopdev() {
[[ -b "$loopdev" ]] || mknod "$loopdev" b 7 "$loopmaj"
}
export -f ensure_next_loopdev
+
+ensure_loopdev_partitions() {
+ local line
+ local partition
+ local majmin
+ lsblk -r -n -o "NAME,MAJ:MIN" "$1" | grep -v "^${1#/dev/} " | while read -r line; do
+ partition="${line%% *}"
+ majmin="${line#* }"
+ if [ ! -b "/dev/$partition" ]; then
+ mknod "/dev/$partition" b "${majmin%:*}" "${majmin#*:}"
+ fi
+ done
+}
+export -f ensure_loopdev_partitions