blob: c0de382f2a5276aa7908513a7d365702cb266a2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
# device-mapper sector sizes are 512b, make sure partitions are the correct
# size when using larger sector sizes and a linear dm table.
# Copyright (C) 2015, 2019 Free Software Foundation, Inc.
# This program 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 3 of the License, or
# (at your option) any later version.
# This program 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.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_root_
require_scsi_debug_module_
grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
skip_ 'this system lacks a new-enough libblkid'
test "x$ENABLE_DEVICE_MAPPER" = xyes \
|| skip_ "no device-mapper support"
# Device maps names - should be random to not conflict with existing ones on
# the system
linear_=plinear-$$test
cleanup_fn_() {
i=0
udevadm settle
while [ $i -lt 10 ] ; do
[ -e "/dev/mapper/${linear_}1" ] && dmsetup remove ${linear_}1
sleep .2
[ -e "/dev/mapper/$linear_" ] && dmsetup remove $linear_
sleep .2
[ -e "/dev/mapper/${linear_}1" ] || [ -e "/dev/mapper/$linear_" ] || i=10
i=$((i + 1))
done
udevadm settle
}
# Create a 500M device
ss=$sector_size_
scsi_debug_setup_ sector_size=$ss dev_size_mb=500 > dev-name ||
skip_ 'failed to create scsi_debug device'
scsi_dev=$(cat dev-name)
# Size of device, in 512b units
scsi_dev_size=$(blockdev --getsz $scsi_dev) || framework_failure
dmsetup create $linear_ --table "0 $scsi_dev_size linear $scsi_dev 0" || framework_failure
dev="/dev/mapper/$linear_"
# Create msdos partition table with a partition from 1MiB to 100MiB
parted -s $dev mklabel msdos mkpart primary ext2 1MiB 101MiB > out 2>&1 || fail=1
compare /dev/null out || fail=1
wait_for_dev_to_appear_ ${dev}1 || fail=1
# The size of the partition should be 100MiB, or 204800 512b sectors
p1_size=$(blockdev --getsz ${dev}1) || framework_failure
[ $p1_size == 204800 ] || fail=1
Exit $fail
|