xen-vtx-unstable

annotate tools/examples/block-file @ 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_loop [bind file|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
cl349@6742 11 set -e
mwilli2@2567 12
cl349@6742 13 case $1 in
cl349@6742 14 bind)
cl349@6742 15 for dev in /dev/loop*; do
cl349@6742 16 if losetup $dev $2; then
cl349@6742 17 major=$(stat -L -c %t "$dev")
cl349@6742 18 minor=$(stat -L -c %T "$dev")
cl349@6742 19 pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
cl349@6742 20 xenstore-write "$XENBUS_PATH"/physical-device $pdev \
cl349@6742 21 "$XENBUS_PATH"/node $dev
cl349@6742 22 exit 0
cl349@6742 23 fi
cl349@6742 24 done
cl349@6742 25 exit 1
cl349@6742 26 ;;
cl349@6742 27 unbind)
cl349@6742 28 losetup -d $2
cl349@6742 29 exit 0
cl349@6742 30 ;;
mwilli2@2567 31 esac