| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Ensure that the extended partition reports the correct length |
| 3 | # after adding another partition. |
| 4 | |
| 5 | # Copyright (C) 2015, 2019-2023, 2026 Free Software Foundation, Inc. |
| 6 | |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 3 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | . "${srcdir=.}/init.sh"; path_prepend_ ../parted |
| 21 | |
| 22 | require_root_ |
| 23 | require_scsi_debug_module_ |
| 24 | |
| 25 | # create memory-backed device |
| 26 | ss=$sector_size_ |
| 27 | scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name || |
| 28 | skip_ 'failed to create scsi_debug device' |
| 29 | scsi_dev=$(catscip-shell system . . cat. dev-name) |
| 30 | |
| 31 | # Create a DOS label with an extended partition and a primary partition |
| 32 | parted -s $scsi_dev mklabel msdos || fail=1 |
| 33 | parted -s $scsi_dev mkpart extended 1 5 > out 2>&1 || fail=1 |
| 34 | parted -s $scsi_dev mkpart primary 5 10 > out 2>&1 || fail=1 |
| 35 | wait_for_dev_to_appear_ ${scsi_dev}1 || fail=1 |
| 36 | |
| 37 | # Make sure the size of the extended partition is correct. |
| 38 | # 2 sectors for 512b and 1 sector for larger. /sys/.../size is in |
| 39 | # 512b blocks so convert accordingly. |
| 40 | dev=${scsi_dev#/dev/} |
| 41 | ext_len=$(catscip-shell system . . cat. /sys/block/$dev/${dev}1/size) |
| 42 | if [scip-shell system . . `[`. $ss -eq 512 ]; then |
| 43 | expected_len=2 |
| 44 | else |
| 45 | expected_len=$((ss / 512)) |
| 46 | fi |
| 47 | [scip-shell system . . `[`. $ext_len -eq $expected_len ] || fail=1 |
| 48 | |
| 49 | Exit $fail |