cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

cleanup.sh (762B)


      1#!/bin/bash
      2
      3function print_usage()
      4{
      5    if [ -n "$2" ]; then
      6        echo "Error: $2"
      7        echo
      8    fi
      9    echo "Usage: $1 <scratch dir>"
     10}
     11
     12scratch_dir=$1
     13if [ -z "$scratch_dir" ]; then
     14    print_usage "$0" 'Scratch dir not given' >&2
     15    exit 1
     16fi
     17
     18cd "$scratch_dir/share" || exit 1
     19mps=(mnt*)
     20mp_i=0
     21for mp in "${mps[@]}"; do
     22    mp_i=$((mp_i + 1))
     23    printf "Unmounting %i/%i...\r" "$mp_i" "${#mps[@]}"
     24
     25    sudo umount -R "$mp"
     26    rm -rf "$mp"
     27done
     28echo
     29
     30rm some-file
     31cd ..
     32rmdir share
     33
     34imgs=(fs*.img)
     35img_i=0
     36for img in "${imgs[@]}"; do
     37    img_i=$((img_i + 1))
     38    printf "Detaching and deleting %i/%i...\r" "$img_i" "${#imgs[@]}"
     39
     40    dev=$(losetup -j "$img" | sed -e 's/:.*//')
     41    sudo losetup -d "$dev"
     42    rm -f "$img"
     43done
     44echo
     45
     46echo 'Done.'