This file is indexed.

/etc/xen/scripts/block-drbd-probe is in xen-utils-common 4.6.0-1ubuntu4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#! /bin/bash
#
# Copyright (C) 2014 FUJITSU LIMITED
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; If not, see <http://www.gnu.org/licenses/>.
#
# Usage:
#     block-drbd-probe devicename
#
# Return value:
#     0: the device is drbd device
#     1: the device is not drbd device
#     2: unkown error
#     3: the drbd device does not use protocol D
#     4: the drbd device is not ready

set -e

drbd_res=

function get_res_name()
{
    local drbd_dev=$1
    local drbd_dev_list=($(drbdadm sh-dev all))
    local drbd_res_list=($(drbdadm sh-resource all))
    local temp_drbd_dev temp_drbd_res
    local found=0

    for temp_drbd_dev in ${drbd_dev_list[@]}; do
        if [[ "$temp_drbd_dev" == "$drbd_dev" ]]; then
            found=1
            break
        fi
    done

    if [[ $found -eq 0 ]]; then
        return 1
    fi

    for temp_drbd_res in ${drbd_res_list[@]}; do
        temp_drbd_dev=$(drbdadm sh-dev $temp_drbd_res)
        if [[ "$temp_drbd_dev" == "$drbd_dev" ]]; then
            drbd_res="$temp_drbd_res"
            return 0
        fi
    done

    # OOPS
    return 2
}

get_res_name $1
rc=$?
if [[ $rc -ne 0 ]]; then
    exit $rc
fi

# check protocol
drbdsetup $1 show | grep -q "protocol D;"
if [[ $? -ne 0 ]]; then
    exit 3
fi

# check connect status
state=$(drbdadm cstate "$drbd_res")
if [[ "$state" != "Connected" ]]; then
    exit 4
fi

# check role
role=$(drbdadm role "$drbd_res")
if [[ "$role" != "Primary/Secondary" ]]; then
    exit 4
fi

exit 0