Files
xen/tools/examples/block-enbd
T
mwilli2@equilibrium.research e52d6a8915 bitkeeper revision 1.1159.1.191 (41597997cc5ZJzvh6XLLSIhJ9hLEnA)
Initial support for automatic management of non-phy block devices.
2004-09-28 14:47:51 +00:00

34 lines
636 B
Bash

#!/bin/sh
# Usage: block-enbd [bind server ctl_port |unbind node]
#
# The file argument to the bind command is the file we are to bind to a
# loop device. We print the path to the loop device node to stdout.
#
# The node argument to unbind is the name of the device node we are to
# unbind.
#
# This assumes you're running a correctly configured server at the other end!
case $1 in
bind)
for dev in /dev/nd*; do
if nbd-client $2:$3 $dev; then
echo $dev
exit 0
fi
done
exit 1
;;
unbind)
nbd-client -d $2
exit 0
;;
*)
echo 'Unknown command: ' $1
echo 'Valid commands are: bind, unbind'
exit 1
esac