| #!/usr/bin/env bash | |
| # This file is part of util-linux. | |
| # | |
| # This file is free software; you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation; either version 2 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # This file is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| # GNU General Public License for more details. | |
| # | |
| # Copyright (C) 2026 Christian Goeschel Ndjomouo <cgoesc2@wgu.edu> | |
| TS_TOPDIR="${0%/*}/../.." | |
| TS_DESC="options" | |
| . "$TS_TOPDIR"/functions.sh | |
| ts_init "$*" | |
| ts_check_test_command "$TS_CMD_BLKZONE" | |
| ts_skip_nonroot | |
| DEV_SIZE_MEBIBYTES="64" | |
| DEV_SECTOR_SIZE=512 | |
| ZONE_SIZE_MEBIBYTES=8 | |
| ZONE_LENGTH_SECTORS=$(( (ZONE_SIZE_MEBIBYTES * 1024**2) / 512 )) | |
| # https://sg.danny.cz/sg/scsi_debug.html#__RefHeading___Toc121_3679520260 | |
| ts_scsi_debug_init dev_size_mb="$DEV_SIZE_MEBIBYTES" \ | |
| sector_size="$DEV_SECTOR_SIZE" \ | |
| ptype=0x14 zone_size_mb="$ZONE_SIZE_MEBIBYTES" \ | |
| zbc=2 | |
| DEV="$TS_DEVICE" | |
| ts_init_subtest "report" | |
| offset=$((2 * ZONE_LENGTH_SECTORS )) | |
| { | |
| "$TS_CMD_BLKZONE" report "$DEV" | |
| echo "---------" | |
| "$TS_CMD_BLKZONE" report --offset $offset "$DEV" | |
| echo "---------" | |
| "$TS_CMD_BLKZONE" report --count 3 --offset $offset "$DEV" | |
| } >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| unset -v offset | |
| ts_finalize_subtest | |
| ts_init_subtest "finish-reset" | |
| offset=$((3 * ZONE_LENGTH_SECTORS )) | |
| { | |
| "$TS_CMD_BLKZONE" finish --count 1 --offset $offset "$DEV" | |
| "$TS_CMD_BLKZONE" report --count 1 --offset $offset "$DEV" | |
| "$TS_CMD_BLKZONE" reset --count 1 --offset $offset "$DEV" | |
| echo "---------" | |
| "$TS_CMD_BLKZONE" report --count 1 --offset $offset "$DEV" | |
| } >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| unset -v offset | |
| ts_finalize_subtest | |
| ts_init_subtest "open-close" | |
| offset=$((2 * ZONE_LENGTH_SECTORS )) | |
| { | |
| "$TS_CMD_BLKZONE" open --count 1 --offset $offset "$DEV" | |
| "$TS_CMD_BLKZONE" report --count 1 --offset $offset "$DEV" | |
| "$TS_CMD_BLKZONE" close --verbose --count 1 --offset $offset "$DEV" | |
| } >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| sed -i -e 's|\(/dev/.*\):\(.*\)|\2|' "$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| unset -v offset | |
| ts_finalize_subtest | |
| ts_init_subtest "capacity" | |
| length=$((3 * ZONE_LENGTH_SECTORS )) | |
| offset=$((2 * ZONE_LENGTH_SECTORS )) | |
| # The capacity sum should be (3 * $ZONE_LENGTH_SECTORS) in hex, i.e. capacity of | |
| # three zones. | |
| "$TS_CMD_BLKZONE" capacity --length $length \ | |
| --offset $offset "$DEV" \ | |
| >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| unset -v offset length | |
| ts_finalize_subtest | |
| ts_finalize |