--- cryptdisks.functions.orig 2007-01-31 15:20:53.000000000 +0100 +++ cryptdisks.functions 2007-01-31 15:25:17.000000000 +0100 @@ -3,6 +3,8 @@ DEVMAPCMD=/sbin/dmsetup LOSETUP=/sbin/losetup TABFILE=/etc/crypttab MAPPER=/dev/mapper +# used for creating symlinks to mapper device in $BYDIR/by-{uuid,label} +BYDIR=/dev/disk MOUNT="${CRYPTDISKS_MOUNT}" @@ -350,7 +352,8 @@ do_swap () { if test "x$MAKESWAP" = "xyes" && test -b $MAPPER/$dst; then if swap_out=$(/lib/cryptsetup/checks/un_vol_id $MAPPER/$dst) || \ /lib/cryptsetup/checks/vol_id $MAPPER/$dst swap>/dev/null; then - mkswap $MAPPER/$dst 2>/dev/null >/dev/null + # create swap with label $dst on mapper-device $dst + mkswap -L $dst $MAPPER/$dst 2>/dev/null >/dev/null else echo "$swap_out" >&2 echo "the check for '$MAPPER/$dst' failed. $MAPPER/$dst contains data." >&2 @@ -425,6 +428,13 @@ do_start () { do_swap do_tmp fi + + # create symlinks for supporting LABEL= and UUID= mounts + # do this as late as possible + [ ! -z "$(vol_id -l $MAPPER/$dst)" ] && ln -fs $MAPPER/$dst \ + $BYDIR/by-label/`vol_id -l $MAPPER/$dst` + [ ! -z "$(vol_id -u $MAPPER/$dst)" ] && ln -fs $MAPPER/$dst \ + $BYDIR/by-uuid/`vol_id -u $MAPPER/$dst` done umount_fs @@ -435,6 +445,10 @@ do_stop () { $DEVMAPCMD mknodes log_action_begin_msg "Stopping $INITSTATE crypto disks" egrep -v "^[[:space:]]*(#|$)" $TABFILE | while read dst src key opts; do + # delete symlinks for supporting LABEL= And UUID= mounts + # do this as early as possible + [ -L $BYDIR/by-label/`vol_id -l $MAPPER/$dst` ] && rm $BYDIR/by-label/`vol_id -l $MAPPER/$dst` + [ -L $BYDIR/by-uuid/`vol_id -u $MAPPER/$dst` ] && rm $BYDIR/by-uuid/`vol_id -u $MAPPER/$dst` if test -b $MAPPER/$dst; then if $DEVMAPCMD info $dst | grep -q '^Open count: *0$'; then dev=`$DEVMAPCMD table $dst | sed 's/^.* \([0-9]*:[0-9]*\) .*/\1/'`