| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | [scip-shell system . . `[`. -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".." |
| 4 | CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup |
| 5 | DEV="" |
| 6 | DEV_STACKED="luks0xbabe" |
| 7 | DEV_NAME="dummyalign" |
| 8 | HDR="test_luks2_hdr" |
| 9 | MNT_DIR="./mnt_luks" |
| 10 | PWD1="93R4P4pIqAH8" |
| 11 | PWD2="mymJeD8ivEhE" |
| 12 | FAST_PBKDF="--pbkdf pbkdf2 --pbkdf-force-iterations 1000" |
| 13 | |
| 14 | if [scip-shell system . . `[`. -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then |
| 15 | CRYPTSETUP_VALGRIND=$CRYPTSETUP |
| 16 | else |
| 17 | CRYPTSETUP_VALGRIND=../.libs/cryptsetup |
| 18 | CRYPTSETUP_LIB_VALGRIND=../.libs |
| 19 | fi |
| 20 | |
| 21 | cleanupscip-shell shell shell-project 0.0.0 cleanup().() { |
| 22 | udevadm settle >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 23 | if [scip-shell system . . `[`. -d "$MNT_DIR" ] ; then |
| 24 | umountscip-shell system . . umount. -f $MNT_DIR 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 25 | rmdirscip-shell system . . rmdir. $MNT_DIR 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 26 | fi |
| 27 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_STACKED ] && dmsetup remove --retry $DEV_STACKED >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 28 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 29 | # FIXME scsi_debug sometimes in-use here |
| 30 | sleepscip-shell system . . sleep. 1 |
| 31 | rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 32 | sleepscip-shell system . . sleep. 1 |
| 33 | rmscip-shell system . . rm. -f $HDR 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 34 | } |
| 35 | |
| 36 | failscip-shell shell shell-project 0.0.0 fail().() |
| 37 | { |
| 38 | if [scip-shell system . . `[`. -n "$1" ] ; then echoscip-shell system . . echo. "FAIL $1" ; fi |
| 39 | echoscip-shell system . . echo. "FAILED backtrace:" |
| 40 | while caller $frame; do ((frame++)); done |
| 41 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 42 | exit 100 |
| 43 | } |
| 44 | |
| 45 | _sigchldscip-shell shell shell-project 0.0.0 _sigchld().() { local c=$?; [scip-shell system . . `[`. $c -eq 139 ] && failscip-shell shell shell-project 0.0.0 fail(). "Segfault"; [scip-shell system . . `[`. $c -eq 134 ] && failscip-shell shell shell-project 0.0.0 fail(). "Aborted"; } |
| 46 | trap _sigchld CHLD |
| 47 | |
| 48 | skipscip-shell shell shell-project 0.0.0 skip().() |
| 49 | { |
| 50 | echoscip-shell system . . echo. "TEST SKIPPED: $1" |
| 51 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 52 | exit 77 |
| 53 | } |
| 54 | |
| 55 | valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup().() |
| 56 | { |
| 57 | command -v valgrind >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find valgrind." |
| 58 | [scip-shell system . . `[`. ! -f $CRYPTSETUP_VALGRIND ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of cryptsetup executable." |
| 59 | [scip-shell system . . `[`. ! -f valg.sh ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of valg runner script." |
| 60 | if [scip-shell system . . `[`. -z "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then |
| 61 | export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH" |
| 62 | fi |
| 63 | } |
| 64 | |
| 65 | valgrind_runscip-shell shell shell-project 0.0.0 valgrind_run().() |
| 66 | { |
| 67 | INFOSTRING="$(basenamescip-shell system . . basename. ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${CRYPTSETUP_VALGRIND} "$@" |
| 68 | } |
| 69 | |
| 70 | dm_crypt_featuresscip-shell shell shell-project 0.0.0 dm_crypt_features().() |
| 71 | { |
| 72 | VER_STR=$(dmsetup targets | grepscip-shell system . . grep. crypt | cutscip-shell system . . cut. -f2 -dv) |
| 73 | [scip-shell system . . `[`. -z "$VER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse dm-crypt version." |
| 74 | |
| 75 | VER_MAJ=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 1 -d.) |
| 76 | VER_MIN=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 2 -d.) |
| 77 | VER_PTC=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 3 -d.) |
| 78 | |
| 79 | [scip-shell system . . `[`. $VER_MAJ -lt 1 ] && return |
| 80 | [scip-shell system . . `[`. $VER_MAJ -gt 1 ] && { |
| 81 | DM_PERF_CPU=1 |
| 82 | DM_SECTOR_SIZE=1 |
| 83 | return |
| 84 | } |
| 85 | |
| 86 | [scip-shell system . . `[`. $VER_MIN -lt 14 ] && return |
| 87 | DM_PERF_CPU=1 |
| 88 | if [scip-shell system . . `[`. $VER_MIN -ge 17 ]; then |
| 89 | DM_SECTOR_SIZE=1 |
| 90 | fi |
| 91 | } |
| 92 | |
| 93 | add_devicescip-shell shell shell-project 0.0.0 add_device().() { |
| 94 | modprobe scsi_debug $@ delay=0 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 95 | if [scip-shell system . . `[`. $? -ne 0 ] ; then |
| 96 | echoscip-shell system . . echo. "This kernel seems to not support proper scsi_debug module, test skipped." |
| 97 | exit 77 |
| 98 | fi |
| 99 | |
| 100 | sleepscip-shell system . . sleep. 1 |
| 101 | DEV=$(grepscip-shell system . . grep. -l -e scsi_debug /sys/block/*/device/model | cutscip-shell system . . cut. -f4 -d /scip-shell filesystem . . `/`.) |
| 102 | |
| 103 | if [scip-shell system . . `[`. ! -e /sys/block/$DEV/alignment_offset ] ; then |
| 104 | echoscip-shell system . . echo. "This kernel seems to not support topology info, test skipped." |
| 105 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 106 | exit 77 |
| 107 | fi |
| 108 | |
| 109 | DEV="/dev/$DEV" |
| 110 | [scip-shell system . . `[`. -b $DEV ] || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find $DEV." |
| 111 | } |
| 112 | |
| 113 | formatscip-shell shell shell-project 0.0.0 format().() # expected [forced] [encryption_sector_size] |
| 114 | { |
| 115 | local _sec_size=512 |
| 116 | |
| 117 | local _exp=$1 |
| 118 | |
| 119 | if [scip-shell system . . `[`. "${2:0:1}" = "s" ]; then |
| 120 | _sec_size=${2:1} |
| 121 | shift |
| 122 | fi |
| 123 | |
| 124 | testscip-shell system . . test. "${3:0:1}" = "s" && _sec_size=${3:1} |
| 125 | |
| 126 | testscip-shell system . . test. $_sec_size -eq 512 || local _smsg=" (encryption sector size $_sec_size)" |
| 127 | |
| 128 | if [scip-shell system . . `[`. -z "$2" ] ; then |
| 129 | echoscip-shell system . . echo. -n "Formatting using topology info$_smsg..." |
| 130 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q -c aes-cbc-essiv:sha256 --sector-size $_sec_size >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 131 | else |
| 132 | echoscip-shell system . . echo. -n "Formatting using forced sector alignment $2$_smsg..." |
| 133 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q -c aes-cbc-essiv:sha256 --align-payload=$2 --sector-size $_sec_size >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 134 | fi |
| 135 | |
| 136 | # check the device can be activated |
| 137 | if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ] ; then |
| 138 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 139 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 140 | fi |
| 141 | |
| 142 | ALIGN=$($CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -A1 "0: crypt" | grepscip-shell system . . grep. "offset:" | cutscip-shell system . . cut. -d ' ' -f2) |
| 143 | # echo "ALIGN = $ALIGN" |
| 144 | |
| 145 | [scip-shell system . . `[`. -z "$ALIGN" ] && failscip-shell shell shell-project 0.0.0 fail(). |
| 146 | ALIGN=$((ALIGN/512)) |
| 147 | [scip-shell system . . `[`. $ALIGN -ne $_exp ] && failscip-shell shell shell-project 0.0.0 fail(). "Expected alignment differs: expected $_exp != detected $ALIGN" |
| 148 | |
| 149 | # test some operation, just in case |
| 150 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $DEV $FAST_PBKDF --new-key-slot 1 |
| 151 | [scip-shell system . . `[`. $? -ne 0 ] && failscip-shell shell shell-project 0.0.0 fail(). "Keyslot add failed." |
| 152 | |
| 153 | $CRYPTSETUP -q luksKillSlot $DEV 1 |
| 154 | [scip-shell system . . `[`. $? -ne 0 ] && failscip-shell shell shell-project 0.0.0 fail(). "Keyslot removal failed." |
| 155 | |
| 156 | echoscip-shell system . . echo. "PASSED" |
| 157 | } |
| 158 | |
| 159 | format_failscip-shell shell shell-project 0.0.0 format_fail().() # expected [forced] [encryption_sector_size] |
| 160 | { |
| 161 | local _sec_size=512 |
| 162 | |
| 163 | local _exp=$1 |
| 164 | |
| 165 | if [scip-shell system . . `[`. "${2:0:1}" = "s" ]; then |
| 166 | _sec_size=${2:1} |
| 167 | shift |
| 168 | fi |
| 169 | |
| 170 | testscip-shell system . . test. "${3:0:1}" = "s" && _sec_size=${3:1} |
| 171 | |
| 172 | testscip-shell system . . test. $_sec_size -eq 512 || local _smsg=" (encryption sector size $_sec_size)" |
| 173 | |
| 174 | if [scip-shell system . . `[`. -z "$2" ] ; then |
| 175 | echoscip-shell system . . echo. -n "Formatting using topology info$_smsg (must fail)..." |
| 176 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q -c aes-cbc-essiv:sha256 --sector-size $_sec_size >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 177 | else |
| 178 | echoscip-shell system . . echo. -n "Formatting using forced sector alignment $2$_smsg (must fail)..." |
| 179 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q -c aes-cbc-essiv:sha256 --align-payload=$2 --sector-size $_sec_size >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 180 | fi |
| 181 | |
| 182 | echoscip-shell system . . echo. "PASSED" |
| 183 | } |
| 184 | |
| 185 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector().() # expected device header |
| 186 | { |
| 187 | local _exp=$1 |
| 188 | local _dev=$2 |
| 189 | local _hdr=$2 |
| 190 | local _hdrstr="" |
| 191 | local _hdrmsg="" |
| 192 | |
| 193 | if [scip-shell system . . `[`. -n "$3" ]; then |
| 194 | _hdrstr="--header $3" |
| 195 | _hdr=$3 |
| 196 | _hdrmsg=" detached header" |
| 197 | fi |
| 198 | |
| 199 | echoscip-shell system . . echo. -n "Formatting$_hdrmsg using optimal encryption sector size (expecting $_exp)..." |
| 200 | |
| 201 | if [scip-shell system . . `[`. -z "$DM_SECTOR_SIZE" -a $_exp -ne 512 ]; then |
| 202 | echoscip-shell system . . echo. "SKIPPED" |
| 203 | return |
| 204 | fi |
| 205 | |
| 206 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $_hdrstr $_dev -q >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 207 | |
| 208 | # check the device can be activated |
| 209 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $_hdrstr $_dev $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 210 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 211 | |
| 212 | SECTOR=$($CRYPTSETUP luksDump $_hdr | grepscip-shell system . . grep. -A4 "0: crypt" | grepscip-shell system . . grep. "sector:" | cutscip-shell system . . cut. -d ' ' -f2) |
| 213 | |
| 214 | [scip-shell system . . `[`. -z "$SECTOR" ] && failscip-shell shell shell-project 0.0.0 fail(). |
| 215 | [scip-shell system . . `[`. $SECTOR -ne $_exp ] && failscip-shell shell shell-project 0.0.0 fail(). "Expected sector size differs: expected $_exp != detected $SECTOR" |
| 216 | |
| 217 | echoscip-shell system . . echo. "PASSED" |
| 218 | } |
| 219 | |
| 220 | [scip-shell system . . `[`. ! -x "$CRYPTSETUP" ] && skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find $CRYPTSETUP, test skipped." |
| 221 | [scip-shell system . . `[`. -n "$VALG" ] && valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup(). && CRYPTSETUP=valgrind_run |
| 222 | if [scip-shell system . . `[`. $(idscip-shell system . . id. -u) != 0 ]; then |
| 223 | echoscip-shell system . . echo. "WARNING: You must be root to run this test, test skipped." |
| 224 | exit 77 |
| 225 | fi |
| 226 | |
| 227 | dm_crypt_featuresscip-shell shell shell-project 0.0.0 dm_crypt_features(). |
| 228 | modprobe --dry-run scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || skipscip-shell shell shell-project 0.0.0 skip(). "This kernel seems to not support proper scsi_debug module, test skipped." |
| 229 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 230 | if [scip-shell system . . `[`. -d /sys/module/scsi_debugscip-shell filesystem . . `/sys/module/scsi_debug`. ] ; then |
| 231 | echoscip-shell system . . echo. "Cannot use scsi_debug module (in use or compiled-in), test skipped." |
| 232 | exit 77 |
| 233 | fi |
| 234 | |
| 235 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 |
| 236 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 237 | EXPCT=$($CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. "offset: " | cutscip-shell system . . cut. -f 2 -d ' ') |
| 238 | testscip-shell system . . test. "$EXPCT" -gt 512 || failscip-shell shell shell-project 0.0.0 fail(). |
| 239 | EXPCT=$((EXPCT/512)) |
| 240 | echoscip-shell system . . echo. "Default alignment detected: $EXPCT sectors" |
| 241 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 242 | |
| 243 | echoscip-shell system . . echo. "# Create desktop-class 4K drive" |
| 244 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)" |
| 245 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 physblk_exp=3 num_tgts=1 |
| 246 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT |
| 247 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s1024 |
| 248 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s2048 |
| 249 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s4096 |
| 250 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 |
| 251 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s1024 |
| 252 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s2048 |
| 253 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s4096 |
| 254 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 |
| 255 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s1024 |
| 256 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s2048 |
| 257 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s4096 |
| 258 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+1)) $((EXPCT+1)) |
| 259 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s1024 |
| 260 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s2048 |
| 261 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s4096 |
| 262 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT |
| 263 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s1024 |
| 264 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s2048 |
| 265 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s4096 |
| 266 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 267 | |
| 268 | echoscip-shell system . . echo. "# Create desktop-class 4K drive with misaligned opt-io (some bad USB enclosures)" |
| 269 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=4096, alignment_offset=0, opt-io=1025)" |
| 270 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 physblk_exp=3 num_tgts=1 opt_blks=1025 |
| 271 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT |
| 272 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s1024 |
| 273 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s2048 |
| 274 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s4096 |
| 275 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 |
| 276 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s1024 |
| 277 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s2048 |
| 278 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s4096 |
| 279 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 |
| 280 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s1024 |
| 281 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s2048 |
| 282 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s4096 |
| 283 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+1)) $((EXPCT+1)) |
| 284 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s1024 |
| 285 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s2048 |
| 286 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s4096 |
| 287 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT |
| 288 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s1024 |
| 289 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s2048 |
| 290 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s4096 |
| 291 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 292 | |
| 293 | echoscip-shell system . . echo. "# Create drive with misaligned opt-io to page-size (some bad USB enclosures)" |
| 294 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=512, alignment_offset=0, opt-io=33553920)" |
| 295 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 num_tgts=1 opt_blks=65535 |
| 296 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT |
| 297 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s1024 |
| 298 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s2048 |
| 299 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s4096 |
| 300 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 |
| 301 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s1024 |
| 302 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s2048 |
| 303 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s4096 |
| 304 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 |
| 305 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s1024 |
| 306 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s2048 |
| 307 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s4096 |
| 308 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+1)) $((EXPCT+1)) |
| 309 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s1024 |
| 310 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s2048 |
| 311 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s4096 |
| 312 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT |
| 313 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s1024 |
| 314 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s2048 |
| 315 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s4096 |
| 316 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 317 | |
| 318 | echoscip-shell system . . echo. "# Create desktop-class 4K drive w/ 1-sector shift (original bug report)" |
| 319 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=4096, alignment_offset=512)" |
| 320 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 physblk_exp=3 lowest_aligned=1 num_tgts=1 |
| 321 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+1)) |
| 322 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) s1024 |
| 323 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) s2048 |
| 324 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) s4096 |
| 325 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 |
| 326 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s1024 |
| 327 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s2048 |
| 328 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s4096 |
| 329 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 |
| 330 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s1024 |
| 331 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s2048 |
| 332 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s4096 |
| 333 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+1)) $((EXPCT+1)) |
| 334 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s1024 |
| 335 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s2048 |
| 336 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s4096 |
| 337 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT |
| 338 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s1024 |
| 339 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s2048 |
| 340 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s4096 |
| 341 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 342 | |
| 343 | echoscip-shell system . . echo. "# Create desktop-class 4K drive w/ 63-sector DOS partition compensation" |
| 344 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=4096, alignment_offset=3584)" |
| 345 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 physblk_exp=3 lowest_aligned=7 num_tgts=1 |
| 346 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+7)) |
| 347 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+7)) s1024 |
| 348 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+7)) s2048 |
| 349 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+7)) s4096 |
| 350 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 |
| 351 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s1024 |
| 352 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s2048 |
| 353 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s4096 |
| 354 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 |
| 355 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s1024 |
| 356 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s2048 |
| 357 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s4096 |
| 358 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+1)) $((EXPCT+1)) |
| 359 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s1024 |
| 360 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s2048 |
| 361 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s4096 |
| 362 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT |
| 363 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s1024 |
| 364 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s2048 |
| 365 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s4096 |
| 366 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 367 | |
| 368 | echoscip-shell system . . echo. "# Create enterprise-class 4K drive" |
| 369 | echoscip-shell system . . echo. "# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0)" |
| 370 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=4096 num_tgts=1 opt_blks=64 |
| 371 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT |
| 372 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s1024 |
| 373 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s2048 |
| 374 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s4096 |
| 375 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 |
| 376 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s1024 |
| 377 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s2048 |
| 378 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s4096 |
| 379 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 |
| 380 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s1024 |
| 381 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s2048 |
| 382 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s4096 |
| 383 | #FIXME: kernel limits issue? |
| 384 | ##format $((EXPCT+1)) $((EXPCT+1)) |
| 385 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s1024 |
| 386 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s2048 |
| 387 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s4096 |
| 388 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT |
| 389 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s1024 |
| 390 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s2048 |
| 391 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s4096 |
| 392 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 393 | |
| 394 | echoscip-shell system . . echo. "# Create classic 512B drive and stack dm-linear" |
| 395 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=512, alignment_offset=0)" |
| 396 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 num_tgts=1 |
| 397 | DEV2=$DEV |
| 398 | DEV=/dev/mapper/$DEV_STACKED |
| 399 | dmsetup create $DEV_STACKED --table "0 65536 linear $DEV2 0" |
| 400 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT |
| 401 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s1024 |
| 402 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s2048 |
| 403 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT s4096 |
| 404 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 |
| 405 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s1024 |
| 406 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s2048 |
| 407 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 1 s4096 |
| 408 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 |
| 409 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s1024 |
| 410 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s2048 |
| 411 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT 8 s4096 |
| 412 | formatscip-shell shell shell-project 0.0.0 format(). $((EXPCT+1)) $((EXPCT+1)) |
| 413 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s1024 |
| 414 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s2048 |
| 415 | format_failscip-shell shell shell-project 0.0.0 format_fail(). $((EXPCT+1)) $((EXPCT+1)) s4096 |
| 416 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT |
| 417 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s1024 |
| 418 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s2048 |
| 419 | formatscip-shell shell shell-project 0.0.0 format(). $EXPCT $EXPCT s4096 |
| 420 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 421 | |
| 422 | echoscip-shell system . . echo. "# Create enterprise-class 4K drive with fs and LUKS images." |
| 423 | # loop device here presents 512 block but images have 4k block |
| 424 | # cryptsetup should properly use 4k block on direct-io |
| 425 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=4096 physblk_exp=0 num_tgts=1 opt_blks=64 |
| 426 | for file in $(lsscip-shell system . . ls. img_fs_*.img.xz) ; do |
| 427 | echoscip-shell system . . echo. -n "Format using fs image $file. " |
| 428 | xzscip-shell system . . xz. -d -c $file | ddscip-shell system . . dd. of=$DEV bs=1M 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "bad image" |
| 429 | [scip-shell system . . `[`. ! -d $MNT_DIR ] && mkdirscip-shell system . . mkdir. $MNT_DIR |
| 430 | mountscip-shell system . . mount. $DEV $MNT_DIR 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 431 | if [scip-shell system . . `[`. $? -ne 0 ] ; then |
| 432 | echoscip-shell system . . echo. "[N/A]" |
| 433 | continue |
| 434 | fi |
| 435 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $MNT_DIR/luks.img --offset 8192 || failscip-shell shell shell-project 0.0.0 fail(). |
| 436 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $MNT_DIR/luks.img --header $MNT_DIR/luks_header.img || failscip-shell shell shell-project 0.0.0 fail(). |
| 437 | umountscip-shell system . . umount. $MNT_DIR || failscip-shell shell shell-project 0.0.0 fail(). |
| 438 | echoscip-shell system . . echo. "[OK]" |
| 439 | done |
| 440 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 441 | |
| 442 | echoscip-shell system . . echo. "# Create classic 512B drive" |
| 443 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=512, alignment_offset=0)" |
| 444 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 num_tgts=1 |
| 445 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 512 $DEV |
| 446 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 512 $DEV $HDR |
| 447 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 448 | echoscip-shell system . . echo. "# Create desktop-class 4K drive" |
| 449 | echoscip-shell system . . echo. "# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)" |
| 450 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=512 physblk_exp=3 num_tgts=1 |
| 451 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 4096 $DEV |
| 452 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 4096 $DEV $HDR |
| 453 | DEV2=$DEV |
| 454 | DEV=/dev/mapper/$DEV_STACKED |
| 455 | dmsetup create $DEV_STACKED --table "0 $((`blockdevscip-shell system . . blockdev. --getsz $DEV2`-1)) linear $DEV2 0" |
| 456 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 512 $DEV |
| 457 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 512 $DEV $HDR |
| 458 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 459 | echoscip-shell system . . echo. "# Create enterprise-class 4K drive" |
| 460 | echoscip-shell system . . echo. "# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0)" |
| 461 | add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=32 sector_size=4096 num_tgts=1 opt_blks=64 |
| 462 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 4096 $DEV |
| 463 | auto_sectorscip-shell shell shell-project 0.0.0 auto_sector(). 4096 $DEV $HDR |
| 464 | cleanupscip-shell shell shell-project 0.0.0 cleanup(). |
| 465 | |
| 466 | exit 0 |