1 diff --git a/configure.ac b/configure.ac
2 index f1284a0..9f0971b 100644
6 dnl This file may be modified and/or distributed without restriction.
9 -AC_INIT([GNU parted],[1.8.8],[bug-parted@gnu.org])
10 +AC_INIT([GNU parted],[1.8.9],[bug-parted@gnu.org])
12 AC_CONFIG_SRCDIR(include/parted/parted.h)
14 @@ -24,7 +24,7 @@ dnl function signatures changed),
15 dnl set PED_BINARY_AGE _and_ PED_INTERFACE_AGE to 0.
23 @@ -471,14 +471,7 @@ AC_CHECK_HEADER([execinfo.h], [
27 -dnl Checks for #defines.
30 - #if defined __s390__ || defined __s390x__
31 - # message s390 defined
33 - ]])], [compile_for_s390="no"], [compile_for_s390="yes"])
34 -AM_CONDITIONAL([COMPILE_FOR_S390], [test "$compile_for_s390" = "yes"])
35 +AM_CONDITIONAL([COMPILE_FOR_S390], [test "$host_cpu" = s390 || test "$host_cpu" = s390x])
37 dnl check for "check", unit testing library/header
38 PKG_CHECK_MODULES([CHECK], [check >= 0.9.3], have_check=yes, have_check=no)
39 diff --git a/doc/C/parted.8 b/doc/C/parted.8
40 index 7040402..fdf3d04 100644
43 @@ -124,6 +124,18 @@ and a human-friendly form for output).
45 Display version information and a copyright message.
48 +ext3 filesystem resizing does not currently work, please use
52 +Resizing partitions with an ext3 filesystem will not generally work because
53 +of the above issue. Use
55 +to resize the filesystem and resize the partition manually using
57 +or a similar tool. For LVM situations, you will need to use the LVM commands
58 +to resize the LVM elements.
60 Report bugs to <bug-parted@gnu.org>
62 diff --git a/doc/parted.texi b/doc/parted.texi
63 index 139ea77..86ec076 100644
66 @@ -14,7 +14,7 @@ resizing, checking and copy partitions and file systems on them.
67 @ifnottex @c texi2pdf don't understand copying and insertcopying ???
68 @c modifications must also be done in the titlepage
70 -Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
71 +Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
72 Free Software Foundation, Inc.
74 Permission is granted to copy, distribute and/or modify this document
75 @@ -63,7 +63,7 @@ Free Documentation License''.
77 @c WTF doesn't texi2html include the titlepage?
83 This document describes the use of GNU Parted, a program for creating,
84 @@ -257,7 +257,7 @@ $ @kbd{make}
85 However, there are a few options for @command{configure}:
88 -@item --without-readline
89 +@item --without-readline
90 turns off use of readline. This is useful for making rescue disks,
91 etc., where few libraries are available.
93 @@ -275,12 +275,12 @@ you don't need the flexibility.
95 disable all file system support
99 turns off native language support. This is useful for use with old
100 versions of glibc, or a trimmed down version of glibc suitable for
103 -@item --disable-shared
104 +@item --disable-shared
105 turns off shared libraries. This may be necessary for use with old
106 versions of GNU libc, if you get a compile error about a ``spilled
107 register''. Also useful for boot/rescue disks.
108 @@ -301,7 +301,7 @@ disable writing (for debugging)
110 @node Static binaries
111 @section Using static binaries of GNU Parted
112 -@cindex static binary
113 +@cindex static binary
114 @cindex unsupported platforms
115 @cindex resizing root device
117 @@ -320,7 +320,7 @@ of the latest GNU Parted version is available, which you can use thus:
119 @subsection Creating the Parted disk
121 -@item Boot your system
122 +@item Boot your system
124 @item Download @file{parted-static-VERSION.tgz} from @uref{ftp://ftp.gnu.org/gnu/parted/static}
125 @item Unpack the tarball, resulting in a file called ``parted.static".
126 @@ -329,7 +329,7 @@ of the latest GNU Parted version is available, which you can use thus:
128 @item Do a low-level format on it (on GNU/Linux this can be achieved with
129 the tool ``fdformat" from the ``util-linux" package.
130 - This is basically a sanity check because floppy disks often
131 + This is basically a sanity check because floppy disks often
134 @item Create a file system. Example:
135 @@ -359,7 +359,7 @@ $ @kbd{umount /mnt/floppy}
137 @subsection Using the Parted disk
139 -@item Choose a rescue disk that suits you.
140 +@item Choose a rescue disk that suits you.
142 @item Boot off your rescue disk. Mount the disk you copied Parted onto.
144 @@ -383,7 +383,7 @@ $ @kbd{umount /mnt/floppy}
148 -@section Introduction to Partitioning
149 +@section Introduction to Partitioning
150 @cindex partitioning overview
152 Unfortunately, partitioning your disk is rather complicated. This is
153 @@ -566,7 +566,7 @@ Supported file systems:
154 (provided the destination partition is larger than the source partition)
159 (equivalent to mkswap on destination partition)
160 @item reiserfs (if libreiserfs is installed)
162 @@ -918,7 +918,7 @@ partitions can be resized only so long as the new extended partition
163 completely contains all logical partitions.
165 Note that Parted can manipulate partitions whether or not they have been
166 -defragmented, so you do not need to defragmenting the disk before
167 +defragmented, so you do not need to defragment the disk before
170 Supported file systems:
171 @@ -1031,7 +1031,7 @@ Microsoft operating systems.
174 (MS-DOS) - this flag can be enabled to tell linux the partition is a
175 -software RAID partition.
176 +software RAID partition.
179 (MS-DOS) - this flag can be enabled to tell linux the partition is a
180 @@ -1109,59 +1109,59 @@ specified after an input number. Input numbers can be followed by
181 an unit (without any space or other character between them), in
182 which case this unit apply instead of the default unit for this
183 particular number, but CHS and cylinder units are not supported as
184 -a suffix. If no suffix is given, then the default unit is assumed.
185 +a suffix. If no suffix is given, then the default unit is assumed.
186 Parted will compute sensible ranges for the locations you specify
187 (e.g. a range of +/- 500 MB when you specify the location in ``G'')
188 and will select the nearest location in this range from the one you
189 wrote that satisfies constraints from both the operation, the
190 filesystem being worked on, the disk label, other partitions and so
191 on. Use the sector unit ``s'' to specify exact locations (if they
192 -do not satisfy all onstraints, Parted will ask you for the nearest
193 +do not satisfy all onstraints, Parted will ask you for the nearest
194 solution). Note that negative numbers count back from the end of
195 -the disk, with ``-1s'' pointing to the end of the disk.
196 +the disk, with ``-1s'' pointing to the end of the disk.
202 -(parted) unit compact
204 +(parted) unit compact
206 Disk geometry for /dev/hda: 0kB - 123GB
207 Disk label type: msdos
208 Number Start End Size Type File system Flags
209 1 32kB 1078MB 1077MB primary reiserfs boot
210 -2 1078MB 2155MB 1078MB primary linux-swap
211 -3 2155MB 123GB 121GB extended
212 -5 2155MB 7452MB 5297MB logical reiserfs
213 +2 1078MB 2155MB 1078MB primary linux-swap
214 +3 2155MB 123GB 121GB extended
215 +5 2155MB 7452MB 5297MB logical reiserfs
218 -(parted) unit chs print
219 +(parted) unit chs print
220 Disk geometry for /dev/hda: 0,0,0 - 14946,225,62
221 BIOS cylinder,head,sector geometry: 14946,255,63. Each cylinder
223 Disk label type: msdos
224 Number Start End Type File system Flags
225 1 0,1,0 130,254,62 primary reiserfs boot
226 -2 131,0,0 261,254,62 primary linux-swap
227 -3 262,0,0 14945,254,62 extended
228 -5 262,2,0 905,254,62 logical reiserfs
229 +2 131,0,0 261,254,62 primary linux-swap
230 +3 262,0,0 14945,254,62 extended
231 +5 262,2,0 905,254,62 logical reiserfs
234 -(parted) unit mb print
235 +(parted) unit mb print
236 Disk geometry for /dev/hda: 0MB - 122942MB
237 Disk label type: msdos
238 Number Start End Size Type File system Flags
239 1 0MB 1078MB 1077MB primary reiserfs boot
240 -2 1078MB 2155MB 1078MB primary linux-swap
241 -3 2155MB 122935MB 120780MB extended
242 -5 2155MB 7452MB 5297MB logical reiserfs
243 +2 1078MB 2155MB 1078MB primary linux-swap
244 +3 2155MB 122935MB 120780MB extended
245 +5 2155MB 7452MB 5297MB logical reiserfs
251 @node Related information
252 -@chapter Related information
253 +@chapter Related information
254 @cindex further reading
255 @cindex related documentation
257 diff --git a/include/parted/constraint.h b/include/parted/constraint.h
258 index 7a39602..6496926 100644
259 --- a/include/parted/constraint.h
260 +++ b/include/parted/constraint.h
262 typedef struct _PedConstraint PedConstraint;
264 #include <parted/device.h>
265 +#include <parted/geom.h>
266 #include <parted/natmath.h>
268 struct _PedConstraint {
269 diff --git a/include/parted/device.h b/include/parted/device.h
270 index cf32dba..e669688 100644
271 --- a/include/parted/device.h
272 +++ b/include/parted/device.h
274 #ifndef PED_DEVICE_H_INCLUDED
275 #define PED_DEVICE_H_INCLUDED
277 +#include <parted/constraint.h>
278 #include <parted/timer.h>
280 /** We can address 2^63 sectors */
281 @@ -45,9 +46,7 @@ typedef enum {
283 PED_DEVICE_VIODASD = 10,
285 -#ifdef ENABLE_DEVICE_MAPPER
291 diff --git a/include/parted/disk.h b/include/parted/disk.h
292 index b82ea0f..1b0133d 100644
293 --- a/include/parted/disk.h
294 +++ b/include/parted/disk.h
297 libparted - a library for manipulating disk partitions
298 - Copyright (C) 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
299 + Copyright (C) 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
301 This program is free software; you can redistribute it and/or modify
302 it under the terms of the GNU General Public License as published by
303 @@ -52,10 +52,11 @@ enum _PedPartitionFlag {
304 PED_PARTITION_HPSERVICE=8,
305 PED_PARTITION_PALO=9,
306 PED_PARTITION_PREP=10,
307 - PED_PARTITION_MSFT_RESERVED=11
308 + PED_PARTITION_MSFT_RESERVED=11,
309 + PED_PARTITION_BIOS_GRUB=12
311 #define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
312 -#define PED_PARTITION_LAST_FLAG PED_PARTITION_MSFT_RESERVED
313 +#define PED_PARTITION_LAST_FLAG PED_PARTITION_BIOS_GRUB
315 enum _PedDiskTypeFeature {
316 PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
317 diff --git a/include/parted/linux.h b/include/parted/linux.h
318 index 52d28be..05a2f0e 100644
319 --- a/include/parted/linux.h
320 +++ b/include/parted/linux.h
322 #include <parted/parted.h>
323 #include <parted/device.h>
325 -#if defined __s390__ || defined __s390x__
326 +#if defined(__s390__) || defined(__s390x__)
327 # include <parted/fdasd.h>
330 diff --git a/include/parted/natmath.h b/include/parted/natmath.h
331 index 32a6e28..e387833 100644
332 --- a/include/parted/natmath.h
333 +++ b/include/parted/natmath.h
335 typedef struct _PedAlignment PedAlignment;
337 #include <parted/disk.h>
338 +#include <parted/device.h>
340 #define PED_MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
341 #define PED_MAX(a, b) ( ((a)>(b)) ? (a) : (b) )
342 diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
343 index 462ab92..9876956 100644
344 --- a/libparted/arch/linux.c
345 +++ b/libparted/arch/linux.c
347 #define HDIO_GETGEO 0x0301 /* get device geometry */
348 #define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
350 -#if defined(O_DIRECT) && (!defined(__s390__) || !defined(__s390x__))
351 +#if defined(O_DIRECT) && !(defined(__s390__) || defined(__s390x__))
352 #define RD_MODE (O_RDONLY | O_DIRECT)
353 #define WR_MODE (O_WRONLY | O_DIRECT)
354 #define RW_MODE (O_RDWR | O_DIRECT)
355 @@ -986,7 +986,7 @@ error:
359 -init_dasd (PedDevice* dev, char* model_name)
360 +init_dasd (PedDevice* dev, const char* model_name)
362 struct stat dev_stat;
363 struct hd_geometry geo;
364 @@ -1042,7 +1042,7 @@ error:
368 -init_generic (PedDevice* dev, char* model_name)
369 +init_generic (PedDevice* dev, const char* model_name)
371 struct stat dev_stat;
372 PedExceptionOption ex_status;
373 diff --git a/libparted/cs/natmath.c b/libparted/cs/natmath.c
374 index b8b4a95..fd376cd 100644
375 --- a/libparted/cs/natmath.c
376 +++ b/libparted/cs/natmath.c
377 @@ -74,16 +74,16 @@ ped_round_down_to (PedSector sector, PedSector grain_size)
378 return sector - abs_mod (sector, grain_size);
383 ped_div_round_up (PedSector numerator, PedSector divisor)
385 - return (numerator + divisor - 1) / divisor;
386 + return (numerator + divisor - 1) / divisor;
391 ped_div_round_to_nearest (PedSector numerator, PedSector divisor)
393 - return (numerator + divisor/2) / divisor;
394 + return (numerator + divisor/2) / divisor;
397 /* Rounds a number up to the closest number that is a multiple of
398 diff --git a/libparted/disk.c b/libparted/disk.c
399 index 1582f26..c465d40 100644
400 --- a/libparted/disk.c
401 +++ b/libparted/disk.c
402 @@ -224,23 +224,24 @@ static int
403 _add_duplicate_part (PedDisk* disk, PedPartition* old_part)
405 PedPartition* new_part;
406 - PedConstraint* constraint_exact;
409 new_part = disk->type->ops->partition_duplicate (old_part);
412 new_part->disk = disk;
414 - constraint_exact = ped_constraint_exact (&new_part->geom);
415 - if (!constraint_exact)
416 + _disk_push_update_mode (disk);
417 + ret = _disk_raw_add (disk, new_part);
418 + _disk_pop_update_mode (disk);
420 goto error_destroy_new_part;
421 - if (!ped_disk_add_partition (disk, new_part, constraint_exact))
422 - goto error_destroy_constraint_exact;
423 - ped_constraint_destroy (constraint_exact);
425 + if (!_disk_check_sanity (disk))
426 + goto error_destroy_new_part;
430 -error_destroy_constraint_exact:
431 - ped_constraint_destroy (constraint_exact);
432 error_destroy_new_part:
433 ped_partition_destroy (new_part);
435 @@ -2161,6 +2162,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
437 case PED_PARTITION_BOOT:
439 + case PED_PARTITION_BIOS_GRUB:
440 + return N_("bios_grub");
441 case PED_PARTITION_ROOT:
443 case PED_PARTITION_SWAP:
444 diff --git a/libparted/exception.c b/libparted/exception.c
445 index 0940d65..230a9b7 100644
446 --- a/libparted/exception.c
447 +++ b/libparted/exception.c
450 libparted - a library for manipulating disk partitions
451 - Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc.
452 + Copyright (C) 1999, 2000, 2007-2008 Free Software Foundation, Inc.
454 This program is free software; you can redistribute it and/or modify
455 it under the terms of the GNU General Public License as published by
456 @@ -73,7 +73,7 @@ static PedExceptionHandler* ex_handler = default_handler;
457 static PedException* ex = NULL;
458 static int ex_fetch_count = 0;
460 -static char* type_strings [] = {
461 +static const char *const type_strings [] = {
465 @@ -82,7 +82,7 @@ static char* type_strings [] = {
466 N_("No Implementation")
469 -static char* option_strings [] = {
470 +static const char *const option_strings [] = {
474 @@ -98,7 +98,7 @@ static char* option_strings [] = {
476 ped_exception_get_type_string (PedExceptionType ex_type)
478 - return type_strings [ex_type - 1];
479 + return (char *) type_strings [ex_type - 1];
482 /* FIXME: move this out to the prospective math.c */
483 @@ -121,7 +121,7 @@ ped_log2 (int n)
485 ped_exception_get_option_string (PedExceptionOption ex_opt)
487 - return option_strings [ped_log2 (ex_opt)];
488 + return (char *) option_strings [ped_log2 (ex_opt)];
491 static PedExceptionOption
492 @@ -243,8 +243,8 @@ ped_exception_throw (PedExceptionType ex_type,
494 ex->options = ex_opts;
497 - ex->message = (char*) malloc (size);
499 + ex->message = (char*) malloc (size * sizeof (char));
503 @@ -256,6 +256,7 @@ ped_exception_throw (PedExceptionType ex_type,
507 + ped_free (ex->message);
511 diff --git a/libparted/fs/ext2/ext2.c b/libparted/fs/ext2/ext2.c
512 index 618fca9..79fc6f6 100644
513 --- a/libparted/fs/ext2/ext2.c
514 +++ b/libparted/fs/ext2/ext2.c
515 @@ -727,7 +727,10 @@ struct ext2_fs *ext2_open(struct ext2_dev_handle *handle, int state)
516 EXT2_FEATURE_RO_COMPAT_LARGE_FILE)))
518 ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
519 - _("File system has an incompatible feature enabled."));
520 + _("File system has an incompatible feature enabled. "
521 + "Compatible features are has_journal, dir_index, "
522 + "filetype, sparse_super and large_file. "
523 + "Use tune2fs or debugfs to remove features."));
527 diff --git a/libparted/fs/ext2/ext2_block_relocator.c b/libparted/fs/ext2/ext2_block_relocator.c
528 index b75a4c5..60f3d50 100644
529 --- a/libparted/fs/ext2/ext2_block_relocator.c
530 +++ b/libparted/fs/ext2/ext2_block_relocator.c
531 @@ -691,10 +691,11 @@ static int ext2_block_relocator_flush(struct ext2_fs *fs, struct ext2_block_relo
533 /* FIXXXME gross hack */
534 fprintf(stderr, "relocating %s blocks",
535 - ((char *[4]){"direct",
538 - "triply indirect"})[i]);
539 + ((const char *const [4])
543 + "triply indirect"})[i]);
547 diff --git a/libparted/fs/ext2/ext2_mkfs.c b/libparted/fs/ext2/ext2_mkfs.c
548 index 19931dd..b1a8ce3 100644
549 --- a/libparted/fs/ext2/ext2_mkfs.c
550 +++ b/libparted/fs/ext2/ext2_mkfs.c
553 ext2_mkfs.c -- ext2 fs creator
554 - Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
555 + Copyright (C) 1999, 2000, 2001, 2007-2008 Free Software Foundation, Inc.
557 This program is free software; you can redistribute it and/or modify
558 it under the terms of the GNU General Public License as published by
559 @@ -263,7 +263,7 @@ error:
561 /* returns the offset into the buffer of the start of the next dir entry */
562 static int _set_dirent(void* buf, int offset, int block_size, int is_last,
563 - uint32_t inode, char* name, int file_type)
564 + uint32_t inode, const char* name, int file_type)
566 struct ext2_dir_entry_2 *dirent = (void*) (((char*)buf) + offset);
567 int name_len = strlen(name);
568 diff --git a/libparted/fs/fat/resize.c b/libparted/fs/fat/resize.c
569 index 7386948..5f24ec2 100644
570 --- a/libparted/fs/fat/resize.c
571 +++ b/libparted/fs/fat/resize.c
575 - Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
576 + Copyright (C) 1998, 1999, 2000, 2007-2008 Free Software Foundation, Inc.
578 This program is free software; you can redistribute it and/or modify
579 it under the terms of the GNU General Public License as published by
580 @@ -481,8 +481,8 @@ ask_type (PedFileSystem* fs, int fat16_ok, int fat32_ok, FatType* out_fat_type)
582 FatSpecific* fs_info = FAT_SPECIFIC (fs);
583 PedExceptionOption status;
586 + const char* fat16_msg;
587 + const char* fat32_msg;
589 if (fs_info->fat_type == FAT_TYPE_FAT16)
590 fat16_msg = _("If you leave your file system as FAT16, "
591 diff --git a/libparted/fs/fat/traverse.c b/libparted/fs/fat/traverse.c
592 index 3d2e2b5..4ef2044 100644
593 --- a/libparted/fs/fat/traverse.c
594 +++ b/libparted/fs/fat/traverse.c
595 @@ -120,7 +120,7 @@ fat_traverse_mark_dirty (FatTraverseInfo* trav_info)
598 fat_traverse_begin (PedFileSystem* fs, FatCluster start_cluster,
600 + const char* dir_name)
602 FatSpecific* fs_info = FAT_SPECIFIC (fs);
603 FatTraverseInfo* trav_info;
604 diff --git a/libparted/fs/fat/traverse.h b/libparted/fs/fat/traverse.h
605 index 21e4c27..afb24a5 100644
606 --- a/libparted/fs/fat/traverse.h
607 +++ b/libparted/fs/fat/traverse.h
608 @@ -42,7 +42,8 @@ extern int fat_traverse_entries_per_buffer (FatTraverseInfo* trav_info);
609 /* starts traversal at an arbitary cluster. if start_cluster==0, then uses
611 extern FatTraverseInfo* fat_traverse_begin (PedFileSystem* fs,
612 - FatCluster start_cluster, char* dir_name);
613 + FatCluster start_cluster,
614 + const char* dir_name);
616 extern int fat_traverse_complete (FatTraverseInfo* trav_info);
618 diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
619 index f25353b..ee9aba0 100644
620 --- a/libparted/labels/bsd.c
621 +++ b/libparted/labels/bsd.c
622 @@ -108,6 +108,9 @@ typedef struct {
631 static PedDiskType bsd_disk_type;
632 @@ -394,6 +397,9 @@ bsd_partition_new (const PedDisk* disk, PedPartitionType part_type,
634 goto error_free_part;
636 + bsd_data->boot = 0;
637 + bsd_data->raid = 0;
640 part->disk_specific = NULL;
642 @@ -423,6 +429,9 @@ bsd_partition_duplicate (const PedPartition* part)
643 old_bsd_data = (BSDPartitionData*) part->disk_specific;
644 new_bsd_data = (BSDPartitionData*) new_part->disk_specific;
645 new_bsd_data->type = old_bsd_data->type;
646 + new_bsd_data->boot = old_bsd_data->boot;
647 + new_bsd_data->raid = old_bsd_data->raid;
648 + new_bsd_data->lvm = old_bsd_data->lvm;
652 @@ -456,14 +465,60 @@ bsd_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
654 bsd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
656 - /* no flags for bsd */
658 +// PedPartition* walk; // since -Werror, this unused variable would break build
659 + BSDPartitionData* bsd_data;
661 + PED_ASSERT (part != NULL, return 0);
662 + PED_ASSERT (part->disk_specific != NULL, return 0);
663 + PED_ASSERT (part->disk != NULL, return 0);
665 + bsd_data = part->disk_specific;
669 + case PED_PARTITION_BOOT:
670 + bsd_data->boot = state;
672 + case PED_PARTITION_RAID:
676 + bsd_data->raid = state;
678 + case PED_PARTITION_LVM:
680 + bsd_data->raid = 0;
682 + bsd_data->lvm = state;
690 bsd_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
692 - /* no flags for bsd */
693 + BSDPartitionData* bsd_data;
695 + PED_ASSERT (part != NULL, return 0);
696 + PED_ASSERT (part->disk_specific != NULL, return 0);
698 + bsd_data = part->disk_specific;
700 + case PED_PARTITION_BOOT:
701 + return bsd_data->boot;
703 + case PED_PARTITION_RAID:
704 + return bsd_data->raid;
706 + case PED_PARTITION_LVM:
707 + return bsd_data->lvm;
715 @@ -471,7 +526,14 @@ static int
716 bsd_partition_is_flag_available (const PedPartition* part,
717 PedPartitionFlag flag)
719 - /* no flags for bsd */
721 + case PED_PARTITION_BOOT:
722 + case PED_PARTITION_RAID:
723 + case PED_PARTITION_LVM:
731 diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
732 index c686658..641257c 100644
733 --- a/libparted/labels/dos.c
734 +++ b/libparted/labels/dos.c
735 @@ -190,14 +190,16 @@ msdos_probe (const PedDevice *dev)
736 if (PED_LE16_TO_CPU (part_table->magic) != MSDOS_MAGIC)
739 - /* if this is a FAT fs, fail here. Note that the Smart Boot Manager
740 - * Loader (SBML) signature indicates a partition table, not a file
742 + /* If this is a FAT fs, fail here. Checking for the FAT signature
743 + * has some false positives; instead, do what the Linux kernel does
744 + * and ensure that each partition has a boot indicator that is
745 + * either 0 or 0x80.
747 - if ((!strncmp (part_table->boot_code + 0x36, "FAT", 3)
748 - && strncmp (part_table->boot_code + 0x40, "SBML", 4) != 0)
749 - || !strncmp (part_table->boot_code + 0x52, "FAT", 3))
751 + for (i = 0; i < 4; i++) {
752 + if (part_table->partitions[i].boot_ind != 0
753 + && part_table->partitions[i].boot_ind != 0x80)
757 /* If this is a GPT disk, fail here */
758 for (i = 0; i < 4; i++) {
759 diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
760 index e4ecf52..7adf12f 100644
761 --- a/libparted/labels/fdasd.c
762 +++ b/libparted/labels/fdasd.c
763 @@ -149,7 +149,7 @@ fdasd_error (fdasd_anchor_t *anc, enum fdasd_failure why, char * str)
764 case device_verification_failed:
765 sprintf(error, "fdasd: %s -- %s\n",
766 _("Device verification failed"),
767 - _("The specified device is not a valid DASD device"));,
768 + _("The specified device is not a valid DASD device"));
771 sprintf(error, "fdasd: %s: %s\n", _("Fatal error"), str);
772 diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
773 index 4dc4f10..cb90d11 100644
774 --- a/libparted/labels/gpt.c
775 +++ b/libparted/labels/gpt.c
777 original version by Matt Domsch <Matt_Domsch@dell.com>
778 Disclaimed into the Public Domain
780 - Portions Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007
781 + Portions Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2008
782 Free Software Foundation, Inc.
784 EFI GUID Partition Table handling
785 @@ -86,6 +86,10 @@ typedef struct {
786 ((efi_guid_t) { PED_CPU_TO_LE32 (0xC12A7328), PED_CPU_TO_LE16 (0xF81F), \
787 PED_CPU_TO_LE16 (0x11d2), 0xBA, 0x4B, \
788 { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B }})
789 +#define PARTITION_BIOS_GRUB_GUID \
790 + ((efi_guid_t) { PED_CPU_TO_LE32 (0x21686148), PED_CPU_TO_LE16 (0x6449), \
791 + PED_CPU_TO_LE16 (0x6E6f), 0x74, 0x4E, \
792 + { 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 }})
793 #define LEGACY_MBR_PARTITION_GUID \
794 ((efi_guid_t) { PED_CPU_TO_LE32 (0x024DEE41), PED_CPU_TO_LE16 (0x33E7), \
795 PED_CPU_TO_LE16 (0x11d3, 0x9D, 0x69, \
796 @@ -245,6 +249,7 @@ typedef struct _GPTPartitionData {
804 @@ -753,13 +758,16 @@ _parse_part_entry (PedDisk* disk, GuidPartitionEntry_t* pte)
806 gpt_part_data->lvm = gpt_part_data->raid
807 = gpt_part_data->boot = gpt_part_data->hp_service
808 - = gpt_part_data->hidden = gpt_part_data->msftres = 0;
809 + = gpt_part_data->hidden = gpt_part_data->msftres
810 + = gpt_part_data->bios_grub = 0;
812 if (pte->Attributes.RequiredToFunction & 0x1)
813 gpt_part_data->hidden = 1;
815 if (!guid_cmp (gpt_part_data->type, PARTITION_SYSTEM_GUID))
816 gpt_part_data->boot = 1;
817 + else if (!guid_cmp (gpt_part_data->type, PARTITION_BIOS_GRUB_GUID))
818 + gpt_part_data->bios_grub = 1;
819 else if (!guid_cmp (gpt_part_data->type, PARTITION_RAID_GUID))
820 gpt_part_data->raid = 1;
821 else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
822 @@ -1130,6 +1138,7 @@ gpt_partition_new (const PedDisk* disk,
823 gpt_part_data->lvm = 0;
824 gpt_part_data->raid = 0;
825 gpt_part_data->boot = 0;
826 + gpt_part_data->bios_grub = 0;
827 gpt_part_data->hp_service = 0;
828 gpt_part_data->hidden = 0;
829 gpt_part_data->msftres = 0;
830 @@ -1208,6 +1217,10 @@ gpt_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
831 gpt_part_data->type = PARTITION_SYSTEM_GUID;
834 + if (gpt_part_data->bios_grub) {
835 + gpt_part_data->type = PARTITION_BIOS_GRUB_GUID;
838 if (gpt_part_data->hp_service) {
839 gpt_part_data->type = PARTITION_HPSERVICE_GUID;
841 @@ -1306,6 +1319,16 @@ gpt_partition_set_flag(PedPartition *part,
845 + = gpt_part_data->bios_grub
846 + = gpt_part_data->hp_service
847 + = gpt_part_data->msftres = 0;
848 + return gpt_partition_set_system (part, part->fs_type);
849 + case PED_PARTITION_BIOS_GRUB:
850 + gpt_part_data->bios_grub = state;
852 + gpt_part_data->raid
853 + = gpt_part_data->lvm
854 + = gpt_part_data->boot
855 = gpt_part_data->hp_service
856 = gpt_part_data->msftres = 0;
857 return gpt_partition_set_system (part, part->fs_type);
858 @@ -1314,6 +1337,7 @@ gpt_partition_set_flag(PedPartition *part,
862 + = gpt_part_data->bios_grub
863 = gpt_part_data->hp_service
864 = gpt_part_data->msftres = 0;
865 return gpt_partition_set_system (part, part->fs_type);
866 @@ -1322,6 +1346,7 @@ gpt_partition_set_flag(PedPartition *part,
869 = gpt_part_data->raid
870 + = gpt_part_data->bios_grub
871 = gpt_part_data->hp_service
872 = gpt_part_data->msftres = 0;
873 return gpt_partition_set_system (part, part->fs_type);
874 @@ -1331,6 +1356,7 @@ gpt_partition_set_flag(PedPartition *part,
876 = gpt_part_data->raid
878 + = gpt_part_data->bios_grub
879 = gpt_part_data->msftres = 0;
880 return gpt_partition_set_system (part, part->fs_type);
881 case PED_PARTITION_MSFT_RESERVED:
882 @@ -1339,6 +1365,7 @@ gpt_partition_set_flag(PedPartition *part,
884 = gpt_part_data->raid
886 + = gpt_part_data->bios_grub
887 = gpt_part_data->hp_service = 0;
888 return gpt_partition_set_system (part, part->fs_type);
889 case PED_PARTITION_HIDDEN:
890 @@ -1367,6 +1394,8 @@ gpt_partition_get_flag(const PedPartition *part, PedPartitionFlag flag)
891 return gpt_part_data->lvm;
892 case PED_PARTITION_BOOT:
893 return gpt_part_data->boot;
894 + case PED_PARTITION_BIOS_GRUB:
895 + return gpt_part_data->bios_grub;
896 case PED_PARTITION_HPSERVICE:
897 return gpt_part_data->hp_service;
898 case PED_PARTITION_MSFT_RESERVED:
899 @@ -1390,6 +1419,7 @@ gpt_partition_is_flag_available(const PedPartition * part,
900 case PED_PARTITION_RAID:
901 case PED_PARTITION_LVM:
902 case PED_PARTITION_BOOT:
903 + case PED_PARTITION_BIOS_GRUB:
904 case PED_PARTITION_HPSERVICE:
905 case PED_PARTITION_MSFT_RESERVED:
906 case PED_PARTITION_HIDDEN:
907 diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
908 index f014194..538e0c0 100644
909 --- a/libparted/labels/mac.c
910 +++ b/libparted/labels/mac.c
913 libparted - a library for manipulating disk partitions
914 - Copyright (C) 2000, 2002, 2004, 2007 Free Software Foundation, Inc.
915 + Copyright (C) 2000, 2002, 2004, 2007-2008 Free Software Foundation, Inc.
917 This program is free software; you can redistribute it and/or modify
918 it under the terms of the GNU General Public License as published by
919 @@ -376,19 +376,19 @@ mac_clobber (PedDevice* dev)
920 #endif /* !DISCOVER_ONLY */
923 -_rawpart_cmp_type (MacRawPartition* raw_part, char* type)
924 +_rawpart_cmp_type (const MacRawPartition* raw_part, const char* type)
926 return strncasecmp (raw_part->type, type, 32) == 0;
930 -_rawpart_cmp_name (MacRawPartition* raw_part, char* name)
931 +_rawpart_cmp_name (const MacRawPartition* raw_part, const char* name)
933 return strncasecmp (raw_part->name, name, 32) == 0;
937 -_rawpart_is_partition_map (MacRawPartition* raw_part)
938 +_rawpart_is_partition_map (const MacRawPartition* raw_part)
940 return _rawpart_cmp_type (raw_part, "Apple_partition_map");
942 @@ -408,7 +408,7 @@ strncasestr (const char* haystack, const char* needle, int n)
946 -_rawpart_is_boot (MacRawPartition* raw_part)
947 +_rawpart_is_boot (const MacRawPartition* raw_part)
949 if (!strcasecmp(raw_part->type, "Apple_Bootstrap"))
951 @@ -420,7 +420,7 @@ _rawpart_is_boot (MacRawPartition* raw_part)
955 -_rawpart_is_driver (MacRawPartition* raw_part)
956 +_rawpart_is_driver (const MacRawPartition* raw_part)
958 if (strncmp (raw_part->type, "Apple_", 6) != 0)
960 @@ -430,7 +430,7 @@ _rawpart_is_driver (MacRawPartition* raw_part)
964 -_rawpart_has_driver (MacRawPartition* raw_part, MacDiskData* mac_disk_data)
965 +_rawpart_has_driver (const MacRawPartition* raw_part, MacDiskData* mac_disk_data)
967 MacDeviceDriver *driverlist;
969 diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
970 index 12ad29f..d526207 100644
971 --- a/libparted/tests/Makefile.am
972 +++ b/libparted/tests/Makefile.am
975 # This file may be modified and/or distributed without restriction.
977 -TESTS = t1000-label.sh
978 +TESTS = t1000-label.sh t2000-disk.sh
979 EXTRA_DIST = $(TESTS)
980 -bin_PROGRAMS = label
981 +bin_PROGRAMS = label disk
982 label_CFLAGS = $(CHECK_CFLAGS) -I$(top_srcdir)/include
983 label_LDADD = $(CHECK_LIBS) $(top_builddir)/libparted/libparted.la
984 label_SOURCES = common.h common.c label.c
986 +disk_CFLAGS = $(CHECK_CFLAGS) -I$(top_srcdir)/include
987 +disk_LDADD = $(CHECK_LIBS) $(top_builddir)/libparted/libparted.la
988 +disk_SOURCES = common.h common.c disk.c
990 MAINTAINERCLEANFILES = Makefile.in
993 diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
995 index 0000000..295ec05
997 +++ b/libparted/tests/disk.c
1000 +#include <unistd.h>
1004 +#include <parted/parted.h>
1006 +#include "common.h"
1008 +static char* temporary_disk;
1013 + temporary_disk = _create_disk (20);
1014 + fail_if (temporary_disk == NULL, "Failed to create temporary disk");
1018 +destroy_disk (void)
1020 + unlink (temporary_disk);
1021 + free (temporary_disk);
1024 +/* TEST: Create a disklabel on a simple disk image */
1025 +START_TEST (test_duplicate)
1027 + PedDevice* dev = ped_device_get (temporary_disk);
1031 + PedDiskType* type;
1033 + PedDisk* disk_dup;
1034 + PedPartition *part;
1035 + PedPartition *part_dup;
1036 + PedConstraint *constraint;
1038 + int part_num[] = {1, 5, 6, 0};
1040 + disk = _create_disk_label (dev, ped_disk_type_get ("msdos"));
1042 + constraint = ped_constraint_any (dev);
1044 + /* Primary partition from 16,4kB to 15MB */
1045 + part = ped_partition_new (disk, PED_PARTITION_EXTENDED,
1048 + ped_disk_add_partition (disk, part, constraint);
1050 + /* Logical partition from 10MB to 15MB */
1051 + part = ped_partition_new (disk, PED_PARTITION_LOGICAL,
1052 + ped_file_system_type_get ("ext2"),
1054 + ped_disk_add_partition (disk, part, constraint);
1056 + /* Logical partition from 16,4kB to 4981kB */
1057 + part = ped_partition_new (disk, PED_PARTITION_LOGICAL,
1058 + ped_file_system_type_get ("ext2"),
1060 + ped_disk_add_partition (disk, part, constraint);
1062 + ped_disk_commit (disk);
1064 + ped_constraint_destroy (constraint);
1066 + disk_dup = ped_disk_duplicate (disk);
1068 + /* Checks if both partitions match */
1069 + for (int *i = part_num; *i != 0; i++) {
1070 + part = ped_disk_get_partition (disk, *i);
1071 + part_dup = ped_disk_get_partition (disk_dup, *i);
1073 + fail_if (part->geom.start != part_dup->geom.start ||
1074 + part->geom.end != part_dup->geom.end,
1075 + "Duplicated partition %d doesn't match. "
1076 + "Details are start: %d/%d end: %d/%d\n",
1077 + *i, part->geom.start, part_dup->geom.start,
1078 + part->geom.end, part_dup->geom.end);
1081 + ped_disk_destroy (disk);
1082 + ped_device_destroy (dev);
1089 + int number_failed;
1090 + Suite* suite = suite_create ("Disk");
1091 + TCase* tcase_duplicate = tcase_create ("Duplicate");
1093 + /* Fail when an exception is raised */
1094 + ped_exception_set_handler (_test_exception_handler);
1096 + tcase_add_checked_fixture (tcase_duplicate, create_disk, destroy_disk);
1097 + tcase_add_test (tcase_duplicate, test_duplicate);
1098 + /* Disable timeout for this test */
1099 + tcase_set_timeout (tcase_duplicate, 0);
1100 + suite_add_tcase (suite, tcase_duplicate);
1102 + SRunner* srunner = srunner_create (suite);
1103 + srunner_run_all (srunner, CK_VERBOSE);
1105 + number_failed = srunner_ntests_failed (srunner);
1106 + srunner_free (srunner);
1108 + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
1110 diff --git a/libparted/tests/t2000-disk.sh b/libparted/tests/t2000-disk.sh
1111 new file mode 100755
1112 index 0000000..7a85b98
1114 +++ b/libparted/tests/t2000-disk.sh
1118 +# Copyright (C) 2007 Free Software Foundation, Inc.
1120 +# This program is free software; you can redistribute it and/or modify
1121 +# it under the terms of the GNU General Public License as published by
1122 +# the Free Software Foundation; either version 3 of the License, or
1123 +# (at your option) any later version.
1125 +# This program is distributed in the hope that it will be useful,
1126 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1127 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1128 +# GNU General Public License for more details.
1130 +# You should have received a copy of the GNU General Public License
1131 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1133 +test_description='run the disk unit tests in a directory supporting O_DIRECT'
1134 +# This wrapper around the ./label binary is used to find a directory
1135 +# in which one can open a file with the O_DIRECT flag.
1139 +test_expect_success \
1140 + 'run the actual tests' 'disk'
1143 diff --git a/parted/parted.c b/parted/parted.c
1144 index 6a606ae..2afc2c1 100644
1145 --- a/parted/parted.c
1146 +++ b/parted/parted.c
1147 @@ -79,7 +79,7 @@ typedef struct {
1148 time_t predicted_time_left;
1151 -static struct option options[] = {
1152 +static const struct option const options[] = {
1153 /* name, has-arg, string-return-val, char-return-val */
1154 {"help", 0, NULL, 'h'},
1155 {"list", 0, NULL, 'l'},
1156 @@ -90,7 +90,7 @@ static struct option options[] = {
1160 -static char* options_help [][2] = {
1161 +static const char *const options_help [][2] = {
1162 {"help", N_("displays this help message")},
1163 {"list", N_("lists partition layout on all block devices")},
1164 {"machine", N_("displays machine parseable output")},
1165 @@ -107,26 +107,26 @@ int opt_machine_mode = 0;
1166 int disk_is_modified = 0;
1167 int is_toggle_mode = 0;
1169 -static char* number_msg = N_(
1170 +static const char* number_msg = N_(
1171 "NUMBER is the partition number used by Linux. On MS-DOS disk labels, the "
1172 "primary partitions number from 1 to 4, logical partitions from 5 onwards.\n");
1174 -static char* label_type_msg_start = N_("LABEL-TYPE is one of: ");
1175 -static char* flag_msg_start = N_("FLAG is one of: ");
1176 -static char* unit_msg_start = N_("UNIT is one of: ");
1177 -static char* part_type_msg = N_("PART-TYPE is one of: primary, logical, "
1178 +static const char* label_type_msg_start = N_("LABEL-TYPE is one of: ");
1179 +static const char* flag_msg_start = N_("FLAG is one of: ");
1180 +static const char* unit_msg_start = N_("UNIT is one of: ");
1181 +static const char* part_type_msg = N_("PART-TYPE is one of: primary, logical, "
1183 -static char* fs_type_msg_start = N_("FS-TYPE is one of: ");
1184 -static char* start_end_msg = N_("START and END are disk locations, such as "
1185 +static const char* fs_type_msg_start = N_("FS-TYPE is one of: ");
1186 +static const char* start_end_msg = N_("START and END are disk locations, such as "
1187 "4GB or 10%. Negative values count from the end of the disk. "
1188 "For example, -1s specifies exactly the last sector.\n");
1189 -static char* state_msg = N_("STATE is one of: on, off\n");
1190 -static char* device_msg = N_("DEVICE is usually /dev/hda or /dev/sda\n");
1191 -static char* name_msg = N_("NAME is any word you want\n");
1192 -static char* resize_msg_start = N_("The partition must have one of the "
1193 +static const char* state_msg = N_("STATE is one of: on, off\n");
1194 +static const char* device_msg = N_("DEVICE is usually /dev/hda or /dev/sda\n");
1195 +static const char* name_msg = N_("NAME is any word you want\n");
1196 +static const char* resize_msg_start = N_("The partition must have one of the "
1197 "following FS-TYPEs: ");
1199 -static char* copyright_msg = N_(
1200 +static const char* copyright_msg = N_(
1201 "Copyright (C) 1998 - 2006 Free Software Foundation, Inc.\n"
1202 "This program is free software, covered by the GNU General Public License.\n"
1204 @@ -1226,7 +1226,7 @@ partition_print (PedPartition* part)
1207 flags = partition_print_flags (part);
1210 printf (_("Minor: %d\n"), part->num);
1211 printf (_("Flags: %s\n"), flags);
1212 printf (_("File System: %s\n"), fs->type->name);
1213 @@ -1264,15 +1264,17 @@ do_print (PedDevice** dev)
1214 int has_free_arg = 0;
1215 int has_list_arg = 0;
1216 int has_num_arg = 0;
1217 - char* transport[13] = {"unknown", "scsi", "ide", "dac960",
1218 - "cpqarray", "file", "ataraid", "i2o",
1219 - "ubd", "dasd", "viodasd", "sx8", "dm"};
1220 + const char *const transport[14] = {"unknown", "scsi", "ide", "dac960",
1221 + "cpqarray", "file", "ataraid", "i2o",
1222 + "ubd", "dasd", "viodasd", "sx8", "dm",
1231 wchar_t* table_rendered;
1233 disk = ped_disk_new (*dev);
1234 @@ -1472,7 +1474,9 @@ do_print (PedDevice** dev)
1235 str_list_append (row, name);
1238 - str_list_append (row, partition_print_flags (part));
1239 + flags = partition_print_flags (part);
1240 + str_list_append (row, flags);
1244 str_list_append (row, "");
1245 @@ -1485,6 +1489,10 @@ do_print (PedDevice** dev)
1246 //PED_ASSERT (row.cols == caption.cols)
1247 table_add_row_from_strlist (table, row);
1248 str_list_destroy (row);
1255 table_rendered = table_render (table);
1256 diff --git a/parted/ui.c b/parted/ui.c
1257 index a53643f..f854a54 100644
1260 @@ -154,17 +154,17 @@ struct siginfo_t {
1261 # define ILL_BADSTK (INTMAX - 8)
1264 -char* prog_name = "GNU Parted " VERSION "\n";
1265 +const char* prog_name = "GNU Parted " VERSION "\n";
1267 -static char* banner_msg = N_(
1268 +static const char* banner_msg = N_(
1269 "Welcome to GNU Parted! Type 'help' to view a list of commands.\n");
1271 -static char* usage_msg = N_(
1272 +static const char* usage_msg = N_(
1273 "Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]\n"
1274 "Apply COMMANDs with PARAMETERS to DEVICE. If no COMMAND(s) are given, "
1275 "run in\ninteractive mode.\n");
1277 -static char* bug_msg = N_(
1278 +static const char* bug_msg = N_(
1279 "\n\nYou found a bug in GNU Parted! Here's what you have to do:\n\n"
1280 "Don't panic! The bug has most likely not affected any of your data.\n"
1281 "Help us to fix this bug by doing the following:\n\n"
1282 @@ -218,7 +218,7 @@ screen_width ()
1284 /* HACK: don't specify termcap separately - it'll annoy the users. */
1285 #ifdef HAVE_LIBREADLINE
1286 - width = tgetnum ("co");
1287 + width = tgetnum ((char *) "co");
1291 @@ -569,7 +569,9 @@ _readline (const char* prompt, const StrList* possibilities)
1292 fputs (line, stdout);
1295 - line [strlen (line) - 1] = 0; /* kill trailing CR */
1296 + /* kill trailing NL */
1297 + if (strlen (line))
1298 + line [strlen (line) - 1] = 0;
1302 diff --git a/parted/ui.h b/parted/ui.h
1303 index f5cf760..77bb194 100644
1308 parted - a frontend to libparted
1309 - Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
1310 + Copyright (C) 1999, 2000, 2001, 2007-2008 Free Software Foundation, Inc.
1312 This program is free software; you can redistribute it and/or modify
1313 it under the terms of the GNU General Public License as published by
1316 #include "strlist.h"
1318 -extern char* prog_name;
1319 +extern const char *prog_name;
1321 extern int init_ui ();
1322 extern int non_interactive_mode (PedDevice** dev, Command* cmd_list[],
1323 diff --git a/tests/Makefile.am b/tests/Makefile.am
1324 index 0a42a8d..3a694fe 100644
1325 --- a/tests/Makefile.am
1326 +++ b/tests/Makefile.am
1327 @@ -5,8 +5,10 @@ TESTS = \
1328 t1100-busy-label.sh \
1329 t1500-small-ext2.sh \
1331 + t2200-dos-label-recog.sh \
1332 t3000-constraints.sh \
1333 - t3100-resize-ext2-partion.sh
1334 + t3100-resize-ext2-partion.sh \
1338 $(TESTS) test-lib.sh mkdtemp
1339 diff --git a/tests/t2200-dos-label-recog.sh b/tests/t2200-dos-label-recog.sh
1340 new file mode 100755
1341 index 0000000..d5d2670
1343 +++ b/tests/t2200-dos-label-recog.sh
1347 +# Copyright (C) 2008 Free Software Foundation, Inc.
1349 +# This program is free software; you can redistribute it and/or modify
1350 +# it under the terms of the GNU General Public License as published by
1351 +# the Free Software Foundation; either version 3 of the License, or
1352 +# (at your option) any later version.
1354 +# This program is distributed in the hope that it will be useful,
1355 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1356 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1357 +# GNU General Public License for more details.
1359 +# You should have received a copy of the GNU General Public License
1360 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1362 +test_description='improved MSDOS partition-table recognition'
1366 +######################################################################
1367 +# With vestiges of a preceding FAT file system boot sector in the MBR,
1368 +# parted 1.8.8.1.29 and earlier would fail to recognize a DOS
1370 +######################################################################
1373 +test_expect_success \
1374 + 'create a file to simulate the underlying device' \
1375 + 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
1377 +test_expect_success \
1378 + 'label the test disk' \
1379 + 'parted -s $dev mklabel msdos > out 2>&1'
1380 +test_expect_success 'expect no output' '$compare out /dev/null'
1382 +test_expect_success \
1383 + 'create two partition' \
1385 + parted -s $dev mkpart primary 1s 40s > out 2>&1 &&
1386 + parted -s $dev mkpart primary 41s 80s > out 2>&1
1389 +test_expect_success 'expect no output' '$compare out /dev/null'
1391 +test_expect_success \
1392 + 'write "FAT" where it would cause trouble' \
1393 + 'printf FAT|dd bs=1c seek=82 count=3 of=$dev conv=notrunc'
1395 +test_expect_success \
1396 + 'print the partition table' \
1398 + parted -m -s $dev unit s p > out &&
1399 + tail -2 out > k && mv k out &&
1400 + printf "1:1s:40s:40s:::;\n2:41s:80s:40s:::;\n" > exp
1403 +test_expect_success 'expect two partitions' '$compare out exp'
1406 diff --git a/tests/t5000-tags.sh b/tests/t5000-tags.sh
1407 new file mode 100755
1408 index 0000000..dab48ae
1410 +++ b/tests/t5000-tags.sh
1414 +# Copyright (C) 2007,2008 Free Software Foundation, Inc.
1416 +# This program is free software; you can redistribute it and/or modify
1417 +# it under the terms of the GNU General Public License as published by
1418 +# the Free Software Foundation; either version 3 of the License, or
1419 +# (at your option) any later version.
1421 +# This program is distributed in the hope that it will be useful,
1422 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1423 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1424 +# GNU General Public License for more details.
1426 +# You should have received a copy of the GNU General Public License
1427 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1429 +test_description="test bios_grub flag in gpt labels"
1435 +test_expect_success \
1436 + "setup: create zeroed device" \
1437 + '{ dd if=/dev/zero bs=1024 count=64; } > $dev'
1439 +test_expect_success \
1440 + 'create gpt label' \
1441 + 'parted -s $dev mklabel gpt >out 2>&1'
1443 +test_expect_success \
1444 + 'add a partition' \
1445 + 'parted -s $dev mkpart primary 0 1 >>out 2>&1'
1447 +test_expect_success \
1448 + 'print the table (before manual modification)' \
1449 + 'parted -s $dev print >>out 2>&1'
1451 +# Using bios_boot_magic='\x48\x61' looks nicer, but isn't portable.
1452 +# dash's builtin printf doesn't recognize such \xHH hexadecimal escapes.
1453 +bios_boot_magic='\110\141\150\41\111\144\157\156\164\116\145\145\144\105\106\111'
1455 +printf "$bios_boot_magic" | dd of=$dev bs=1024 seek=1 conv=notrunc
1457 +test_expect_success \
1458 + 'print the table (after manual modification)' \
1459 + 'parted -s $dev print >>out 2>&1'
1467 +Disk .../$dev: 65.5kB
1468 +Sector size (logical/physical): 512B/512B
1469 +Partition Table: gpt
1471 +Number Start End Size File system Name Flags
1472 + 1 17.4kB 48.6kB 31.2kB primary
1475 +Disk .../$dev: 65.5kB
1476 +Sector size (logical/physical): 512B/512B
1477 +Partition Table: gpt
1479 +Number Start End Size File system Name Flags
1480 + 1 17.4kB 48.6kB 31.2kB primary bios_grub
1485 +test_expect_success \
1486 + 'prepare actual and expected output' \
1487 + 'test $fail = 0 &&
1488 + mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'
1490 +test_expect_success 'check for expected output' '$compare out exp'