summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2008-12-15 17:49:51 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2008-12-15 17:49:51 +0100
commit870f3f1c30418fa010c3bcf0d7118fec6cd9c614 (patch)
tree5ce3e7de2e2181796de1ab8c140bbd782867fc87
parent07beb06fdab44f5422ef9636da849fff18071893 (diff)
prevent duplicate blockdevice entries
-rw-r--r--src/core/libs/lib-ui-interactive.sh20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index f569f6b..32a4689 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -370,19 +370,13 @@ interactive_filesystem ()
NEW_FILESYSTEM="$fs_type;yes;$fs_mountpoint;target;$fs_opts;$fs_label;$fs_params" #TODO: make re-creation yes/no asking available in this UI.
# add new theoretical blockdevice, if relevant
- if [ "$fs_type" = lvm-vg ]
- then
- echo "/dev/mapper/$fs_label $fs_type $fs_label no_fs" >> $TMP_BLOCKDEVICES
- elif [ "$fs_type" = lvm-pv ]
- then
- echo "$part+ $fs_type no_label no_fs" >> $TMP_BLOCKDEVICES
- elif [ "$fs_type" = lvm-lv ]
- then
- echo "/dev/mapper/$part_label-$fs_label $fs_type no_label no_fs" >> $TMP_BLOCKDEVICES
- elif [ "$fs_type" = dm_crypt ]
- then
- echo "/dev/mapper/$fs_label $fs_type no_label no_fs" >> $TMP_BLOCKDEVICES
- fi
+ new_device=
+ [ "$fs_type" = lvm-vg ] && new_device="/dev/mapper/$fs_label $fs_type $fs_label"
+ [ "$fs_type" = lvm-pv ] && new_device="$part+ $fs_type no_label"
+ [ "$fs_type" = lvm-lv ] && new_device="/dev/mapper/$part_label-$fs_label $fs_type no_label"
+ [ "$fs_type" = dm_crypt ] && new_device="/dev/mapper/$fs_label $fs_type no_label"
+ [ -n "$new_device" ] && ! grep -q "^$new_device " $TMP_BLOCKDEVICES && echo "$new_device no_fs" >> $TMP_BLOCKDEVICES
+
# TODO: cascading remove theoretical blockdevice(s), if relevant ( eg if we just changed from vg->ext3, dm_crypt -> fat, or if we changed the label of something, etc)
if [[ $old_fs = lvm-* || $old_fs = dm_crypt ]] && [[ $fs_string != lvm-* && "$fs_string" != dm_crypt ]]