*** /etc/rc.d/functions 2012-05-07 11:38:17.563261914 +0200 --- /root/functions_new 2012-05-07 12:23:57.630824788 +0200 *************** *** 414,419 **** --- 414,441 ---- stat_append "creating swapspace.." mkswap -f -L $1 /dev/mapper/$1 >/dev/null fi;; + TMP) + local _overwriteokay=0 + if [[ -b $2 && -r $2 ]]; then + # This is DANGEROUS! If there is any known file system, + # partition table, RAID or LVM volume on the device + # we don't overwrite it. + # + # 'blkid' returns 2 if no valid signature has been found. + # Only in this case we should allow overwriting the device. + # + # This sanity check _should_ be sufficient, but it might not. + # This may cause dataloss if it is not used carefully. + blkid -p "$2" &>/dev/null + (( $? == 2 )) && _overwriteokay=1 + fi + if (( _overwriteokay == 0 )); then + false + elif cryptsetup -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then + stat_append "creating temporary filesystem.." + mkfs.ext4 -L $1 /dev/mapper/$1 >/dev/null + fi;; + ASK) printf "\nOpening '$1' volume:\n" cryptsetup $4 $open "$a" "$b" < /dev/console;;