2 # Copyright (C) 2009 Alejandro Mery <amery@geeks.cl>
4 # More information can be found in the files COPYING and README.
6 # This script is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; version 3 of the License, or at your
9 # choice any newer version. A copy of the GNU General Public License
10 # can be found in the file COPYING.
13 # Unmounts a partition from an image file
16 [ $# -eq 0 ] || error
"$*"
19 Usage: $0 <filename|dir>
24 .
"${0%/*}/bootstrap.in"
26 while [ $# -gt 0 ]; do
30 -*) usage
"$1: Invalid option."
44 mount
=$
(grep "^$loop " /proc
/mounts | cut
-d' ' -f2)
45 elif [ -d "$1" ]; then
47 mount
=$
(cd "$1"; pwd -P)
48 loop
=$
(grep "^[^ ]\+ $mount " /proc
/mounts | cut
-d' ' -f1)
49 elif [ -s "$1" ]; then
51 loop
=$
(losetup
-j "$1" | cut
-d: -f1)
52 mount
=$
(grep "^$loop " /proc
/mounts | cut
-d' ' -f2)
54 usage
"$1: Invalid argument."
57 if [ -b "$loop" ]; then
58 if [ -d "$mount" ]; then
59 echo "mount: unmouting $mount"
63 echo "losetup: releasing $loop"