]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/vhost/readonly/delete_partition_vm.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / test / vhost / readonly / delete_partition_vm.sh
CommitLineData
11fdf7f2
TL
1#!/usr/bin/env bash
2
3set -xe
9f95a23c
TL
4
5testdir=$(readlink -f $(dirname $0))
11fdf7f2
TL
6
7disk_name="vda"
8test_folder_name="readonly_test"
9test_file_name="some_test_file"
10
11function error()
12{
13 echo "==========="
14 echo -e "ERROR: $@"
15 echo "==========="
16 trap - ERR
17 set +e
18 umount "$test_folder_name"
9f95a23c 19 rm -rf "$testdir/$test_folder_name"
11fdf7f2
TL
20 exit 1
21}
22
23trap 'error "In delete_partition_vm.sh, line:" "${LINENO}"' ERR
24
25if [[ ! -d "/sys/block/$disk_name" ]]; then
26 error "No vhost-blk disk found!"
27fi
28
29if (( $(lsblk -r -n -o RO -d "/dev/$disk_name") == 1 )); then
30 error "Vhost-blk disk is set as readonly!"
31fi
32
33mkdir -p $test_folder_name
34
35echo "INFO: Mounting disk"
36mount /dev/$disk_name"1" $test_folder_name
37
38echo "INFO: Removing folder and unmounting $test_folder_name"
39umount "$test_folder_name"
9f95a23c 40rm -rf "$testdir/$test_folder_name"
11fdf7f2
TL
41
42echo "INFO: Deleting partition"
43echo -e "d\n1\nw" | fdisk /dev/$disk_name