1 From 6c4c8464c704b645ddeccce4c4931b8e9d11c3a8 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Fri, 29 Jan 2010 10:58:17 +0100
4 Subject: [PATCH parted 1/7] linux: Fixup phys_sector_size setting
6 1) Use the logical sector size as physical sector size instead of 512
7 when not compiled with libblkid support, this fixes problems
8 with logical sector size > physical sector size.
9 2) blkid_topology_get_physical_sector_size() can return 0 when it could
10 not determine the physical sector size, handle this.
11 * libparted/arch/linux.c (_device_set_sector_size): Fixup
12 phys_sector_size setting.
14 libparted/arch/linux.c | 17 +++++++++++------
15 2 files changed, 14 insertions(+), 6 deletions(-)
17 diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
18 index f3b54f0..4b7b9f5 100644
19 --- a/libparted/arch/linux.c
20 +++ b/libparted/arch/linux.c
21 @@ -654,22 +654,27 @@ _device_set_sector_size (PedDevice* dev)
22 dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
24 dev->sector_size = (long long)sector_size;
25 + dev->phys_sector_size = dev->sector_size;
29 get_blkid_topology(arch_specific);
30 if (!arch_specific->topology) {
31 - ped_exception_throw (
32 - PED_EXCEPTION_WARNING,
34 - _("Could not determine minimum io size for %s: %s.\n"
35 - "Using the default size (%lld)."),
36 - dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
37 + dev->phys_sector_size = 0;
39 dev->phys_sector_size =
40 blkid_topology_get_physical_sector_size(
41 arch_specific->topology);
43 + if (dev->phys_sector_size == 0) {
44 + ped_exception_throw (
45 + PED_EXCEPTION_WARNING,
47 + _("Could not determine physical sector size for %s.\n"
48 + "Using the logical sector size (%lld)."),
49 + dev->path, dev->sector_size);
50 + dev->phys_sector_size = dev->sector_size;
54 #if defined __s390__ || defined __s390x__
58 From 4bb123a121b54d758f87fc6c38d8edab4ddc6d6b Mon Sep 17 00:00:00 2001
59 From: Hans de Goede <hdegoede@redhat.com>
60 Date: Fri, 29 Jan 2010 19:55:10 +0100
61 Subject: [PATCH parted 2/7] libparted: Give device_get_*_alignment sane defaults
63 When the topology info is incomplete or non existent, return something
64 more sensible then NULL (which ends up being interpreted as
65 PedAlignmentAny in most cases). The default minimum alignment aligns to
66 physical sector size, the default optimal alignment is 1 MiB, which is
67 what vista and windows 7 do.
68 * libparted/device.c (device_get_*_alignment): Add default aligments.
70 libparted/device.c | 30 ++++++++++++++++++++++++++----
71 2 files changed, 33 insertions(+), 4 deletions(-)
73 diff --git a/libparted/device.c b/libparted/device.c
74 index dda8d74..0f36a03 100644
75 --- a/libparted/device.c
76 +++ b/libparted/device.c
77 @@ -501,10 +501,16 @@ ped_device_get_optimal_aligned_constraint(const PedDevice *dev)
79 ped_device_get_minimum_alignment(const PedDevice *dev)
81 + PedAlignment *align = NULL;
83 if (ped_architecture->dev_ops->get_minimum_alignment)
84 - return ped_architecture->dev_ops->get_minimum_alignment(dev);
85 + align = ped_architecture->dev_ops->get_minimum_alignment(dev);
88 + align = ped_alignment_new(0,
89 + dev->phys_sector_size / dev->sector_size);
91 - return NULL; /* ped_alignment_none */
96 @@ -521,10 +527,26 @@ ped_device_get_minimum_alignment(const PedDevice *dev)
98 ped_device_get_optimum_alignment(const PedDevice *dev)
100 + PedAlignment *align = NULL;
102 if (ped_architecture->dev_ops->get_optimum_alignment)
103 - return ped_architecture->dev_ops->get_optimum_alignment(dev);
104 + align = ped_architecture->dev_ops->get_optimum_alignment(dev);
106 + /* If the arch specific code could not give as an alignment
107 + return a default value based on the type of device. */
108 + if (align == NULL) {
109 + switch (dev->type) {
110 + case PED_DEVICE_DASD:
111 + align = ped_device_get_minimum_alignment(dev);
114 + /* Align to a grain of 1MiB (like vista / win7) */
115 + align = ped_alignment_new(0,
116 + 1048576 / dev->sector_size);
120 - return NULL; /* ped_alignment_none */
128 From 82f42a9e059a8f5dea46090889914041204ebe36 Mon Sep 17 00:00:00 2001
129 From: Hans de Goede <hdegoede@redhat.com>
130 Date: Fri, 29 Jan 2010 19:59:06 +0100
131 Subject: [PATCH parted 3/7] linux: handle incomplete topology information
133 The topology information returned by libblkid is not always complete
134 (as the kernel does not always have complete information).
135 This patch makes the linux_get_*_alignment() alignment functions handle
136 this. The algorithm used for linux_get_optimum_alignment is:
137 1) Always use the reported aligment offset as offset
138 2a)If optimal io size is present in the topology info use that as grain
139 2b)If optimal io size is not present in topology info and aligment
140 offset is 0 and minimum io size is a power of 2, use the device.c
141 default optimal alignment (grain 1MiB).
142 2c)If not 2a and 2b, use the minimum io size, or if that is not defined
143 the physical sector size as grain (iow the minimum alignment).
144 The algorithm used for linux_get_minimum_alignment is:
145 1) Always use the reported aligment offset as offset
146 2) Use the minimum io size, or if that is not defined the physical
147 sector size as grain.
148 * libparted/arch/linux.c (linux_get_*_alignment): handle incomplete
149 topology information.
151 libparted/arch/linux.c | 25 +++++++++++++++++++++----
152 1 files changed, 21 insertions(+), 4 deletions(-)
154 diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
155 index 4b7b9f5..a083028 100644
156 --- a/libparted/arch/linux.c
157 +++ b/libparted/arch/linux.c
158 @@ -2564,9 +2564,14 @@ PedAlignment*
159 linux_get_minimum_alignment(const PedDevice *dev)
161 blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
165 - if (!tp || blkid_topology_get_minimum_io_size(tp) == 0)
166 - return NULL; /* ped_alignment_none */
167 + if (blkid_topology_get_minimum_io_size(tp) == 0)
168 + return ped_alignment_new(
169 + blkid_topology_get_alignment_offset(tp) /
171 + dev->phys_sector_size / dev->sector_size);
173 return ped_alignment_new(
174 blkid_topology_get_alignment_offset(tp) / dev->sector_size,
175 @@ -2577,9 +2582,21 @@ PedAlignment*
176 linux_get_optimum_alignment(const PedDevice *dev)
178 blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
182 + /* If optimal_io_size is 0 _and_ alignment_offset is 0 _and_
183 + minimum_io_size is a power of 2 then go with the device.c default */
184 + unsigned long minimum_io_size = blkid_topology_get_minimum_io_size(tp);
185 + if (blkid_topology_get_optimal_io_size(tp) == 0 &&
186 + blkid_topology_get_alignment_offset(tp) == 0 &&
187 + (minimum_io_size & (minimum_io_size - 1)) == 0)
190 - if (!tp || blkid_topology_get_optimal_io_size(tp) == 0)
191 - return NULL; /* ped_alignment_none */
192 + /* If optimal_io_size is 0 and we don't meet the other criteria
193 + for using the device.c default, return the minimum alignment. */
194 + if (blkid_topology_get_optimal_io_size(tp) == 0)
195 + return linux_get_minimum_alignment(dev);
197 return ped_alignment_new(
198 blkid_topology_get_alignment_offset(tp) / dev->sector_size,
202 From 4be1b004ad2c576fc093ca5227e22bb78b35f1fd Mon Sep 17 00:00:00 2001
203 From: Hans de Goede <hdegoede@redhat.com>
204 Date: Fri, 29 Jan 2010 23:28:13 +0100
205 Subject: [PATCH parted 4/7] parted: Honor --align option also in mkpartfs, resize and print cmds
207 parted/parted.c (do_mkpartfs,do_print,do_resize): honor --align
209 parted/parted.c | 26 +++++++++++++++++++++++++-
210 1 files changed, 25 insertions(+), 1 deletions(-)
212 diff --git a/parted/parted.c b/parted/parted.c
213 index c4d1779..5ba8bbf 100644
214 --- a/parted/parted.c
215 +++ b/parted/parted.c
216 @@ -949,6 +949,11 @@ do_mkpartfs (PedDevice** dev)
220 + if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
221 + if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
222 + alignment == ALIGNMENT_CYLINDER))
223 + goto error_destroy_disk;
225 if (!ped_disk_type_check_feature (disk->type, PED_DISK_TYPE_EXTENDED)) {
226 part_type = PED_PARTITION_NORMAL;
228 @@ -989,7 +994,14 @@ do_mkpartfs (PedDevice** dev)
230 PED_ASSERT (user_constraint != NULL, return 0);
232 - dev_constraint = ped_device_get_constraint (*dev);
233 + if (alignment == ALIGNMENT_OPTIMAL)
235 + ped_device_get_optimal_aligned_constraint(*dev);
236 + else if (alignment == ALIGNMENT_MINIMAL)
238 + ped_device_get_minimal_aligned_constraint(*dev);
240 + dev_constraint = ped_device_get_constraint(*dev);
241 PED_ASSERT (dev_constraint != NULL, return 0);
243 final_constraint = ped_constraint_intersect (user_constraint,
244 @@ -1353,6 +1365,11 @@ do_print (PedDevice** dev)
248 + if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
249 + if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
250 + alignment == ALIGNMENT_CYLINDER))
251 + goto error_destroy_disk;
253 peek_word = command_line_peek_word ();
255 if (strncmp (peek_word, "devices", 7) == 0) {
256 @@ -1697,6 +1697,7 @@ do_print (PedDevice** dev)
261 ped_disk_destroy (disk);
264 @@ -1862,6 +1881,11 @@ do_resize (PedDevice** dev)
268 + if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
269 + if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
270 + alignment == ALIGNMENT_CYLINDER))
271 + goto error_destroy_disk;
273 if (!command_line_get_partition (_("Partition number?"), disk, &part))
274 goto error_destroy_disk;
275 if (part->type != PED_PARTITION_EXTENDED) {
279 From 950bfc92b1a67c8baa8c7cfab04103bd38a2d24b Mon Sep 17 00:00:00 2001
280 From: Hans de Goede <hdegoede@redhat.com>
281 Date: Fri, 29 Jan 2010 22:51:30 +0100
282 Subject: [PATCH parted 5/7] parted: change warnings when initial constrained mkpart fails
284 In do_mkpart we first try to create a partition using a constraint
285 derived from the user input intersected with the devices alignment
286 needs. And if that fails we try again without any constraint.
288 However the warning given when this happens only takes into account
289 the user not getting what he asked for, while the alignment might be
290 a problem too (or even the only problem). So this patch adds a check
291 to see if the user really did not get what he asked before giving that
292 warning, and adds a new check + warning to see if the created partition
294 *parted/parted.c (do_mkpart,do_mkpartfs): change warnings when initial
295 constrained mkpart fails.
297 parted/parted.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++------
298 1 files changed, 52 insertions(+), 7 deletions(-)
300 diff --git a/parted/parted.c b/parted/parted.c
301 index 5ba8bbf..3ce356f 100644
302 --- a/parted/parted.c
303 +++ b/parted/parted.c
304 @@ -178,6 +178,8 @@ static TimerContext timer_context;
306 static int _print_list ();
307 static void _done (PedDevice* dev);
308 +static bool partition_align_check (PedDisk const *disk,
309 + PedPartition const *part, enum AlignmentType a_type);
312 _timer_handler (PedTimer* timer, void* context)
313 @@ -833,7 +835,12 @@ do_mkpart (PedDevice** dev)
314 bool added_ok = ped_disk_add_partition (disk, part,
316 ped_constraint_destroy (constraint_any);
320 + goto error_remove_part;
322 + if (!ped_geometry_test_sector_inside(range_start, part->geom.start) ||
323 + !ped_geometry_test_sector_inside(range_end, part->geom.end)) {
324 start_usr = ped_unit_format (*dev, start);
325 end_usr = ped_unit_format (*dev, end);
326 start_sol = ped_unit_format (*dev, part->geom.start);
327 @@ -867,8 +874,23 @@ do_mkpart (PedDevice** dev)
328 /* undo partition addition */
329 goto error_remove_part;
332 - goto error_remove_part;
335 + if ((alignment == ALIGNMENT_OPTIMAL &&
336 + !partition_align_check(disk, part, PA_OPTIMUM)) ||
337 + (alignment == ALIGNMENT_MINIMAL &&
338 + !partition_align_check(disk, part, PA_MINIMUM))) {
339 + if (ped_exception_throw(
340 + PED_EXCEPTION_WARNING,
343 + : PED_EXCEPTION_IGNORE_CANCEL),
344 + _("The resulting partition is not properly "
345 + "aligned for best performance.")) ==
346 + PED_EXCEPTION_CANCEL) {
347 + /* undo partition addition */
348 + goto error_remove_part;
352 ped_exception_leave_all();
353 @@ -1018,8 +1040,16 @@ do_mkpartfs (PedDevice** dev)
355 ped_exception_leave_all();
357 - if (ped_disk_add_partition (disk, part,
358 - ped_constraint_any (*dev))) {
359 + PedConstraint *constraint_any = ped_constraint_any (*dev);
360 + bool added_ok = ped_disk_add_partition (disk, part,
362 + ped_constraint_destroy (constraint_any);
365 + goto error_remove_part;
367 + if (!ped_geometry_test_sector_inside(range_start, part->geom.start) ||
368 + !ped_geometry_test_sector_inside(range_end, part->geom.end)) {
369 start_usr = ped_unit_format (*dev, start);
370 end_usr = ped_unit_format (*dev, end);
371 start_sol = ped_unit_format (*dev, part->geom.start);
372 @@ -1048,8 +1078,23 @@ do_mkpartfs (PedDevice** dev)
373 /* undo partition addition */
374 goto error_remove_part;
377 - goto error_remove_part;
380 + if ((alignment == ALIGNMENT_OPTIMAL &&
381 + !partition_align_check(disk, part, PA_OPTIMUM)) ||
382 + (alignment == ALIGNMENT_MINIMAL &&
383 + !partition_align_check(disk, part, PA_MINIMUM))) {
384 + if (ped_exception_throw(
385 + PED_EXCEPTION_WARNING,
388 + : PED_EXCEPTION_IGNORE_CANCEL),
389 + _("The resulting partition is not properly "
390 + "aligned for best performance.")) ==
391 + PED_EXCEPTION_CANCEL) {
392 + /* undo partition addition */
393 + goto error_remove_part;
397 ped_exception_leave_all();
401 From 6c2db872647816b84a5efc8c8995a019d47f89a9 Mon Sep 17 00:00:00 2001
402 From: Hans de Goede <hdegoede@redhat.com>
403 Date: Sat, 30 Jan 2010 17:46:23 +0100
404 Subject: [PATCH parted 6/7] Makefiles: Fix check-other-sector_sizes
406 Atleast on my system check-other-sector_sizes was actually just testing
407 512 bytes sectors 4 times. This fixes this.
408 * Makefile.am: Fix check-other-sector_sizes
411 1 files changed, 1 insertions(+), 1 deletions(-)
413 diff --git a/Makefile.am b/Makefile.am
414 index 0e80967..d5a32ef 100644
417 @@ -1415,7 +1415,7 @@ MAINTAINERCLEANFILES += \
419 .PHONY: ss-1024 ss-2048 ss-4096
420 ss-1024 ss-2048 ss-4096:
421 - PARTED_SECTOR_SIZE=$(ss-,,$@) $(MAKE) check-recursive
422 + PARTED_SECTOR_SIZE=$(subst ss-,,$@) $(MAKE) check-recursive
424 # Run the regression test suite with different settings,
425 # to ensure it works with simulated partition sizes > 512.
429 From 6ba62ce27f84c5c931d021f4be4af0cce011bdbf Mon Sep 17 00:00:00 2001
430 From: Hans de Goede <hdegoede@redhat.com>
431 Date: Fri, 29 Jan 2010 20:30:18 +0100
432 Subject: [PATCH parted 7/7] parted: Change default alignment to optimal
434 parted/parted.c: change --align default value to optimal
435 tests/*.sh: adjust for alignment changes where necessary
437 parted/parted.c | 2 +-
438 tests/t0220-gpt-msftres.sh | 4 ++--
439 tests/t0280-gpt-corrupt.sh | 6 +++---
440 tests/t2100-mkswap.sh | 14 +++++++-------
441 tests/t2200-dos-label-recog.sh | 11 ++++++-----
442 tests/t2300-dos-label-extended-bootcode.sh | 12 ++++++------
443 tests/t3000-resize-fs.sh | 4 ++--
444 tests/t4100-dvh-partition-limits.sh | 4 +++-
445 tests/t4100-msdos-partition-limits.sh | 22 +++++-----------------
446 tests/t4100-msdos-starting-sector.sh | 10 +++++-----
447 tests/t5000-tags.sh | 6 +++---
448 tests/t8000-loop.sh | 1 +
449 tests/t9021-maxima.sh | 3 ++-
450 14 files changed, 49 insertions(+), 53 deletions(-)
452 diff --git a/parted/parted.c b/parted/parted.c
453 index 3ce356f..e35ce6a 100644
454 --- a/parted/parted.c
455 +++ b/parted/parted.c
456 @@ -133,7 +133,7 @@ int pretend_input_tty = 0;
457 int opt_machine_mode = 0;
458 int disk_is_modified = 0;
459 int is_toggle_mode = 0;
460 -int alignment = ALIGNMENT_CYLINDER;
461 +int alignment = ALIGNMENT_OPTIMAL;
463 static const char* number_msg = N_(
464 "NUMBER is the partition number used by Linux. On MS-DOS disk labels, the "
465 diff --git a/tests/t0220-gpt-msftres.sh b/tests/t0220-gpt-msftres.sh
466 index 8ef885f..bbc415b 100755
467 --- a/tests/t0220-gpt-msftres.sh
468 +++ b/tests/t0220-gpt-msftres.sh
469 @@ -35,8 +35,8 @@ NTFS
477 n_types=$(echo "$fs_types"|wc -w)
479 # Create a "disk" with enough room for one partition per FS type,
480 diff --git a/tests/t0280-gpt-corrupt.sh b/tests/t0280-gpt-corrupt.sh
481 index 28c9035..5c48116 100755
482 --- a/tests/t0280-gpt-corrupt.sh
483 +++ b/tests/t0280-gpt-corrupt.sh
484 @@ -43,7 +43,7 @@ poke()
492 dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
493 @@ -62,7 +62,7 @@ printf "BYT;\n$dev:${n_sectors}s:file:$sector_size_:$sector_size_:gpt:;\n" \
494 compare exp out || fail=1
497 -parted -s $dev mkpart sw linux-swap 60s 100s > empty 2>&1 || fail=1
498 +parted -s $dev mkpart sw linux-swap 2048s 4095s > empty 2>&1 || fail=1
499 compare /dev/null empty || fail=1
501 # We're going to change the name of the first partition,
502 @@ -123,7 +123,7 @@ compare exp err || fail=1
503 parted -m -s $dev u s print > out 2>&1 || fail=1
505 # check for expected output
506 -printf "BYT;\nfile\n1:60s:100s:41s::foo:;\n" > exp || fail=1
507 +printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:;\n" > exp || fail=1
508 sed "s/.*gpt:;/file/" out > k && mv k out || fail=1
509 compare exp out || fail=1
511 diff --git a/tests/t2100-mkswap.sh b/tests/t2100-mkswap.sh
512 index 1462e5d..1e4c444 100755
513 --- a/tests/t2100-mkswap.sh
514 +++ b/tests/t2100-mkswap.sh
515 @@ -27,7 +27,7 @@ require_512_byte_sector_size_
516 # table, ensure that the proper file system type (0x82) is used.
517 # Some releases, e.g. parted-1.8.8 would mistakenly use 0x83.
518 ######################################################################
523 test_expect_success \
524 @@ -41,7 +41,7 @@ test_expect_success 'expect no output' 'compare out /dev/null'
526 test_expect_success \
527 'create a partition' \
528 - 'parted -s $dev mkpart primary 0 1 > out 2>&1'
529 + 'parted -s $dev mkpart primary 2048s 4095s > out 2>&1'
530 test_expect_success 'expect no output' 'compare out /dev/null'
532 test_expect_success \
533 @@ -66,7 +66,7 @@ test_expect_success 'expect no output' 'compare out /dev/null'
535 test_expect_success \
536 'create another partition' \
537 - 'parted -s $dev2 mkpart primary 0 1 > out 2>&1'
538 + 'parted -s $dev2 mkpart primary 2048s 4095s > out 2>&1'
539 test_expect_success 'expect no output' 'compare out /dev/null'
541 test_expect_success \
542 @@ -74,13 +74,13 @@ test_expect_success \
543 'parted -s $dev2 mkfs 1 "linux-swap(v1)" > out 2>&1'
544 test_expect_success 'expect no output' 'compare out /dev/null'
546 -# partition starts at offset 16384; swap UUID is 1036 bytes in
547 +# partition starts at offset 1048576; swap UUID is 1036 bytes in
548 test_expect_success \
550 - 'od -t x1 -An -j17420 -N16 $dev > uuid1'
551 + 'od -t x1 -An -j1049612 -N16 $dev > uuid1'
552 test_expect_success \
554 - 'od -t x1 -An -j17420 -N16 $dev2 > uuid2'
555 + 'od -t x1 -An -j1049612 -N16 $dev2 > uuid2'
556 test_expect_failure \
557 'two linux-swap file systems have different UUIDs' \
558 'compare uuid1 uuid2'
559 @@ -92,7 +92,7 @@ test_expect_success 'expect no output' 'compare out /dev/null'
561 test_expect_success \
562 'extract new UUID 2' \
563 - 'od -t x1 -An -j17420 -N16 $dev2 > uuid2-new'
564 + 'od -t x1 -An -j1049612 -N16 $dev2 > uuid2-new'
565 test_expect_success \
566 'check preserves linux-swap UUID' \
567 'compare uuid2 uuid2-new'
568 diff --git a/tests/t2200-dos-label-recog.sh b/tests/t2200-dos-label-recog.sh
569 index 1254226..92e6d42 100755
570 --- a/tests/t2200-dos-label-recog.sh
571 +++ b/tests/t2200-dos-label-recog.sh
572 @@ -25,11 +25,12 @@ test_description='improved MSDOS partition-table recognition'
573 # parted 1.8.8.1.29 and earlier would fail to recognize a DOS
575 ######################################################################
580 test_expect_success \
581 'create a file to simulate the underlying device' \
582 - 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
583 + 'dd if=/dev/null of=$dev bs=$ss seek=$N 2> /dev/null'
585 test_expect_success \
586 'label the test disk' \
587 @@ -39,8 +40,8 @@ test_expect_success 'expect no output' 'compare out /dev/null'
588 test_expect_success \
589 'create two partition' \
591 - parted -s $dev mkpart primary 1s 40s > out 2>&1 &&
592 - parted -s $dev mkpart primary 41s 80s >> out 2>&1
593 + parted -s $dev mkpart primary 2048s 4095s > out 2>&1 &&
594 + parted -s $dev mkpart primary 4096s 8191s >> out 2>&1
597 test_expect_success 'expect no output' 'compare out /dev/null'
598 @@ -54,7 +55,7 @@ test_expect_success \
600 parted -m -s $dev unit s p > out &&
601 tail -2 out > k && mv k out &&
602 - printf "1:1s:40s:40s:::;\n2:41s:80s:40s:::;\n" > exp
603 + printf "1:2048s:4095s:2048s:::;\n2:4096s:8191s:4096s:::;\n" > exp
606 test_expect_success 'expect two partitions' 'compare out exp'
607 diff --git a/tests/t2300-dos-label-extended-bootcode.sh b/tests/t2300-dos-label-extended-bootcode.sh
608 index 6f2b219..73fa45b 100755
609 --- a/tests/t2300-dos-label-extended-bootcode.sh
610 +++ b/tests/t2300-dos-label-extended-bootcode.sh
611 @@ -27,7 +27,7 @@ bootcode_size=446
613 test_expect_success \
614 'Create the test file' \
615 - 'dd if=/dev/zero of=$dev bs=1024c count=100 >/dev/null 2>&1'
616 + 'dd if=/dev/zero of=$dev bs=1M count=4 >/dev/null 2>&1'
618 test_expect_success \
619 'Create msdos label' \
620 @@ -36,23 +36,23 @@ test_expect_success 'Expect no output' 'compare out /dev/null'
622 test_expect_success \
623 'Create extended partition' \
624 - 'parted -s $dev mkpart extended 32s 127s > out 2>&1'
625 + 'parted -s $dev mkpart extended 2048s 8191s > out 2>&1'
626 test_expect_success 'Expect no output' 'compare out /dev/null'
628 test_expect_success \
629 'Create logical partition' \
630 - 'parted -s $dev mkpart logical 64s 127s > out 2>&1'
631 + 'parted -s $dev mkpart logical 4096s 8191s > out 2>&1'
632 test_expect_success 'Expect no output' 'compare out /dev/null'
634 test_expect_success \
635 'Install fake bootcode' \
636 'printf %0${bootcode_size}d 0 > in &&
637 - dd if=in of=$dev bs=1c seek=16384 count=$bootcode_size \
638 + dd if=in of=$dev bs=1c seek=1M count=$bootcode_size \
639 conv=notrunc > /dev/null 2>&1'
641 test_expect_success \
642 'Save fake bootcode for later comparison' \
643 - 'dd if=$dev of=before bs=1 skip=16384 count=$bootcode_size > /dev/null 2>&1'
644 + 'dd if=$dev of=before bs=1 skip=1M count=$bootcode_size > /dev/null 2>&1'
646 test_expect_success \
647 'Do something to the label' \
648 @@ -61,7 +61,7 @@ test_expect_success 'Expect no output' 'compare out /dev/null'
650 test_expect_success \
651 'Extract the bootcode for comparison' \
652 - 'dd if=$dev of=after bs=1 skip=16384 count=$bootcode_size > /dev/null 2>&1'
653 + 'dd if=$dev of=after bs=1 skip=1M count=$bootcode_size > /dev/null 2>&1'
655 test_expect_success \
656 'Expect bootcode has not changed' \
657 diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
658 index 2abc71b..d6af67d 100755
659 --- a/tests/t3000-resize-fs.sh
660 +++ b/tests/t3000-resize-fs.sh
661 @@ -64,8 +64,8 @@ for fs_type in hfs+ fat32; do
663 # create an empty $fs_type partition, cylinder aligned, size > 256 MB
664 parted -s $dev mkpart primary $fs_type $start $default_end > out 2>&1 || fail=1
666 - compare out /dev/null || fail=1
667 + echo "Warning: The resulting partition is not properly aligned for best performance." > exp
668 + compare out exp || fail=1
670 # print partition table
671 parted -m -s $dev u s p > out 2>&1 || fail=1
672 diff --git a/tests/t4100-dvh-partition-limits.sh b/tests/t4100-dvh-partition-limits.sh
673 index 01e3078..17b1530 100755
674 --- a/tests/t4100-dvh-partition-limits.sh
675 +++ b/tests/t4100-dvh-partition-limits.sh
676 @@ -33,11 +33,13 @@ fs=fs_file
680 +# We must use -f otherwise newer mkfs.xfs fail with:
681 +# mkfs.xfs: probe of test.img failed, cannot detect existing filesystem.
682 test_expect_success \
683 'create an XFS file system' \
685 dd if=/dev/zero of=$fs bs=1MB count=2 seek=20 &&
687 + mkfs.xfs -f -q $fs &&
691 diff --git a/tests/t4100-msdos-partition-limits.sh b/tests/t4100-msdos-partition-limits.sh
692 index 0c5b404..b9f168a 100755
693 --- a/tests/t4100-msdos-partition-limits.sh
694 +++ b/tests/t4100-msdos-partition-limits.sh
695 @@ -33,11 +33,13 @@ fs=fs_file
699 +# We must use -f otherwise newer mkfs.xfs fail with:
700 +# mkfs.xfs: probe of test.img failed, cannot detect existing filesystem.
701 test_expect_success \
702 'create an XFS file system' \
704 dd if=/dev/zero of=$fs bs=1MB count=2 seek=20 &&
706 + mkfs.xfs -f -q $fs &&
710 @@ -102,27 +104,13 @@ test_expect_success \
711 'check for new diagnostic' \
712 'bad_part_length 4294967296 > exp && diff -u err exp'
714 -# FIXME: investigate this.
715 -# Unexpectedly to me, both of these failed with this same diagnostic:
717 -# Error: partition length of 4294967296 sectors exceeds the \
718 -# DOS-partition-table-imposed maximum of 2^32-1" > exp &&
720 -# I expected the one below to fail with a length of _4294967297_.
721 -# Debugging, I see that _check_partition *does* detect this,
722 -# but the diagnostic doesn't get displayed because of the wonders
723 -# of parted's exception mechanism.
725 test_expect_failure \
726 "$table_type: a partition length of 2^32+1 sectors provokes failure." \
727 'do_mkpart $n $(echo $n+2^32|bc) > err 2>&1'
729 -# FIXME: odd that we asked for 2^32+1, yet the diagnostic says 2^32
730 -# FIXME: Probably due to constraints.
731 -# FIXME: For now, just accept the current output.
732 test_expect_success \
733 'check for new diagnostic' \
734 - 'bad_part_length 4294967296 > exp && diff -u err exp'
735 + 'bad_part_length 4294967297 > exp && diff -u err exp'
737 # =========================================================
738 # Now consider partition starting sector numbers.
739 @@ -164,7 +152,7 @@ test_expect_failure \
740 'do_mkpart_start_and_len $(echo 2^32+1|bc) 1000 > err 2>&1'
741 test_expect_success \
742 'check for new diagnostic' \
743 - 'bad_start_sector 4294967296 > exp && diff -u err exp'
744 + 'bad_start_sector 4294967297 > exp && diff -u err exp'
748 diff --git a/tests/t4100-msdos-starting-sector.sh b/tests/t4100-msdos-starting-sector.sh
749 index 7761e75..3d0233b 100755
750 --- a/tests/t4100-msdos-starting-sector.sh
751 +++ b/tests/t4100-msdos-starting-sector.sh
752 @@ -27,7 +27,7 @@ ss=$sector_size_
753 # consistent in the use of metadata padding for msdos labels.
754 ######################################################################
756 -N=200 # number of sectors
757 +N=4096 # number of sectors
759 test_expect_success \
760 'create a file to simulate the underlying device' \
761 @@ -43,7 +43,7 @@ fail=0
762 cat <<EOF > exp || fail=1
764 path:${N}s:file:$ss:$ss:msdos:;
765 -1:32s:127s:96s:free;
766 +1:32s:4095s:4064s:free;
769 test_expect_success 'create expected output file' 'test $fail = 0'
770 @@ -62,15 +62,15 @@ fail=0
771 cat <<EOF > exp || fail=1
773 path:${N}s:file:$ss:$ss:msdos:;
776 +1:32s:2047s:2016s:free;
777 +1:2048s:4095s:2048s:::;
780 test_expect_success 'create expected output file' 'test $fail = 0'
782 test_expect_success \
783 'create a partition at the end of the label' \
784 - 'parted -s $dev mkpart primary 51s 199s'
785 + 'parted -s $dev mkpart primary 2048s 4095s'
787 test_expect_success \
788 'display output of label with partition' \
789 diff --git a/tests/t5000-tags.sh b/tests/t5000-tags.sh
790 index d1e9533..9b0a1cc 100755
791 --- a/tests/t5000-tags.sh
792 +++ b/tests/t5000-tags.sh
793 @@ -22,10 +22,10 @@ test_description="test bios_grub flag in gpt labels"
797 -N=300 # number of sectors
798 +N=4200 # number of sectors
804 end_sector=$(expr $start_sector + $part_sectors - 1)
806 test_expect_success \
807 diff --git a/tests/t8000-loop.sh b/tests/t8000-loop.sh
808 index 313e3b8..cba3454 100755
809 --- a/tests/t8000-loop.sh
810 +++ b/tests/t8000-loop.sh
819 diff --git a/tests/t9021-maxima.sh b/tests/t9021-maxima.sh
820 index 999a696..c8316bc 100755
821 --- a/tests/t9021-maxima.sh
822 +++ b/tests/t9021-maxima.sh
831 @@ -33,7 +34,7 @@ export PATH
832 for t in msdos gpt dvh sun mac bsd amiga loop pc98; do
835 - dd if=/dev/zero of=$dev bs=512 count=1 seek=10000 || { fail=1; continue; }
836 + dd if=/dev/zero of=$dev bs=$ss count=1 seek=10000 || { fail=1; continue; }
837 parted -s $dev mklabel $t || { fail=1; continue; }
839 #case $t in pc98) sleep 999d;; esac