2 # Exercise the exclusive, single-bit flags.
4 # Copyright (C) 2010-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
25 perl -nle '/^1:2048s:4095s:2048s::(?:P1)?:(.+);$/ and print $1' "$@"
28 for table_type in msdos gpt; do
30 # Extract flag names of type $table_type from the texinfo documentation.
32 msdos) search_term=MS-DOS; pri_or_name=pri;;
33 gpt) search_term=GPT; pri_or_name=P1;;
35 flags=$(sed -n '/^@node set/,/^@node/p' \
36 "$abs_top_srcdir/doc/parted.texi" \
38 '/^\@item (\w+).*'"$search_term"'/s and print lc($1), "\n"')
41 dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
43 parted -s $dev mklabel $table_type \
44 mkpart $pri_or_name ext2 $((1*2048))s $((2*2048-1))s \
45 > out 2> err || fail=1
46 compare /dev/null out || fail=1
48 for mode in on_only on_and_off ; do
49 for flag in $flags; do
51 # Exclude the supplemental flags.
52 # These are not boolean, like the others.
53 case $flag in boot|lba|hidden) continue;; esac
55 # Turn on each flag, one at a time.
56 parted -m -s $dev set 1 $flag on u s print > raw 2> err || fail=1
57 extract_flags raw > out
59 || { warn_ "$ME: flag not turned on: $(cat out)"; fail=1; }
60 compare /dev/null err || fail=1
62 if test $mode = on_and_off; then
64 parted -m -s $dev set 1 $flag off u s print > raw 2> err || fail=1
65 extract_flags raw > out
67 && { warn_ "$ME: flag not turned off: $(cat out)"; fail=1; }
68 compare /dev/null err || fail=1