2
# Consistency in msdos free space starting sector.
4
# Copyright (C) 2008-2012 Free Software Foundation, Inc.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
22
######################################################################
23
# parted 1.8.8.1 and earlier was inconsistent when calculating the
24
# start sector for free space in msdos type lables. parted was not
25
# consistent in the use of metadata padding for msdos labels.
26
######################################################################
28
N=4096 # number of sectors
30
# create a file to simulate the underlying device
31
dd if=/dev/zero of=$dev bs=${ss}c count=$N 2> /dev/null || fail=1
34
parted -s $dev mklabel msdos > out 2>&1 || fail=1
36
compare /dev/null out || fail=1
38
# Test the output of print free with no partitions.
39
cat <<EOF > exp || fail=1
41
path:${N}s:file:$ss:$ss:msdos::;
42
1:32s:4095s:4064s:free;
45
# create expected output file' 'test $fail = 0'
47
# display output of label without partitions
48
parted -m -s $dev unit s print free > out 2>&1 || fail=1
50
# check for expected output
51
sed "2s/^[^:]*:/path:/" < out > k; mv k out
52
compare exp out || fail=1
54
# Test the output of print free with one partition.
55
cat <<EOF > exp || fail=1
57
path:${N}s:file:$ss:$ss:msdos::;
58
1:32s:2047s:2016s:free;
59
1:2048s:4095s:2048s:::;
62
# create a partition at the end of the label
63
parted -s $dev mkpart primary 2048s 4095s || fail=1
65
# display output of label with partition
66
parted -m -s $dev unit s print free > out 2>&1 || fail=1
68
# check for expected output
69
sed "2s/^[^:]*:/path:/" < out > k; mv k out
70
compare exp out || fail=1