/lib/partman/commit.d/01unmount_busy is in ubiquity 2.10.16.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #! /bin/sh
# This should largely be unnecessary now that partman-base/init.d/parted
# checks for mounted partitions at startup, but it may still serve as
# insurance against partitions being mounted while the partitioner is
# running.
. /lib/partman/lib/base.sh
db_get ubiquity/partman-skip-unmount
if [ "$RET" = true ]; then
exit 0
fi
if [ -f /etc/mtab ]; then
MTAB=/etc/mtab
else
MTAB=/proc/mounts
fi
busy_partitions=
for dev in $DEVICES/*; do
[ -d "$dev" ] || continue
cd $dev
partitions=
found_mounted=false
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
[ "$fs" != free ] || continue
partitions="$partitions $id,$path"
if [ -f "$id/mountpoint" ]; then
mp="$(cat "$id/mountpoint")"
case $mp in
/media/*)
;;
*)
found_mounted=:
;;
esac
fi
done
close_dialog
if ! $found_mounted; then
open_dialog IS_CHANGED
read_line changed
close_dialog
[ "$changed" = yes ] || continue
fi
for part in $partitions; do
id="${part%,*}"
path="${part#*,}"
open_dialog IS_BUSY "$id"
read_line busy
close_dialog
[ "$busy" = yes ] || continue
busy_partitions="$busy_partitions $path"
done
done
[ "$busy_partitions" ] || exit 0
noninteractive=:
while :; do
failed_mountpoints=
for part in $busy_partitions; do
for mp in $(grep "^$part " "$MTAB" | cut -d' ' -f2); do
# This is impressively horrible, but it's the best way I can
# come up with to unmangle mtab entries in shell.
new_mp=
while [ "$mp" ]; do
case $mp in
\\[0-9][0-9][0-9]*)
octal="$(echo "$mp" | sed 's/^\\\([0-9][0-9][0-9]\).*/\1/')"
new_mp="$new_mp$(printf "\\$octal")"
mp="${mp#\\[0-9][0-9][0-9]}"
;;
\\*)
new_mp="$new_mp\\"
mp="${mp#\\}"
;;
*\\*)
new_mp="$new_mp${mp%%\\*}"
mp="\\${mp#*\\}"
;;
*)
new_mp="$new_mp$mp"
mp=
;;
esac
done
umount "$new_mp" || failed_mountpoints="${failed_mountpoints:+$failed_mountpoints }$new_mp"
done
done
if [ -z "$failed_mountpoints" ]; then
break
fi
db_reset ubiquity/partman-failed-unmount
db_subst ubiquity/partman-failed-unmount MOUNTED "$failed_mountpoints"
db_input critical ubiquity/partman-failed-unmount || $noninteractive
db_go || exit 1
db_get ubiquity/partman-failed-unmount
[ "$RET" = true ] || exit 1
noninteractive='exit 1'
done
exit 0
|