summaryrefslogtreecommitdiffstats
path: root/src/tools/rbd_nbd/rbd-nbd_quiesce
blob: a62a12b15ae15c7de809e765402c2ce1cc45e085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

echo "$0 $@" >&2

if [ $# -lt 2 ]; then
    echo "usage: $0 <dev> <cmd>" >&2
    exit 1
fi

dev=$1
cmd=$2

export PATH=/usr/sbin:/usr/bin:/sbin:/bin

findmnt -S "${dev}" -fno TARGET |
while read mnt; do
    case "${cmd}" in
        quiesce)
            echo "freezing ${mnt}" >&2
            fsfreeze -f "${mnt}"
            ;;
        unquiesce)
            echo "unfreezing ${mnt}" >&2
            fsfreeze -u "${mnt}"
            ;;
        *)
            echo "unknown command ${cmd}" >&2
            exit 1
            ;;
    esac
done