From c88414b54cc41c92122e28a9d0c2e4821a07df0f Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 12 Dec 2008 21:40:10 +0100 Subject: implementation if iterative, dependency-resolving underlying volume filesystem creater --- src/core/libs/lib-blockdevices-filesystems.sh | 45 +++++++++++++++++++++------ src/core/libs/lib-misc.sh | 15 +++++++++ 2 files changed, 51 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index b2e829f..a5bf073 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -448,17 +448,44 @@ process_filesystems () done - # TODO: phase 3: create all blockdevices and filesystems in the correct order (for each fs, the underlying block/lvm/devicemapper device must be available so dependencies must be resolved. for lvm:first pv's, then vg's, then lv's etc) + # phase 3: create all blockdevices and filesystems in the correct order (for each fs, the underlying block/lvm/devicemapper device must be available so dependencies must be resolved. for lvm:first pv's, then vg's, then lv's etc) + # don't let them mount yet. we take care of all that ourselves in the next phase - while read part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params + done_filesystems= + for i in `seq 1 10` do - if [ -b "$part" -a "$fs_create" = yes ] - then - infofy "Making $fs_type filesystem on $part" disks - # don't ask to mount. we take care of all that ourselves in the next phase - process_filesystem $part $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params - fi - done < $TMP_FILESYSTEMS + open_items=0 + while read part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params + do + fs_string="$part $fs_type $fs_create $fs_mountpoint $fs_mount $fs_opts $fs_label $fs_params" + if [ "$fs_create" = yes ] + then + debug "Checking if I need to process $fs_string..." + if check_is_in "$fs_string" "${done_filesystems[@]}" + then + debug "->Already done" + else + if [ "$part_type" != lvm-pv -a -b "$part" ] + then + debug "->Still need to do it: Making the filesystem on a volume other then lvm PV" + infofy "Making $fs_type filesystem on $part" disks + process_filesystem $part $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_string") + elif [ "$part_type" = lvm-pv ] && pvdisplay ${part/+/} >/dev/null + then + debug "->Still need to do it: Making the filesystem on a volume which is a lvm PV" + infofy "Making $fs_type filesystem on $part" disks + process_filesystem $part $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_string") + else + debug "->Cannot do right now..." + open_items=1 + fi + fi + fi + done < $TMP_FILESYSTEMS + [ $open_items -eq 0 ] && break + done + [ $open_items -eq 1 ] && show_warning "Filesystem/blockdevice processor problem" "Warning: Could not create all needed filesystems. Either the underlying blockdevices didn't became available in 10 iterations, or process_filesystem failed" + # phase 4: mount all filesystems in the vfs in the correct order. (also swapon where appropriate) diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 995307d..d04e850 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -45,3 +45,18 @@ wait_for () kill $(cat $ANSWER) #TODO: this may not work when mode = cli } + +# $1 set (array) haystack +# $2 needle +check_is_in () +{ + [ -z "$2" ] && die_error "check_is_in needs a needle as \$2 and a haystack as \$1!" + + local pattern="$1" element + shift + for element + do + [[ $element = $pattern ]] && return 0 + done + return 1 +} -- cgit v1.2.3-54-g00ecf