2
# exercise the resize sub-command; FAT and HFS only
2
# exercise the resize library; FAT and HFS+ only
4
# Copyright (C) 2009-2010 Free Software Foundation, Inc.
4
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
6
6
# This program is free software; you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
if test "$VERBOSE" = yes; then
19
. "${srcdir=.}/init.sh"; path_prepend_ ../parted .
29
23
require_scsi_debug_module_
30
24
require_512_byte_sector_size_
32
cat <<EOF > exp-warning || framework_failure
33
WARNING: you are attempting to use parted to operate on (resize) a file system.
34
parted's file system manipulation code is not as robust as what you'll find in
35
dedicated, file-system-specific packages like e2fsprogs. We recommend
36
you use parted only to manipulate partition tables, whenever possible.
37
Support for performing most operations on most types of file systems
38
will be removed in an upcoming release.
54
39
parted -s $dev mklabel gpt > out 2>&1 || fail=1
56
compare out /dev/null || fail=1
41
compare /dev/null out || fail=1
58
43
# ensure that the disk is large enough
59
44
dev_n_sectors=$(parted -s $dev u s p|sed -n '2s/.* \([0-9]*\)s$/\1/p')
64
49
for fs_type in hfs+ fat32; do
66
51
# create an empty $fs_type partition, cylinder aligned, size > 256 MB
67
parted -s $dev mkpart primary $fs_type $start $default_end > out 2>&1 || fail=1
68
echo "Warning: The resulting partition is not properly aligned for best performance." > exp
69
compare out exp || fail=1
52
parted -a min -s $dev mkpart p1 $start $default_end > out 2>&1 || fail=1
53
compare /dev/null out || fail=1
71
55
# print partition table
72
56
parted -m -s $dev u s p > out 2>&1 || fail=1
74
# FIXME: check expected output
76
# There's a race condition here: on udev-based systems, the partition#1
77
# device, ${dev}1 (i.e., /dev/sde1) is not created immediately, and
78
# without some delay, this mount command would fail. Using a flash card
79
# as $dev, the loop below typically iterates 7-20 times.
81
58
# wait for new partition device to appear
84
test -e "${dev}1" && break; test $i = 90 && break;
86
sleep .01 2>/dev/null || sleep 1
88
test $i = 90 && fail=1
59
wait_for_dev_to_appear_ ${dev}1
91
fat32) mkfs_cmd='mkfs.vfat -F 32';;
92
hfs*) mkfs_cmd='mkfs.hfs';;
62
fat32) mkfs_cmd='mkfs.vfat -F 32'; fsck='fsck.vfat -v';;
63
hfs*) mkfs_cmd='mkfs.hfs'; fsck=fsck.hfs;;
93
64
*) error "internal error: unhandled fs type: $fs_type";;
99
70
# NOTE: shrinking is the only type of resizing that works.
100
71
# resize that file system to be one cylinder (8MiB) smaller
101
parted -s $dev resize 1 $start $new_end > out 2> err || fail=1
72
fs-resize ${dev}1 0 $new_end > out 2>&1 || fail=1
102
73
# expect no output
103
compare out /dev/null || fail=1
104
compare err exp-warning || fail=1
106
# print partition table
107
parted -m -s $dev u s p > out 2>&1 || fail=1
109
# compare against expected output
110
sed -n 3p out > k && mv k out || fail=1
111
printf "1:$start:$new_end:530082s:$fs_type:primary:$ms;\n" > exp || fail=1
112
compare out exp || fail=1
74
compare /dev/null out || fail=1
76
# This is known to segfault with fsck.hfs from
77
# Fedora 16's hfsplus-tools-332.14-12.fc15.x86_64.
78
# You can build a working version from
79
# git://cavan.codon.org.uk/hfsplus-tools.git
81
# Skip the fsck.hfs test unless it understands the -v option.
84
hfs*) $fsck -v || { warn_ skipping $fsck test; skip=1; } ;; esac
86
if test $skip = 0; then
87
$fsck ${dev}1 > out || fail=1
89
# Oops. Currently, fsck.hfs reports this:
90
# Executing fsck_hfs (version 540.1-Linux).
91
# ** Checking non-journaled HFS Plus Volume.
92
# The volume name is untitled
93
# ** Checking extents overflow file.
94
# ** Checking catalog file.
95
# ** Checking multi-linked files.
96
# ** Checking catalog hierarchy.
97
# ** Checking volume bitmap.
98
# Volume bitmap needs minor repair for orphaned blocks
99
# ** Checking volume information.
100
# Invalid volume free block count
101
# (It should be 67189 instead of 65197)
102
# Volume header needs minor repair
104
# FIXME: This means the HFS resizing code is wrong.
106
# FIXME: parse "out" for FS size and verify that it's the new, smaller size
114
109
# Remove the partition explicitly, so that mklabel doesn't evoke a warning.
115
110
parted -s $dev rm 1 || fail=1