From d9d87ed89d53e93fbaf0e3c86e96cf11285dce80 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 13 Jun 2024 20:42:43 +0200 Subject: [slx-dmsetup] Fix braindead mktemp call by removing it --- modules.d/slx-dmsetup/hooks/dmsetup-slx-device | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device index 0888e97c..4c41af4b 100755 --- a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device +++ b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device @@ -241,15 +241,16 @@ ramdisk_fallback() { mkdir -p "$cow_tmpfs" fi if ! mount -t tmpfs cow-tmpfs -o size="$(( read_only_device_sz / 2 + 100 ))k" "$cow_tmpfs"; then - echo "$0: Failed to mount tmpfs in '$cow_tmpfs' of size '$(( read_only_device_sz / 2 + 100 ))KiB'." + echo "$0: Failed to mount tmpfs in '$cow_tmpfs' of size '$(( read_only_device_sz / 2 + 100 ))KiB', trying to use regular /run tmpfs." fi # create sparse file there - local file="$(mktemp -u -p "$cow_tmpfs" dnbd_cow.XXX)" - if ! dd if=/dev/null of="$file" seek="$(( read_only_device_sz ))" bs=512 2> /dev/null; then + local file="$cow_tmpfs/thinpool.meta" + if ! truncate -s "$(( read_only_device_sz * 512 ))" "$file" \ + && ! dd if=/dev/null of="$file" seek="$read_only_device_sz" bs=512 2> /dev/null; then emergency_shell "Failed to allocate CoW file $file." fi - declare -rg writable_device="$(losetup --show --find "$file")" + declare -rg writable_device="$( losetup --show --find "$file" )" local cow_device_candidate="root" while [ -b "/dev/mapper/$cow_device_candidate" ]; do cow_device_candidate="root.$RANDOM" -- cgit v1.2.3-55-g7522