/etc/xen/scripts/block-common.sh is in xen-utils-common 4.1.4-3+deb7u9.
This file is owned by root:root, with mode 0o644.
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #
# Copyright (c) 2005 XenSource Ltd.
#
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
dir=$(dirname "$0")
. "$dir/xen-hotplug-common.sh"
findCommand "$@"
if [ "$command" != "add" ] &&
[ "$command" != "remove" ]
then
log err "Invalid command: $command"
exit 1
fi
XENBUS_PATH="${XENBUS_PATH:?}"
ebusy()
{
xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \
"$XENBUS_PATH/hotplug-status" busy
log err "$@"
exit 1
}
##
# Print the given device's major and minor numbers, written in hex and
# separated by a colon.
device_major_minor()
{
stat -L -c %t:%T "$1"
}
##
# Write physical-device = MM,mm to the store, where MM and mm are the major
# and minor numbers of device respectively.
#
# @param device The device from which major and minor numbers are read, which
# will be written into the store.
#
write_dev() {
local mm
mm=$(device_major_minor "$1")
if [ -z $mm ]
then
fatal "Backend device does not exist"
fi
xenstore_write "$XENBUS_PATH/physical-device" "$mm"
success
}
##
# canonicalise_mode mode
#
# Takes the given mode, which may be r, w, ro, rw, w!, or rw!, or variations
# thereof, and canonicalises them to one of
#
# 'r': perform checks for a new read-only mount;
# 'w': perform checks for a read-write mount; or
# '!': perform no checks at all.
#
canonicalise_mode()
{
local mode="$1"
if ! expr index "$mode" 'w' >/dev/null
then
echo 'r'
elif ! expr index "$mode" '!' >/dev/null
then
echo 'w'
else
echo '!'
fi
}
same_vm()
{
local otherdom="$1"
# Note that othervm can be MISSING here, because Xend will be racing with
# the hotplug scripts -- the entries in /local/domain can be removed by
# Xend before the hotplug scripts have removed the entry in
# /local/domain/0/backend/. In this case, we want to pretend that the
# VM is the same as FRONTEND_UUID, because that way the 'sharing' will be
# allowed.
local othervm=$(xenstore_read_default "/local/domain/$otherdom/vm" \
"$FRONTEND_UUID")
local target=$(xenstore_read_default "/local/domain/$FRONTEND_ID/target" \
"-1")
local otarget=$(xenstore_read_default "/local/domain/$otherdom/target" \
"-1")
local otvm=$(xenstore_read_default "/local/domain/$otarget/vm" \
"-1")
otvm=${otvm%-1}
othervm=${othervm%-1}
local frontend_uuid=${FRONTEND_UUID%-1}
[ "$frontend_uuid" = "$othervm" -o "$target" = "$otherdom" -o "$frontend_uuid" = "$otvm" ]
}
|