summaryrefslogtreecommitdiff
path: root/packages/parted/files/parted-1.8.x.patch
blob: 167a0fbeff6b86f871fa3433a2c32364d11a85d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
diff --git a/configure.ac b/configure.ac
index f1284a0..9f0971b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ dnl
 dnl This file may be modified and/or distributed without restriction.
 
 AC_PREREQ(2.61)
-AC_INIT([GNU parted],[1.8.8],[bug-parted@gnu.org])
+AC_INIT([GNU parted],[1.8.9],[bug-parted@gnu.org])
 
 AC_CONFIG_SRCDIR(include/parted/parted.h)
 
@@ -24,7 +24,7 @@ dnl function signatures changed),
 dnl set PED_BINARY_AGE _and_ PED_INTERFACE_AGE to 0.
 PED_MAJOR_VERSION=1
 PED_MINOR_VERSION=8
-PED_MICRO_VERSION=8
+PED_MICRO_VERSION=9
 PED_INTERFACE_AGE=0
 PED_BINARY_AGE=0
 PED_VERSION_SUFFIX=
@@ -471,14 +471,7 @@ AC_CHECK_HEADER([execinfo.h], [
 	])
 ])
 
-dnl Checks for #defines.
-AC_COMPILE_IFELSE([
-	AC_LANG_PROGRAM([[
-	#if defined __s390__ || defined __s390x__
-	#  message s390 defined
-	#endif
-	]])], [compile_for_s390="no"], [compile_for_s390="yes"])
-AM_CONDITIONAL([COMPILE_FOR_S390], [test "$compile_for_s390" = "yes"])
+AM_CONDITIONAL([COMPILE_FOR_S390], [test "$host_cpu" = s390 || test "$host_cpu" = s390x])
 
 dnl check for "check", unit testing library/header
 PKG_CHECK_MODULES([CHECK], [check >= 0.9.3], have_check=yes, have_check=no)
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index 7040402..fdf3d04 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -124,6 +124,18 @@ and a human-friendly form for output).
 .B version
 Display version information and a copyright message.
 .RE
+.SH KNOWN ISSUES
+ext3 filesystem resizing does not currently work, please use
+.BR resize2fs (8)
+instead.
+
+Resizing partitions with an ext3 filesystem will not generally work because
+of the above issue.  Use
+.BR resize2fs (8)
+to resize the filesystem and resize the partition manually using
+.BR fdisk (8)
+or a similar tool.  For LVM situations, you will need to use the LVM commands
+to resize the LVM elements.
 .SH REPORTING BUGS
 Report bugs to <bug-parted@gnu.org>
 .SH SEE ALSO
diff --git a/doc/parted.texi b/doc/parted.texi
index 139ea77..86ec076 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -14,7 +14,7 @@ resizing, checking and copy partitions and file systems on them.
 @ifnottex @c texi2pdf don't understand copying and insertcopying ???
 @c modifications must also be done in the titlepage
 @copying
-Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
@@ -63,7 +63,7 @@ Free Documentation License''.
 
 @c WTF doesn't texi2html include the titlepage?
 @ifhtml
-@insertcopying 
+@insertcopying
 @end ifhtml
 
 This document describes the use of GNU Parted, a program for creating,
@@ -257,7 +257,7 @@ $ @kbd{make}
 However, there are a few options for @command{configure}:
 
 @table @code
-@item --without-readline		
+@item --without-readline
 turns off use of readline.  This is useful for making rescue disks,
 etc., where few libraries are available.
 
@@ -275,12 +275,12 @@ you don't need the flexibility.
 @item --disable-fs
 disable all file system support
 
-@item --disable-nls			
+@item --disable-nls
 turns off native language support.  This is useful for use with old
 versions of glibc, or a trimmed down version of glibc suitable for
 rescue disks.
 
-@item --disable-shared		
+@item --disable-shared
 turns off shared libraries.  This may be necessary for use with old
 versions of GNU libc, if you get a compile error about a ``spilled
 register''.  Also useful for boot/rescue disks.
@@ -301,7 +301,7 @@ disable writing (for debugging)
 
 @node Static binaries
 @section Using static binaries of GNU Parted
-@cindex static binary 
+@cindex static binary
 @cindex unsupported platforms
 @cindex resizing root device
 
@@ -320,7 +320,7 @@ of the latest GNU Parted version is available, which you can use thus:
 
 @subsection Creating the Parted disk
 @enumerate
-@item Boot your system 
+@item Boot your system
 
 @item Download @file{parted-static-VERSION.tgz} from @uref{ftp://ftp.gnu.org/gnu/parted/static}
 @item Unpack the tarball, resulting in a file called ``parted.static".
@@ -329,7 +329,7 @@ of the latest GNU Parted version is available, which you can use thus:
 
 @item Do a low-level format on it (on GNU/Linux this can be achieved with
       the tool ``fdformat" from the ``util-linux" package.
-      This is basically a sanity check because floppy disks often 
+      This is basically a sanity check because floppy disks often
       contain bad blocks.
 
 @item Create a file system. Example:
@@ -359,7 +359,7 @@ $ @kbd{umount /mnt/floppy}
 
 @subsection Using the Parted disk
 @enumerate
-@item Choose a rescue disk that suits you. 
+@item Choose a rescue disk that suits you.
 
 @item Boot off your rescue disk.  Mount the disk you copied Parted onto.
 
@@ -383,7 +383,7 @@ $ @kbd{umount /mnt/floppy}
 @end menu
 
 @node Partitioning
-@section Introduction to Partitioning 
+@section Introduction to Partitioning
 @cindex partitioning overview
 
 Unfortunately, partitioning your disk is rather complicated.  This is
@@ -566,7 +566,7 @@ Supported file systems:
 (provided the destination partition is larger than the source partition)
 
 @item fat16, fat32
-@item linux-swap	
+@item linux-swap
 (equivalent to mkswap on destination partition)
 @item reiserfs (if libreiserfs is installed)
 
@@ -918,7 +918,7 @@ partitions can be resized only so long as the new extended partition
 completely contains all logical partitions.
 
 Note that Parted can manipulate partitions whether or not they have been
-defragmented, so you do not need to defragmenting the disk before
+defragmented, so you do not need to defragment the disk before
 using Parted.
 
 Supported file systems:
@@ -1031,7 +1031,7 @@ Microsoft operating systems.
 
 @item raid
 (MS-DOS) - this flag can be enabled to tell linux the partition is a
-software RAID partition. 
+software RAID partition.
 
 @item LVM
 (MS-DOS) - this flag can be enabled to tell linux the partition is a
@@ -1109,59 +1109,59 @@ specified after an input number.  Input numbers can be followed by
 an unit (without any space or other character between them), in
 which case this unit apply instead of the default unit for this
 particular number, but CHS and cylinder units are not supported as
-a suffix.  If no suffix is given, then the default unit is assumed. 
+a suffix.  If no suffix is given, then the default unit is assumed.
 Parted will compute sensible ranges for the locations you specify
 (e.g. a range of +/- 500 MB when you specify the location in ``G'')
 and will select the nearest location in this range from the one you
 wrote that satisfies constraints from both the operation, the
 filesystem being worked on, the disk label, other partitions and so
 on.  Use the sector unit ``s'' to specify exact locations (if they
-do not satisfy all onstraints, Parted will ask you for the nearest 
+do not satisfy all onstraints, Parted will ask you for the nearest
 solution).  Note that negative numbers count back from the end of
-the disk, with ``-1s'' pointing to the end of the disk.  
+the disk, with ``-1s'' pointing to the end of the disk.
 
 Example:
 
 @example
 @group
-(parted) unit compact                                                     
-(parted) print                                                            
+(parted) unit compact
+(parted) print
 Disk geometry for /dev/hda: 0kB - 123GB
 Disk label type: msdos
 Number  Start   End     Size    Type      File system  Flags
 1       32kB    1078MB  1077MB  primary   reiserfs     boot
-2       1078MB  2155MB  1078MB  primary   linux-swap   
-3       2155MB  123GB   121GB   extended               
-5       2155MB  7452MB  5297MB  logical   reiserfs     
+2       1078MB  2155MB  1078MB  primary   linux-swap
+3       2155MB  123GB   121GB   extended
+5       2155MB  7452MB  5297MB  logical   reiserfs
 @end group
 @group
-(parted) unit chs print                                                   
+(parted) unit chs print
 Disk geometry for /dev/hda: 0,0,0 - 14946,225,62
 BIOS cylinder,head,sector geometry: 14946,255,63.  Each cylinder
 is 8225kB.
 Disk label type: msdos
 Number  Start       End         Type      File system  Flags
 1       0,1,0       130,254,62  primary   reiserfs     boot
-2       131,0,0     261,254,62  primary   linux-swap   
-3       262,0,0     14945,254,62 extended               
-5       262,2,0     905,254,62  logical   reiserfs     
+2       131,0,0     261,254,62  primary   linux-swap
+3       262,0,0     14945,254,62 extended
+5       262,2,0     905,254,62  logical   reiserfs
 @end group
 @group
-(parted) unit mb print                                                    
+(parted) unit mb print
 Disk geometry for /dev/hda: 0MB - 122942MB
 Disk label type: msdos
 Number  Start   End     Size    Type      File system  Flags
 1       0MB     1078MB  1077MB  primary   reiserfs     boot
-2       1078MB  2155MB  1078MB  primary   linux-swap   
-3       2155MB  122935MB 120780MB extended               
-5       2155MB  7452MB  5297MB  logical   reiserfs     
+2       1078MB  2155MB  1078MB  primary   linux-swap
+3       2155MB  122935MB 120780MB extended
+5       2155MB  7452MB  5297MB  logical   reiserfs
 @end group
 @end example
 
 @end deffn
 
 @node Related information
-@chapter Related information 
+@chapter Related information
 @cindex further reading
 @cindex related documentation
 
diff --git a/include/parted/constraint.h b/include/parted/constraint.h
index 7a39602..6496926 100644
--- a/include/parted/constraint.h
+++ b/include/parted/constraint.h
@@ -22,6 +22,7 @@
 typedef struct _PedConstraint	PedConstraint;
 
 #include <parted/device.h>
+#include <parted/geom.h>
 #include <parted/natmath.h>
 
 struct _PedConstraint {
diff --git a/include/parted/device.h b/include/parted/device.h
index cf32dba..e669688 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -26,6 +26,7 @@
 #ifndef PED_DEVICE_H_INCLUDED
 #define PED_DEVICE_H_INCLUDED
 
+#include <parted/constraint.h>
 #include <parted/timer.h>
 
 /** We can address 2^63 sectors */
@@ -45,9 +46,7 @@ typedef enum {
         PED_DEVICE_DASD         = 9,
         PED_DEVICE_VIODASD      = 10,
         PED_DEVICE_SX8          = 11,
-#ifdef ENABLE_DEVICE_MAPPER
         PED_DEVICE_DM           = 12,
-#endif
         PED_DEVICE_XVD          = 13
 } PedDeviceType;
 
diff --git a/include/parted/disk.h b/include/parted/disk.h
index b82ea0f..1b0133d 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
+    Copyright (C) 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -52,10 +52,11 @@ enum _PedPartitionFlag {
         PED_PARTITION_HPSERVICE=8,
         PED_PARTITION_PALO=9,
         PED_PARTITION_PREP=10,
-        PED_PARTITION_MSFT_RESERVED=11
+        PED_PARTITION_MSFT_RESERVED=11,
+        PED_PARTITION_BIOS_GRUB=12
 };
 #define PED_PARTITION_FIRST_FLAG        PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG         PED_PARTITION_MSFT_RESERVED
+#define PED_PARTITION_LAST_FLAG         PED_PARTITION_BIOS_GRUB
 
 enum _PedDiskTypeFeature {
         PED_DISK_TYPE_EXTENDED=1,       /**< supports extended partitions */
diff --git a/include/parted/linux.h b/include/parted/linux.h
index 52d28be..05a2f0e 100644
--- a/include/parted/linux.h
+++ b/include/parted/linux.h
@@ -22,7 +22,7 @@
 #include <parted/parted.h>
 #include <parted/device.h>
 
-#if defined __s390__ || defined __s390x__
+#if defined(__s390__) || defined(__s390x__)
 #  include <parted/fdasd.h>
 #endif
 
diff --git a/include/parted/natmath.h b/include/parted/natmath.h
index 32a6e28..e387833 100644
--- a/include/parted/natmath.h
+++ b/include/parted/natmath.h
@@ -30,6 +30,7 @@
 typedef struct _PedAlignment	PedAlignment;
 
 #include <parted/disk.h>
+#include <parted/device.h>
 
 #define PED_MIN(a, b)	( ((a)<(b)) ? (a) : (b) )
 #define PED_MAX(a, b)	( ((a)>(b)) ? (a) : (b) )
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 462ab92..9876956 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -64,7 +64,7 @@
 #define HDIO_GETGEO             0x0301  /* get device geometry */
 #define HDIO_GET_IDENTITY       0x030d  /* get IDE identification info */
 
-#if defined(O_DIRECT) && (!defined(__s390__) || !defined(__s390x__))
+#if defined(O_DIRECT) && !(defined(__s390__) || defined(__s390x__))
 #define RD_MODE (O_RDONLY | O_DIRECT)
 #define WR_MODE (O_WRONLY | O_DIRECT)
 #define RW_MODE (O_RDWR | O_DIRECT)
@@ -986,7 +986,7 @@ error:
 }
 
 static int
-init_dasd (PedDevice* dev, char* model_name)
+init_dasd (PedDevice* dev, const char* model_name)
 {
         struct stat             dev_stat;
         struct hd_geometry      geo;
@@ -1042,7 +1042,7 @@ error:
 }
 
 static int
-init_generic (PedDevice* dev, char* model_name)
+init_generic (PedDevice* dev, const char* model_name)
 {
         struct stat             dev_stat;
         PedExceptionOption      ex_status;
diff --git a/libparted/cs/natmath.c b/libparted/cs/natmath.c
index b8b4a95..fd376cd 100644
--- a/libparted/cs/natmath.c
+++ b/libparted/cs/natmath.c
@@ -74,16 +74,16 @@ ped_round_down_to (PedSector sector, PedSector grain_size)
 	return sector - abs_mod (sector, grain_size);
 }
 
-inline PedSector
+PedSector
 ped_div_round_up (PedSector numerator, PedSector divisor)
 {
-                return (numerator + divisor - 1) / divisor;
+	return (numerator + divisor - 1) / divisor;
 }
 
-inline PedSector
+PedSector
 ped_div_round_to_nearest (PedSector numerator, PedSector divisor)
 {
-                return (numerator + divisor/2) / divisor;
+	return (numerator + divisor/2) / divisor;
 }
 
 /* Rounds a number up to the closest number that is a multiple of
diff --git a/libparted/disk.c b/libparted/disk.c
index 1582f26..c465d40 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -224,23 +224,24 @@ static int
 _add_duplicate_part (PedDisk* disk, PedPartition* old_part)
 {
 	PedPartition*	new_part;
-	PedConstraint*	constraint_exact;
+	int ret;
 
 	new_part = disk->type->ops->partition_duplicate (old_part);
 	if (!new_part)
 		goto error;
 	new_part->disk = disk;
 
-	constraint_exact = ped_constraint_exact (&new_part->geom);
-	if (!constraint_exact)
+	_disk_push_update_mode (disk);
+	ret = _disk_raw_add (disk, new_part);
+	_disk_pop_update_mode (disk);
+	if (!ret)
 		goto error_destroy_new_part;
-	if (!ped_disk_add_partition (disk, new_part, constraint_exact))
-       		goto error_destroy_constraint_exact;
-	ped_constraint_destroy (constraint_exact);
+#ifdef DEBUG
+	if (!_disk_check_sanity (disk))
+		goto error_destroy_new_part;
+#endif
 	return 1;
 
-error_destroy_constraint_exact:
-	ped_constraint_destroy (constraint_exact);
 error_destroy_new_part:
 	ped_partition_destroy (new_part);
 error:
@@ -2161,6 +2162,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
 	switch (flag) {
 	case PED_PARTITION_BOOT:
 		return N_("boot");
+	case PED_PARTITION_BIOS_GRUB:
+		return N_("bios_grub");
 	case PED_PARTITION_ROOT:
 		return N_("root");
 	case PED_PARTITION_SWAP:
diff --git a/libparted/exception.c b/libparted/exception.c
index 0940d65..230a9b7 100644
--- a/libparted/exception.c
+++ b/libparted/exception.c
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc.
+    Copyright (C) 1999, 2000, 2007-2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -73,7 +73,7 @@ static PedExceptionHandler*	ex_handler = default_handler;
 static PedException*		ex = NULL;
 static int			ex_fetch_count = 0;
 
-static char*	type_strings [] = {
+static const char *const type_strings [] = {
 	N_("Information"),
 	N_("Warning"),
 	N_("Error"),
@@ -82,7 +82,7 @@ static char*	type_strings [] = {
 	N_("No Implementation")
 };
 
-static char*	option_strings [] = {
+static const char *const option_strings [] = {
 	N_("Fix"),
 	N_("Yes"),
 	N_("No"),
@@ -98,7 +98,7 @@ static char*	option_strings [] = {
 char*
 ped_exception_get_type_string (PedExceptionType ex_type)
 {
-	return type_strings [ex_type - 1];
+	return (char *) type_strings [ex_type - 1];
 }
 
 /* FIXME: move this out to the prospective math.c */
@@ -121,7 +121,7 @@ ped_log2 (int n)
 char*
 ped_exception_get_option_string (PedExceptionOption ex_opt)
 {
-	return option_strings [ped_log2 (ex_opt)];
+	return (char *) option_strings [ped_log2 (ex_opt)];
 }
 
 static PedExceptionOption
@@ -243,8 +243,8 @@ ped_exception_throw (PedExceptionType ex_type,
 	ex->type = ex_type;
 	ex->options = ex_opts;
 
-	while (1) {
-			ex->message = (char*) malloc (size);
+	while (message) {
+			ex->message = (char*) malloc (size * sizeof (char));
 			if (!ex->message)
 					goto no_memory;
 
@@ -256,6 +256,7 @@ ped_exception_throw (PedExceptionType ex_type,
 					break;
 
 			size += 10;
+			ped_free (ex->message);
 	}
 
 	return do_throw ();
diff --git a/libparted/fs/ext2/ext2.c b/libparted/fs/ext2/ext2.c
index 618fca9..79fc6f6 100644
--- a/libparted/fs/ext2/ext2.c
+++ b/libparted/fs/ext2/ext2.c
@@ -727,7 +727,10 @@ struct ext2_fs *ext2_open(struct ext2_dev_handle *handle, int state)
 			    EXT2_FEATURE_RO_COMPAT_LARGE_FILE)))
 	{
 		ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
-		     _("File system has an incompatible feature enabled."));
+		     _("File system has an incompatible feature enabled.  "
+		       "Compatible features are has_journal, dir_index, "
+		       "filetype, sparse_super and large_file.  "
+		       "Use tune2fs or debugfs to remove features."));
 		goto error_free_fs;
 	}
 
diff --git a/libparted/fs/ext2/ext2_block_relocator.c b/libparted/fs/ext2/ext2_block_relocator.c
index b75a4c5..60f3d50 100644
--- a/libparted/fs/ext2/ext2_block_relocator.c
+++ b/libparted/fs/ext2/ext2_block_relocator.c
@@ -691,10 +691,11 @@ static int ext2_block_relocator_flush(struct ext2_fs *fs, struct ext2_block_relo
 		{
 			/* FIXXXME gross hack */
 			fprintf(stderr, "relocating %s blocks",
-				((char *[4]){"direct",
-						     "singly indirect",
-						     "doubly indirect",
-						     "triply indirect"})[i]);
+				((const char *const [4])
+				 {"direct",
+				  "singly indirect",
+				  "doubly indirect",
+				  "triply indirect"})[i]);
 			fflush(stderr);
 		}
 
diff --git a/libparted/fs/ext2/ext2_mkfs.c b/libparted/fs/ext2/ext2_mkfs.c
index 19931dd..b1a8ce3 100644
--- a/libparted/fs/ext2/ext2_mkfs.c
+++ b/libparted/fs/ext2/ext2_mkfs.c
@@ -1,6 +1,6 @@
 /*
     ext2_mkfs.c -- ext2 fs creator
-    Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
+    Copyright (C) 1999, 2000, 2001, 2007-2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -263,7 +263,7 @@ error:
 
 /* returns the offset into the buffer of the start of the next dir entry */
 static int _set_dirent(void* buf, int offset, int block_size, int is_last,
-		       uint32_t inode, char* name, int file_type)
+		       uint32_t inode, const char* name, int file_type)
 {
 	struct ext2_dir_entry_2 *dirent = (void*) (((char*)buf) + offset);
 	int name_len = strlen(name);
diff --git a/libparted/fs/fat/resize.c b/libparted/fs/fat/resize.c
index 7386948..5f24ec2 100644
--- a/libparted/fs/fat/resize.c
+++ b/libparted/fs/fat/resize.c
@@ -1,6 +1,6 @@
 /*
     libparted
-    Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
+    Copyright (C) 1998, 1999, 2000, 2007-2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -481,8 +481,8 @@ ask_type (PedFileSystem* fs, int fat16_ok, int fat32_ok, FatType* out_fat_type)
 {
 	FatSpecific*		fs_info = FAT_SPECIFIC (fs);
 	PedExceptionOption	status;
-	char*			fat16_msg;
-	char*			fat32_msg;
+	const char*		fat16_msg;
+	const char*		fat32_msg;
 
 	if (fs_info->fat_type == FAT_TYPE_FAT16)
 		fat16_msg = _("If you leave your file system as FAT16, "
diff --git a/libparted/fs/fat/traverse.c b/libparted/fs/fat/traverse.c
index 3d2e2b5..4ef2044 100644
--- a/libparted/fs/fat/traverse.c
+++ b/libparted/fs/fat/traverse.c
@@ -120,7 +120,7 @@ fat_traverse_mark_dirty (FatTraverseInfo* trav_info)
 
 FatTraverseInfo*
 fat_traverse_begin (PedFileSystem* fs, FatCluster start_cluster,
-		    char* dir_name)
+		    const char* dir_name)
 {
 	FatSpecific*		fs_info = FAT_SPECIFIC (fs);
 	FatTraverseInfo*	trav_info;
diff --git a/libparted/fs/fat/traverse.h b/libparted/fs/fat/traverse.h
index 21e4c27..afb24a5 100644
--- a/libparted/fs/fat/traverse.h
+++ b/libparted/fs/fat/traverse.h
@@ -42,7 +42,8 @@ extern int fat_traverse_entries_per_buffer (FatTraverseInfo* trav_info);
 /* starts traversal at an arbitary cluster.  if start_cluster==0, then uses
    root directory */
 extern FatTraverseInfo* fat_traverse_begin (PedFileSystem* fs,
-				     FatCluster start_cluster, char* dir_name);
+					    FatCluster start_cluster,
+					    const char* dir_name);
 
 extern int fat_traverse_complete (FatTraverseInfo* trav_info);
 
diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
index f25353b..ee9aba0 100644
--- a/libparted/labels/bsd.c
+++ b/libparted/labels/bsd.c
@@ -108,6 +108,9 @@ typedef struct {
 
 typedef struct {
 	uint8_t		type;
+	int			boot;
+	int			raid;
+	int			lvm;
 } BSDPartitionData;
 
 static PedDiskType bsd_disk_type;
@@ -394,6 +397,9 @@ bsd_partition_new (const PedDisk* disk, PedPartitionType part_type,
 		if (!bsd_data)
 			goto error_free_part;
 		bsd_data->type = 0;
+		bsd_data->boot = 0;
+		bsd_data->raid = 0;
+		bsd_data->lvm  = 0;
 	} else {
 		part->disk_specific = NULL;
 	}
@@ -423,6 +429,9 @@ bsd_partition_duplicate (const PedPartition* part)
 	old_bsd_data = (BSDPartitionData*) part->disk_specific;
 	new_bsd_data = (BSDPartitionData*) new_part->disk_specific;
 	new_bsd_data->type = old_bsd_data->type;
+	new_bsd_data->boot = old_bsd_data->boot;
+	new_bsd_data->raid = old_bsd_data->raid;
+	new_bsd_data->lvm = old_bsd_data->lvm;
 	return new_part;
 }
 
@@ -456,14 +465,60 @@ bsd_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
 static int
 bsd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
 {
-	/* no flags for bsd */
+	PedDisk*			disk;
+//	PedPartition*		walk; // since -Werror, this unused variable would break build
+	BSDPartitionData*	bsd_data;
+
+	PED_ASSERT (part != NULL, return 0);
+	PED_ASSERT (part->disk_specific != NULL, return 0);
+	PED_ASSERT (part->disk != NULL, return 0);
+
+	bsd_data = part->disk_specific;
+	disk = part->disk;
+
+	switch (flag) {
+		case PED_PARTITION_BOOT:
+			bsd_data->boot = state;
+			return 1;
+		case PED_PARTITION_RAID:
+			if (state) {
+				bsd_data->lvm = 0;
+			}
+			bsd_data->raid = state;
+			return 1;
+		case PED_PARTITION_LVM:
+			if (state) {
+				bsd_data->raid = 0;
+			}
+			bsd_data->lvm = state;
+		default:
+			;
+	}
 	return 0;
 }
 
 static int
 bsd_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
-	/* no flags for bsd */
+	BSDPartitionData*		bsd_data;
+
+	PED_ASSERT (part != NULL, return 0);
+	PED_ASSERT (part->disk_specific != NULL, return 0);
+
+	bsd_data = part->disk_specific;
+	switch (flag) {
+		case PED_PARTITION_BOOT:
+			return bsd_data->boot;
+
+		case PED_PARTITION_RAID:
+			return bsd_data->raid;
+
+		case PED_PARTITION_LVM:
+			return bsd_data->lvm;
+
+		default:
+			;
+	}
 	return 0;
 }
 
@@ -471,7 +526,14 @@ static int
 bsd_partition_is_flag_available (const PedPartition* part,
 				 PedPartitionFlag flag)
 {
-	/* no flags for bsd */
+	switch (flag) {
+		case PED_PARTITION_BOOT:
+		case PED_PARTITION_RAID:
+		case PED_PARTITION_LVM:
+			return 1;
+		default:
+			;
+	}
 	return 0;
 }
 
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index c686658..641257c 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -190,14 +190,16 @@ msdos_probe (const PedDevice *dev)
 	if (PED_LE16_TO_CPU (part_table->magic) != MSDOS_MAGIC)
 		goto probe_fail;
 
-	/* if this is a FAT fs, fail here.  Note that the Smart Boot Manager
-	 * Loader (SBML) signature indicates a partition table, not a file
-	 * system.
+	/* If this is a FAT fs, fail here.  Checking for the FAT signature
+	 * has some false positives; instead, do what the Linux kernel does
+	 * and ensure that each partition has a boot indicator that is
+	 * either 0 or 0x80.
 	 */
-	if ((!strncmp (part_table->boot_code + 0x36, "FAT", 3)
-	    && strncmp (part_table->boot_code + 0x40, "SBML", 4) != 0)
-	    || !strncmp (part_table->boot_code + 0x52, "FAT", 3))
-		goto probe_fail;
+	for (i = 0; i < 4; i++) {
+		if (part_table->partitions[i].boot_ind != 0
+		    && part_table->partitions[i].boot_ind != 0x80)
+			goto probe_fail;
+	}
 
 	/* If this is a GPT disk, fail here */
 	for (i = 0; i < 4; i++) {
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index e4ecf52..7adf12f 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -149,7 +149,7 @@ fdasd_error (fdasd_anchor_t *anc, enum fdasd_failure why, char * str)
 		case device_verification_failed:
 			sprintf(error, "fdasd: %s -- %s\n",
 				_("Device verification failed"),
-				_("The specified device is not a valid DASD device"));,
+				_("The specified device is not a valid DASD device"));
 			break;
 		default: 
 			sprintf(error, "fdasd: %s: %s\n", _("Fatal error"), str);
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 4dc4f10..cb90d11 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -4,7 +4,7 @@
     original version by Matt Domsch <Matt_Domsch@dell.com>
     Disclaimed into the Public Domain
 
-    Portions Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007
+    Portions Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2008
         Free Software Foundation, Inc.
 
     EFI GUID Partition Table handling
@@ -86,6 +86,10 @@ typedef struct {
     ((efi_guid_t) { PED_CPU_TO_LE32 (0xC12A7328), PED_CPU_TO_LE16 (0xF81F), \
     		    PED_CPU_TO_LE16 (0x11d2), 0xBA, 0x4B, \
 		    { 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B }})
+#define PARTITION_BIOS_GRUB_GUID \
+    ((efi_guid_t) { PED_CPU_TO_LE32 (0x21686148), PED_CPU_TO_LE16 (0x6449), \
+    		    PED_CPU_TO_LE16 (0x6E6f), 0x74, 0x4E, \
+		    { 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 }})
 #define LEGACY_MBR_PARTITION_GUID \
     ((efi_guid_t) { PED_CPU_TO_LE32 (0x024DEE41), PED_CPU_TO_LE16 (0x33E7), \
 		    PED_CPU_TO_LE16 (0x11d3, 0x9D, 0x69, \
@@ -245,6 +249,7 @@ typedef struct _GPTPartitionData {
 	int		lvm;
 	int		raid;
 	int		boot;
+	int		bios_grub;
 	int		hp_service;
         int             hidden;
         int             msftres;
@@ -753,13 +758,16 @@ _parse_part_entry (PedDisk* disk, GuidPartitionEntry_t* pte)
         
         gpt_part_data->lvm = gpt_part_data->raid 
                 = gpt_part_data->boot = gpt_part_data->hp_service
-                = gpt_part_data->hidden = gpt_part_data->msftres = 0;
+                = gpt_part_data->hidden = gpt_part_data->msftres
+                = gpt_part_data->bios_grub = 0;
 
         if (pte->Attributes.RequiredToFunction & 0x1)
                 gpt_part_data->hidden = 1;
        
 	if (!guid_cmp (gpt_part_data->type, PARTITION_SYSTEM_GUID))
 		gpt_part_data->boot = 1;
+	else if (!guid_cmp (gpt_part_data->type, PARTITION_BIOS_GRUB_GUID))
+		gpt_part_data->bios_grub = 1;
 	else if (!guid_cmp (gpt_part_data->type, PARTITION_RAID_GUID))
 		gpt_part_data->raid = 1;
 	else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
@@ -1130,6 +1138,7 @@ gpt_partition_new (const PedDisk* disk,
 	gpt_part_data->lvm = 0;
 	gpt_part_data->raid = 0;
 	gpt_part_data->boot = 0;
+	gpt_part_data->bios_grub = 0;
 	gpt_part_data->hp_service = 0;
         gpt_part_data->hidden = 0;
         gpt_part_data->msftres = 0;
@@ -1208,6 +1217,10 @@ gpt_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
 		gpt_part_data->type = PARTITION_SYSTEM_GUID;
 		return 1;
 	}
+	if (gpt_part_data->bios_grub) {
+		gpt_part_data->type = PARTITION_BIOS_GRUB_GUID;
+		return 1;
+	}
 	if (gpt_part_data->hp_service) {
 		gpt_part_data->type = PARTITION_HPSERVICE_GUID;
 		return 1;
@@ -1306,6 +1319,16 @@ gpt_partition_set_flag(PedPartition *part,
 		if (state)
                         gpt_part_data->raid 
                                 = gpt_part_data->lvm
+                                = gpt_part_data->bios_grub
+                                = gpt_part_data->hp_service
+                                = gpt_part_data->msftres = 0;
+		return gpt_partition_set_system (part, part->fs_type);
+	case PED_PARTITION_BIOS_GRUB:
+		gpt_part_data->bios_grub = state;
+		if (state)
+                        gpt_part_data->raid 
+                                = gpt_part_data->lvm
+                                = gpt_part_data->boot
                                 = gpt_part_data->hp_service
                                 = gpt_part_data->msftres = 0;
 		return gpt_partition_set_system (part, part->fs_type);
@@ -1314,6 +1337,7 @@ gpt_partition_set_flag(PedPartition *part,
 		if (state)
                         gpt_part_data->boot
                                 = gpt_part_data->lvm
+                                = gpt_part_data->bios_grub
                                 = gpt_part_data->hp_service
                                 = gpt_part_data->msftres = 0;
 		return gpt_partition_set_system (part, part->fs_type);
@@ -1322,6 +1346,7 @@ gpt_partition_set_flag(PedPartition *part,
 		if (state)
                         gpt_part_data->boot
                                 = gpt_part_data->raid
+                                = gpt_part_data->bios_grub
                                 = gpt_part_data->hp_service
                                 = gpt_part_data->msftres = 0;
 		return gpt_partition_set_system (part, part->fs_type);
@@ -1331,6 +1356,7 @@ gpt_partition_set_flag(PedPartition *part,
                         gpt_part_data->boot
                                 = gpt_part_data->raid
                                 = gpt_part_data->lvm
+                                = gpt_part_data->bios_grub
                                 = gpt_part_data->msftres = 0;
 		return gpt_partition_set_system (part, part->fs_type);
         case PED_PARTITION_MSFT_RESERVED:
@@ -1339,6 +1365,7 @@ gpt_partition_set_flag(PedPartition *part,
                         gpt_part_data->boot
                                 = gpt_part_data->raid
                                 = gpt_part_data->lvm
+                                = gpt_part_data->bios_grub
                                 = gpt_part_data->hp_service = 0;
                 return gpt_partition_set_system (part, part->fs_type);
         case PED_PARTITION_HIDDEN:
@@ -1367,6 +1394,8 @@ gpt_partition_get_flag(const PedPartition *part, PedPartitionFlag flag)
 		return gpt_part_data->lvm;
 	case PED_PARTITION_BOOT:
 		return gpt_part_data->boot;
+	case PED_PARTITION_BIOS_GRUB:
+		return gpt_part_data->bios_grub;
 	case PED_PARTITION_HPSERVICE:
 		return gpt_part_data->hp_service;
         case PED_PARTITION_MSFT_RESERVED:
@@ -1390,6 +1419,7 @@ gpt_partition_is_flag_available(const PedPartition * part,
 	case PED_PARTITION_RAID:
 	case PED_PARTITION_LVM:
 	case PED_PARTITION_BOOT:
+	case PED_PARTITION_BIOS_GRUB:
 	case PED_PARTITION_HPSERVICE:
         case PED_PARTITION_MSFT_RESERVED:
         case PED_PARTITION_HIDDEN:        
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index f014194..538e0c0 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 2000, 2002, 2004, 2007 Free Software Foundation, Inc.
+    Copyright (C) 2000, 2002, 2004, 2007-2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -376,19 +376,19 @@ mac_clobber (PedDevice* dev)
 #endif /* !DISCOVER_ONLY */
 
 static int
-_rawpart_cmp_type (MacRawPartition* raw_part, char* type)
+_rawpart_cmp_type (const MacRawPartition* raw_part, const char* type)
 {
 	return strncasecmp (raw_part->type, type, 32) == 0;
 }
 
 static int
-_rawpart_cmp_name (MacRawPartition* raw_part, char* name)
+_rawpart_cmp_name (const MacRawPartition* raw_part, const char* name)
 {
 	return strncasecmp (raw_part->name, name, 32) == 0;
 }
 
 static int
-_rawpart_is_partition_map (MacRawPartition* raw_part)
+_rawpart_is_partition_map (const MacRawPartition* raw_part)
 {
 	return _rawpart_cmp_type (raw_part, "Apple_partition_map");
 }
@@ -408,7 +408,7 @@ strncasestr (const char* haystack, const char* needle, int n)
 }
 
 static int
-_rawpart_is_boot (MacRawPartition* raw_part)
+_rawpart_is_boot (const MacRawPartition* raw_part)
 {
 	if (!strcasecmp(raw_part->type, "Apple_Bootstrap"))
 		return 1;
@@ -420,7 +420,7 @@ _rawpart_is_boot (MacRawPartition* raw_part)
 }
 
 static int
-_rawpart_is_driver (MacRawPartition* raw_part)
+_rawpart_is_driver (const MacRawPartition* raw_part)
 {
 	if (strncmp (raw_part->type, "Apple_", 6) != 0)
 		return 0;
@@ -430,7 +430,7 @@ _rawpart_is_driver (MacRawPartition* raw_part)
 }
 
 static int
-_rawpart_has_driver (MacRawPartition* raw_part, MacDiskData* mac_disk_data)
+_rawpart_has_driver (const MacRawPartition* raw_part, MacDiskData* mac_disk_data)
 {
 	MacDeviceDriver *driverlist;
 	uint16_t i, bsz;
diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index 12ad29f..d526207 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -3,13 +3,17 @@
 #
 # This file may be modified and/or distributed without restriction.
 
-TESTS = t1000-label.sh
+TESTS = t1000-label.sh t2000-disk.sh
 EXTRA_DIST = $(TESTS)
-bin_PROGRAMS     = label
+bin_PROGRAMS     = label disk
 label_CFLAGS    = $(CHECK_CFLAGS) -I$(top_srcdir)/include
 label_LDADD     = $(CHECK_LIBS) $(top_builddir)/libparted/libparted.la
 label_SOURCES   = common.h common.c label.c
 
+disk_CFLAGS    = $(CHECK_CFLAGS) -I$(top_srcdir)/include
+disk_LDADD     = $(CHECK_LIBS) $(top_builddir)/libparted/libparted.la
+disk_SOURCES   = common.h common.c disk.c
+
 MAINTAINERCLEANFILES = Makefile.in
 
 CLEANFILES = init.sh
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
new file mode 100644
index 0000000..295ec05
--- /dev/null
+++ b/libparted/tests/disk.c
@@ -0,0 +1,111 @@
+#include <config.h>
+#include <unistd.h>
+
+#include <check.h>
+
+#include <parted/parted.h>
+
+#include "common.h"
+
+static char* temporary_disk;
+
+static void
+create_disk (void)
+{
+        temporary_disk = _create_disk (20);
+        fail_if (temporary_disk == NULL, "Failed to create temporary disk");
+}
+
+static void
+destroy_disk (void)
+{
+        unlink (temporary_disk);
+        free (temporary_disk);
+}
+
+/* TEST: Create a disklabel on a simple disk image */
+START_TEST (test_duplicate)
+{
+        PedDevice* dev = ped_device_get (temporary_disk);
+        if (dev == NULL)
+                return;
+
+        PedDiskType* type;
+        PedDisk* disk;
+        PedDisk* disk_dup;
+        PedPartition *part;
+        PedPartition *part_dup;
+        PedConstraint *constraint;
+
+        int part_num[] = {1, 5, 6, 0};
+
+        disk = _create_disk_label (dev, ped_disk_type_get ("msdos"));
+
+        constraint = ped_constraint_any (dev);
+
+        /* Primary partition from 16,4kB to 15MB */
+        part = ped_partition_new (disk, PED_PARTITION_EXTENDED,
+                                  NULL,
+                                  32, 29311);
+        ped_disk_add_partition (disk, part, constraint);
+
+        /* Logical partition from 10MB to 15MB */
+        part = ped_partition_new (disk, PED_PARTITION_LOGICAL,
+                                  ped_file_system_type_get ("ext2"),
+                                  19584, 29311);
+        ped_disk_add_partition (disk, part, constraint);
+
+        /* Logical partition from 16,4kB to 4981kB */
+        part = ped_partition_new (disk, PED_PARTITION_LOGICAL,
+                                  ped_file_system_type_get ("ext2"),
+                                  32, 9727);
+        ped_disk_add_partition (disk, part, constraint);
+
+        ped_disk_commit (disk);
+
+        ped_constraint_destroy (constraint);
+
+        disk_dup = ped_disk_duplicate (disk);
+
+        /* Checks if both partitions match */
+        for (int *i = part_num; *i != 0; i++) {
+                part = ped_disk_get_partition (disk, *i);
+                part_dup = ped_disk_get_partition (disk_dup, *i);
+
+                fail_if (part->geom.start != part_dup->geom.start ||
+                         part->geom.end != part_dup->geom.end,
+                         "Duplicated partition %d doesn't match. "
+                         "Details are start: %d/%d end: %d/%d\n",
+                         *i, part->geom.start, part_dup->geom.start,
+                         part->geom.end, part_dup->geom.end);
+        }
+
+        ped_disk_destroy (disk);
+        ped_device_destroy (dev);
+}
+END_TEST
+
+int
+main (void)
+{
+        int number_failed;
+        Suite* suite = suite_create ("Disk");
+        TCase* tcase_duplicate = tcase_create ("Duplicate");
+
+        /* Fail when an exception is raised */
+        ped_exception_set_handler (_test_exception_handler);
+
+        tcase_add_checked_fixture (tcase_duplicate, create_disk, destroy_disk);
+        tcase_add_test (tcase_duplicate, test_duplicate);
+        /* Disable timeout for this test */
+        tcase_set_timeout (tcase_duplicate, 0);
+        suite_add_tcase (suite, tcase_duplicate);
+
+        SRunner* srunner = srunner_create (suite);
+        srunner_run_all (srunner, CK_VERBOSE);
+
+        number_failed = srunner_ntests_failed (srunner);
+        srunner_free (srunner);
+
+        return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/libparted/tests/t2000-disk.sh b/libparted/tests/t2000-disk.sh
new file mode 100755
index 0000000..7a85b98
--- /dev/null
+++ b/libparted/tests/t2000-disk.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+test_description='run the disk unit tests in a directory supporting O_DIRECT'
+# This wrapper around the ./label binary is used to find a directory
+# in which one can open a file with the O_DIRECT flag.
+
+. ./init.sh
+
+test_expect_success \
+    'run the actual tests' 'disk'
+
+test_done
diff --git a/parted/parted.c b/parted/parted.c
index 6a606ae..2afc2c1 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -79,7 +79,7 @@ typedef struct {
         time_t  predicted_time_left;
 } TimerContext;
 
-static struct option    options[] = {
+static const struct option const options[] = {
         /* name, has-arg, string-return-val, char-return-val */
         {"help",        0, NULL, 'h'},
         {"list",        0, NULL, 'l'},
@@ -90,7 +90,7 @@ static struct option    options[] = {
         {NULL,          0, NULL, 0}
 };
 
-static char*    options_help [][2] = {
+static const char *const options_help [][2] = {
         {"help",        N_("displays this help message")},
         {"list",        N_("lists partition layout on all block devices")},
         {"machine",     N_("displays machine parseable output")},
@@ -107,26 +107,26 @@ int     opt_machine_mode = 0;
 int     disk_is_modified = 0;
 int     is_toggle_mode = 0;
 
-static char* number_msg = N_(
+static const char* number_msg = N_(
 "NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the "
 "primary partitions number from 1 to 4, logical partitions from 5 onwards.\n");
 
-static char* label_type_msg_start = N_("LABEL-TYPE is one of: ");
-static char* flag_msg_start =   N_("FLAG is one of: ");
-static char* unit_msg_start =   N_("UNIT is one of: ");
-static char* part_type_msg =    N_("PART-TYPE is one of: primary, logical, "
+static const char* label_type_msg_start = N_("LABEL-TYPE is one of: ");
+static const char* flag_msg_start =   N_("FLAG is one of: ");
+static const char* unit_msg_start =   N_("UNIT is one of: ");
+static const char* part_type_msg =    N_("PART-TYPE is one of: primary, logical, "
                                    "extended\n");
-static char* fs_type_msg_start = N_("FS-TYPE is one of: ");
-static char* start_end_msg =    N_("START and END are disk locations, such as "
+static const char* fs_type_msg_start = N_("FS-TYPE is one of: ");
+static const char* start_end_msg =    N_("START and END are disk locations, such as "
                 "4GB or 10%.  Negative values count from the end of the disk.  "
                 "For example, -1s specifies exactly the last sector.\n");
-static char* state_msg =        N_("STATE is one of: on, off\n");
-static char* device_msg =       N_("DEVICE is usually /dev/hda or /dev/sda\n");
-static char* name_msg =         N_("NAME is any word you want\n");
-static char* resize_msg_start = N_("The partition must have one of the "
+static const char* state_msg =        N_("STATE is one of: on, off\n");
+static const char* device_msg =       N_("DEVICE is usually /dev/hda or /dev/sda\n");
+static const char* name_msg =         N_("NAME is any word you want\n");
+static const char* resize_msg_start = N_("The partition must have one of the "
                                    "following FS-TYPEs: ");
 
-static char* copyright_msg = N_(
+static const char* copyright_msg = N_(
 "Copyright (C) 1998 - 2006 Free Software Foundation, Inc.\n"
 "This program is free software, covered by the GNU General Public License.\n"
 "\n"
@@ -1226,7 +1226,7 @@ partition_print (PedPartition* part)
         putchar ('\n');
 
         flags = partition_print_flags (part);
-     
+
         printf (_("Minor: %d\n"), part->num);
         printf (_("Flags: %s\n"), flags);
         printf (_("File System: %s\n"), fs->type->name);
@@ -1264,15 +1264,17 @@ do_print (PedDevice** dev)
         int             has_free_arg = 0;
         int             has_list_arg = 0;
         int             has_num_arg = 0;
-        char*           transport[13] = {"unknown", "scsi", "ide", "dac960",
-                                         "cpqarray", "file", "ataraid", "i2o",
-                                         "ubd", "dasd", "viodasd", "sx8", "dm"};
+        const char *const transport[14] = {"unknown", "scsi", "ide", "dac960",
+					   "cpqarray", "file", "ataraid", "i2o",
+					   "ubd", "dasd", "viodasd", "sx8", "dm",
+					   "xvd"};
         char*           peek_word;
         char*           start;
         char*           end;
         char*           size;
         const char*     name;
         char*           tmp;
+        char*           flags;
         wchar_t*        table_rendered;
 
         disk = ped_disk_new (*dev);
@@ -1472,7 +1474,9 @@ do_print (PedDevice** dev)
                                     str_list_append (row, name);
                             }
 
-                            str_list_append (row, partition_print_flags (part));
+                            flags = partition_print_flags (part);
+                            str_list_append (row, flags);
+                            ped_free (flags);
                     } else {
                             if (has_extended)
                                     str_list_append (row, "");
@@ -1485,6 +1489,10 @@ do_print (PedDevice** dev)
                     //PED_ASSERT (row.cols == caption.cols)
                     table_add_row_from_strlist (table, row);
                     str_list_destroy (row);
+                    ped_free (tmp);
+                    ped_free (start);
+                    ped_free (end);
+                    ped_free (size);
             }
 
             table_rendered = table_render (table); 
diff --git a/parted/ui.c b/parted/ui.c
index a53643f..f854a54 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -154,17 +154,17 @@ struct siginfo_t {
 #  define ILL_BADSTK (INTMAX - 8)
 #endif
 
-char* prog_name = "GNU Parted " VERSION "\n";
+const char* prog_name = "GNU Parted " VERSION "\n";
 
-static char* banner_msg = N_(
+static const char* banner_msg = N_(
 "Welcome to GNU Parted! Type 'help' to view a list of commands.\n");
 
-static char* usage_msg = N_(
+static const char* usage_msg = N_(
 "Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]\n"
 "Apply COMMANDs with PARAMETERS to DEVICE.  If no COMMAND(s) are given, "
 "run in\ninteractive mode.\n");
 
-static char* bug_msg = N_(
+static const char* bug_msg = N_(
 "\n\nYou found a bug in GNU Parted! Here's what you have to do:\n\n"
 "Don't panic! The bug has most likely not affected any of your data.\n"
 "Help us to fix this bug by doing the following:\n\n"
@@ -218,7 +218,7 @@ screen_width ()
 
 /* HACK: don't specify termcap separately - it'll annoy the users. */
 #ifdef HAVE_LIBREADLINE
-        width = tgetnum ("co");
+        width = tgetnum ((char *) "co");
 #endif
 
         if (width <= 0)
@@ -569,7 +569,9 @@ _readline (const char* prompt, const StrList* possibilities)
                         fputs (line, stdout);
                         fflush (stdout);
 #endif
-                        line [strlen (line) - 1] = 0;    /* kill trailing CR */
+                        /* kill trailing NL */
+                        if (strlen (line))
+                                line [strlen (line) - 1] = 0;
                 } else {
                         free (line);
                         line = NULL;
diff --git a/parted/ui.h b/parted/ui.h
index f5cf760..77bb194 100644
--- a/parted/ui.h
+++ b/parted/ui.h
@@ -1,6 +1,6 @@
 /*
     parted - a frontend to libparted
-    Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
+    Copyright (C) 1999, 2000, 2001, 2007-2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
 
 #include "strlist.h"
 
-extern char*	prog_name;
+extern const char *prog_name;
 
 extern int init_ui ();
 extern int non_interactive_mode (PedDevice** dev, Command* cmd_list[],
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0a42a8d..3a694fe 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -5,8 +5,10 @@ TESTS = \
   t1100-busy-label.sh \
   t1500-small-ext2.sh \
   t2000-mkfs.sh \
+  t2200-dos-label-recog.sh \
   t3000-constraints.sh \
-  t3100-resize-ext2-partion.sh
+  t3100-resize-ext2-partion.sh \
+  t5000-tags.sh
 
 EXTRA_DIST = \
   $(TESTS) test-lib.sh mkdtemp
diff --git a/tests/t2200-dos-label-recog.sh b/tests/t2200-dos-label-recog.sh
new file mode 100755
index 0000000..d5d2670
--- /dev/null
+++ b/tests/t2200-dos-label-recog.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+test_description='improved MSDOS partition-table recognition'
+
+. ./init.sh
+
+######################################################################
+# With vestiges of a preceding FAT file system boot sector in the MBR,
+# parted 1.8.8.1.29 and earlier would fail to recognize a DOS
+# partition table.
+######################################################################
+N=100k
+dev=loop-file
+test_expect_success \
+    'create a file to simulate the underlying device' \
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
+
+test_expect_success \
+    'label the test disk' \
+    'parted -s $dev mklabel msdos > out 2>&1'
+test_expect_success 'expect no output' '$compare out /dev/null'
+
+test_expect_success \
+    'create two partition' \
+    '
+    parted -s $dev mkpart primary  1s 40s > out 2>&1 &&
+    parted -s $dev mkpart primary 41s 80s > out 2>&1
+
+    '
+test_expect_success 'expect no output' '$compare out /dev/null'
+
+test_expect_success \
+    'write "FAT" where it would cause trouble' \
+    'printf FAT|dd bs=1c seek=82 count=3 of=$dev conv=notrunc'
+
+test_expect_success \
+    'print the partition table' \
+    '
+    parted -m -s $dev unit s p > out &&
+    tail -2 out > k && mv k out &&
+    printf "1:1s:40s:40s:::;\n2:41s:80s:40s:::;\n" > exp
+
+    '
+test_expect_success 'expect two partitions' '$compare out exp'
+
+test_done
diff --git a/tests/t5000-tags.sh b/tests/t5000-tags.sh
new file mode 100755
index 0000000..dab48ae
--- /dev/null
+++ b/tests/t5000-tags.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+# Copyright (C) 2007,2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+test_description="test bios_grub flag in gpt labels"
+
+. ./init.sh
+
+dev=loop-file
+
+test_expect_success \
+    "setup: create zeroed device" \
+    '{ dd if=/dev/zero bs=1024 count=64; } > $dev'
+
+test_expect_success \
+    'create gpt label' \
+    'parted -s $dev mklabel gpt >out 2>&1'
+
+test_expect_success \
+    'add a partition' \
+    'parted -s $dev mkpart primary 0 1 >>out 2>&1'
+
+test_expect_success \
+    'print the table (before manual modification)' \
+    'parted -s $dev print >>out 2>&1'
+
+# Using bios_boot_magic='\x48\x61' looks nicer, but isn't portable.
+# dash's builtin printf doesn't recognize such \xHH hexadecimal escapes.
+bios_boot_magic='\110\141\150\41\111\144\157\156\164\116\145\145\144\105\106\111'
+
+printf "$bios_boot_magic" | dd of=$dev bs=1024 seek=1 conv=notrunc
+
+test_expect_success \
+    'print the table (after manual modification)' \
+    'parted -s $dev print >>out 2>&1'
+
+pwd=`pwd`
+
+fail=0
+{
+  cat <<EOF
+Model:  (file)
+Disk .../$dev: 65.5kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+
+Number  Start   End     Size    File system  Name     Flags
+ 1      17.4kB  48.6kB  31.2kB               primary       
+
+Model:  (file)
+Disk .../$dev: 65.5kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+
+Number  Start   End     Size    File system  Name     Flags    
+ 1      17.4kB  48.6kB  31.2kB               primary  bios_grub
+
+EOF
+} > exp || fail=1
+
+test_expect_success \
+    'prepare actual and expected output' \
+    'test $fail = 0 &&
+     mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'
+
+test_expect_success 'check for expected output' '$compare out exp'
+
+test_done