xen-vtx-unstable

annotate tools/examples/block-enbd @ 6774:4d899a738d59

merge?
author cl349@firebug.cl.cam.ac.uk
date Tue Sep 13 15:05:49 2005 +0000 (2005-09-13)
parents 219d96d545fc 3b25e1de5efb
children e7c7196fa329 8ca0f98ba8e2
rev   line source
mwilli2@2567 1 #!/bin/sh
mwilli2@2567 2
mwilli2@2567 3 # Usage: block-enbd [bind server ctl_port |unbind node]
mwilli2@2567 4 #
mwilli2@2567 5 # The file argument to the bind command is the file we are to bind to a
cl349@6742 6 # loop device.
mwilli2@2567 7 #
mwilli2@2567 8 # The node argument to unbind is the name of the device node we are to
mwilli2@2567 9 # unbind.
mwilli2@2567 10 #
mwilli2@2567 11 # This assumes you're running a correctly configured server at the other end!
mwilli2@2567 12
cl349@6742 13 set -e
mwilli2@2567 14
cl349@6742 15 case $1 in
cl349@6742 16 bind)
cl349@6742 17 for dev in /dev/nd*; do
cl349@6742 18 if nbd-client $2:$3 $dev; then
cl349@6742 19 major=$(stat -L -c %t "$dev")
cl349@6742 20 minor=$(stat -L -c %T "$dev")
cl349@6742 21 pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
cl349@6742 22 xenstore-write "$XENBUS_PATH"/physical-device $pdev \
cl349@6742 23 "$XENBUS_PATH"/node $dev
cl349@6742 24 exit 0
cl349@6742 25 fi
cl349@6742 26 done
cl349@6742 27 exit 1
cl349@6742 28 ;;
cl349@6742 29 unbind)
cl349@6742 30 nbd-client -d $2
cl349@6742 31 exit 0
cl349@6742 32 ;;
mwilli2@2567 33 esac