2 # exercise the resize library; FAT and HFS+ only
4 # Copyright (C) 2009-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 .
23 require_scsi_debug_module_
24 require_512_byte_sector_size_
32 # create memory-backed device
33 scsi_debug_setup_ dev_size_mb=550 > dev-name ||
34 skip_test_ 'failed to create scsi_debug device'
39 parted -s $dev mklabel gpt > out 2>&1 || fail=1
41 compare /dev/null out || fail=1
43 # ensure that the disk is large enough
44 dev_n_sectors=$(parted -s $dev u s p|sed -n '2s/.* \([0-9]*\)s$/\1/p')
45 device_sectors_required=$(echo $default_end | sed 's/s$//')
46 # Ensure that $dev is large enough for this test
47 test $device_sectors_required -le $dev_n_sectors || fail=1
49 for fs_type in hfs+ fat32; do
51 # create an empty $fs_type partition, cylinder aligned, size > 256 MB
52 parted -a min -s $dev mkpart p1 $start $default_end > out 2>&1 || fail=1
53 compare /dev/null out || fail=1
55 # print partition table
56 parted -m -s $dev u s p > out 2>&1 || fail=1
58 # wait for new partition device to appear
59 wait_for_dev_to_appear_ ${dev}1
62 fat32) mkfs_cmd='mkfs.vfat -F 32'; fsck='fsck.vfat -v';;
63 hfs*) mkfs_cmd='mkfs.hfs'; fsck=fsck.hfs;;
64 *) error "internal error: unhandled fs type: $fs_type";;
67 # create the file system
68 $mkfs_cmd ${dev}1 || fail=1
70 # NOTE: shrinking is the only type of resizing that works.
71 # resize that file system to be one cylinder (8MiB) smaller
72 fs-resize ${dev}1 0 $new_end > out 2>&1 || 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
109 # Remove the partition explicitly, so that mklabel doesn't evoke a warning.
110 parted -s $dev rm 1 || fail=1
112 # Create a clean partition table for the next iteration.
113 parted -s $dev mklabel gpt > out 2>&1 || fail=1
115 compare /dev/null out || fail=1