3 CRYPTSETUP="../src/cryptsetup"
5 DEV_STACKED="luks0xbabe"
8 udevadm settle >/dev/null 2>&1
9 [ -b /dev/mapper/$DEV_STACKED ] && dmsetup remove $DEV_STACKED >/dev/null 2>&1
10 rmmod scsi_debug 2>/dev/null
16 [ -n "$1" ] && echo "$1"
22 modprobe scsi_debug $@
23 if [ $? -ne 0 ] ; then
24 echo "This kernel seems to not support proper scsi_debug module, test skipped."
29 DEV=$(grep scsi_debug /sys/block/*/device/model | cut -f4 -d /)
31 if [ ! -e /sys/block/$DEV/alignment_offset ] ; then
32 echo "This kernel seems to not support topology info, test skipped."
38 [ -b $DEV ] || fail "Cannot find $DEV."
42 format() # key_bits expected [forced]
45 echo -n "Formatting using topology info ($1 bits key)...."
46 echo xxx| $CRYPTSETUP luksFormat $DEV -q -i1 -c aes-cbc-essiv:sha256 -s $1
48 echo -n "Formatting using forced sector alignment $3 ($1 bits key)..."
49 echo xxx| $CRYPTSETUP luksFormat $DEV -q -i1 -s $1 -c aes-cbc-essiv:sha256 --align-payload=$2
52 ALIGN=$($CRYPTSETUP luksDump $DEV |grep "Payload offset" | sed -e s/.*\\t//)
53 #echo "ALIGN = $ALIGN"
55 if [ -z "$ALIGN" ] ; then
57 elif [ $ALIGN -ne $2 ] ; then
59 fail "Expected alignment differs: expected $2 != detected $ALIGN"
62 # test some operation, just in case
63 echo -e "xxx\naaa" | $CRYPTSETUP luksAddKey $DEV -i1 --key-slot 1
64 if [ $? -ne 0 ] ; then
66 fail "Keyslot add failed."
68 $CRYPTSETUP -q luksKillSlot $DEV 1
69 if [ $? -ne 0 ] ; then
71 fail "Keyslot removal failed."
77 if [ $(id -u) != 0 ]; then
78 echo "WARNING: You must be root to run this test, test skipped."
82 modprobe --dry-run scsi_debug || exit 0
85 echo "# Create desktop-class 4K drive"
86 echo "# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)"
87 add_device dev_size_mb=16 sector_size=512 physblk_exp=3 num_tgts=1
96 echo "# Create desktop-class 4K drive w/ 63-sector DOS partition compensation"
97 echo "# (logical_block_size=512, physical_block_size=4096, alignment_offset=3584)"
98 add_device dev_size_mb=16 sector_size=512 physblk_exp=3 lowest_aligned=7 num_tgts=1
105 echo "# Create enterprise-class 4K drive"
106 echo "# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0)"
107 add_device dev_size_mb=16 sector_size=4096 num_tgts=1
114 echo "# Create classic 512b drive and stack dm-linear"
115 echo "# (logical_block_size=512, physical_block_size=512, alignment_offset=0)"
116 add_device dev_size_mb=16 sector_size=512 num_tgts=1
118 DEV=/dev/mapper/$DEV_STACKED
119 dmsetup create $DEV_STACKED --table "0 32768 linear $DEV2 0"