mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
Many files:
Make interface to network/block scripts consistent:
- output on stdout is returned to the script caller
- output on stderr is logged at the error level, messages with a '-' prefix
are logged at the debug level and messages with a '*' prefix are logged
at the info level.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
32 lines
545 B
Bash
Executable File
32 lines
545 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Usage: block_loop [bind file|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.
|
|
|
|
case $1 in
|
|
bind)
|
|
for dev in /dev/loop*; do
|
|
if losetup $dev $2; then
|
|
echo $dev
|
|
exit 0
|
|
fi
|
|
done
|
|
exit 1
|
|
;;
|
|
|
|
unbind)
|
|
losetup -d $2
|
|
exit 0
|
|
;;
|
|
|
|
*)
|
|
echo 'Unknown command: ' $1 >&2
|
|
echo 'Valid commands are: bind, unbind' >&2
|
|
exit 1
|
|
esac
|