From 95caa66e0b7e55e71aeed2a0a3160e68fd5fe595 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 18 Sep 2020 13:21:07 +0200 Subject: contrib/mount-ext4-ramdisk.sh: clean up in error case Also fix all shellcheck warnings. --- contrib/mount-ext4-ramdisk.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'contrib') diff --git a/contrib/mount-ext4-ramdisk.sh b/contrib/mount-ext4-ramdisk.sh index 66de968..5ff7ef1 100755 --- a/contrib/mount-ext4-ramdisk.sh +++ b/contrib/mount-ext4-ramdisk.sh @@ -8,9 +8,13 @@ fi IMG=$(mktemp /tmp/ext4-ramdisk-XXX.img) -dd if=/dev/zero of=$IMG bs=1M count=1030 -mkfs.ext4 -q $IMG -mkdir -p $MNT -mount $IMG $MNT -chmod 777 $MNT -rm $IMG # unlink the file, it will be deleted once the fs is unmounted +# unlink the file when done, space will be +# reclaimed once the fs is unmounted. Also +# cleans up in the error case. +trap 'rm "$IMG"' EXIT + +dd if=/dev/zero of="$IMG" bs=1M count=1030 status=none +mkfs.ext4 -q "$IMG" +mkdir -p "$MNT" +mount "$IMG" "$MNT" +chmod 777 "$MNT" -- cgit v1.2.3