ia64/xen-unstable

view tools/examples/block-common.sh @ 10098:48c0f5489d44

Remove Emacs variables settings from tail of our Linux files.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 18 11:39:03 2006 +0100 (2006-05-18)
parents 895a9ca1b0a6
children bd8647a7b992
line source
1 #
2 # Copyright (c) 2005 XenSource Ltd.
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of version 2.1 of the GNU Lesser General Public
6 # License as published by the Free Software Foundation.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
19 dir=$(dirname "$0")
20 . "$dir/xen-hotplug-common.sh"
22 findCommand "$@"
24 if [ "$command" != "add" ] &&
25 [ "$command" != "remove" ]
26 then
27 log err "Invalid command: $command"
28 exit 1
29 fi
32 XENBUS_PATH="${XENBUS_PATH:?}"
35 ebusy()
36 {
37 xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \
38 "$XENBUS_PATH/hotplug-status" busy
39 log err "$@"
40 exit 1
41 }
44 ##
45 # Print the given device's major and minor numbers, written in hex and
46 # separated by a colon.
47 device_major_minor()
48 {
49 stat -L -c %t:%T "$1"
50 }
53 ##
54 # Write physical-device = MM,mm to the store, where MM and mm are the major
55 # and minor numbers of device respectively.
56 #
57 # @param device The device from which major and minor numbers are read, which
58 # will be written into the store.
59 #
60 write_dev() {
61 local mm
63 mm=$(device_major_minor "$1")
65 if [ -z $mm ]
66 then
67 fatal "Backend device does not exist"
68 fi
70 xenstore_write "$XENBUS_PATH/physical-device" "$mm"
72 success
73 }