3 CRYPTSETUP="../src/cryptsetup"
7 udevadm settle 2>/dev/null 2>&1
8 rmmod scsi_debug 2>/dev/null
14 [ -n "$1" ] && echo "$1"
20 modprobe scsi_debug $@
21 if [ $? -ne 0 ] ; then
22 echo "This kernel seems to not support proper scsi_debug module, test skipped."
27 DEV=$(grep scsi_debug /sys/block/*/device/model | cut -f4 -d /)
29 if [ ! -e /sys/block/$DEV/alignment_offset ] ; then
30 echo "This kernel seems to not support topology info, test skipped."
36 [ -b $DEV ] || fail "Cannot find $DEV."
40 format() # key_bits expected [forced]
43 echo -n "Formatting using topology info ($1 bits key)...."
44 echo xxx| $CRYPTSETUP luksFormat $DEV -q -s $1
46 echo -n "Formatting using forced offset $3 ($1 bits key)..."
47 echo xxx| $CRYPTSETUP luksFormat $DEV -q -s $1 --align-payload=$2
50 ALIGN=$($CRYPTSETUP luksDump $DEV |grep "Payload offset" | sed -e s/.*\\t//)
51 #echo "ALIGN = $ALIGN"
53 if [ $ALIGN -ne $2 ] ; then
55 echo "Expected alignment differs: expected $2 != detected $ALIGN"
61 if [ $(id -u) != 0 ]; then
62 echo "WARNING: You must be root to run this test, test skipped."
66 modprobe --dry-run scsi_debug || exit 0
69 echo "# Create desktop-class 4K drive"
70 echo "# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)"
71 add_device dev_size_mb=16 sector_size=512 physblk_exp=3 num_tgts=1
78 echo "# Create desktop-class 4K drive w/ 63-sector DOS partition compensation"
79 echo "# (logical_block_size=512, physical_block_size=4096, alignment_offset=3584)"
80 add_device dev_size_mb=16 sector_size=512 physblk_exp=3 lowest_aligned=7 num_tgts=1
85 echo "# Create enterprise-class 4K drive"
86 echo "# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0)"
87 add_device dev_size_mb=16 sector_size=4096 num_tgts=1
92 echo "# Create classic 512b drive and stack dm-linear"
93 echo "# (logical_block_size=512, physical_block_size=512, alignment_offset=0)"
94 add_device dev_size_mb=16 sector_size=512 num_tgts=1
96 DEV=/dev/mapper/luks0xbabe
97 dmsetup create luks0xbabe --table "0 32768 linear $DEV2 0"
101 dmsetup remove luks0xbabe