all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 98fbd3a8bf6476a6e7630ea39f40515a62137b6e 68086 bytes (raw)
name: gnu/packages/patches/mac-fdisk-p18.patch 	 # note: path name is non-authoritative(*)

   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
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
 
This is the result of unzipping the 0.1-18 diff.gz
https://cdn-aws.deb.debian.org/debian/pool/main/m/mac-fdisk/mac-fdisk_0.1-18.diff.gz

---
 Makefile             |   9 +-
 debian/README.debian |  18 +++
 debian/changelog     | 185 ++++++++++++++++++++++++++++++
 debian/compat        |   1 +
 debian/control       |  58 ++++++++++
 debian/copyright     |  25 +++++
 debian/postinst      |  50 +++++++++
 debian/rules         | 154 +++++++++++++++++++++++++
 dpme.h               |  11 +-
 dump.c               | 164 +++++++++++++++++----------
 fdisk.c              |  48 ++++----
 fdisklabel.c         |  15 +--
 fdisklabel.h         |   6 +
 io.c                 |  10 +-
 kernel-defs.h        |  64 +++++++++++
 mac-fdisk.8.in       | 262 +++++++++++++++++++++++++++++++++++++++++++
 partition_map.c      |  37 +++---
 partition_map.h      |   2 +
 pdisk.c              |  55 +++++++--
 pmac-fdisk.8.in      | 222 ++++++++++++++++++++++++++++++++++++
 20 files changed, 1281 insertions(+), 115 deletions(-)
 create mode 100644 debian/README.debian
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100644 debian/postinst
 create mode 100644 debian/rules
 create mode 100644 kernel-defs.h
 create mode 100644 mac-fdisk.8.in
 create mode 100644 pmac-fdisk.8.in

diff --git a/Makefile b/Makefile
index f26608f..0adf886 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,14 @@ pdisk: pdisk.o dump.o partition_map.o convert.o io.o errors.o bitfield.o
 fdisk: fdisk.o fdisklabel.o
 
 clean:
-	rm -f *.o pdisk fdisk
+	rm -f *.o pdisk fdisk mac-fdisk pmac-fdisk
+
+install: pdisk fdisk
+	-rm -f pmac-fdisk mac-fdisk
+	ln pdisk mac-fdisk
+	ln fdisk pmac-fdisk
+	install -o root -g root -m 0755 mac-fdisk ${DESTDIR}/sbin
+	install -o root -g root -m 0755 pmac-fdisk ${DESTDIR}/sbin
 
 distribution:
 	cd ..; tar cvf pdisk.src.tar.`date +%y%m%d` --files-from pdisk/list.src
diff --git a/debian/README.debian b/debian/README.debian
new file mode 100644
index 0000000..b9de127
--- /dev/null
+++ b/debian/README.debian
@@ -0,0 +1,18 @@
+mac-fdisk for DEBIAN
+----------------------
+
+Comments regarding mac-fdisk
+
+mac-fdisk provides Apple partition format utilities required for
+installation of Debian/68k on Apple Macintosh computers. The Debian version
+of mac-fdisk is derived from pdisk 0.4a2 (pdisk.970115.tar) by Eryk Vershen 
+(eryk@apple.com).
+pmac-fdisk is a version of the PC partition format utilities for PowerPC
+computers, taken from the same pdisk source version and can be used for
+installation of Debian/68k on PC partition format disks on Macintosh.
+
+Modifications have been made to the pdisk partition table output code to permit
+parsing the output of 'mac-fdisk -l' in a manner consistent with other Linux
+fdisk utilities. (Christiaan Welvaart, <>)
+
+Michael Schmitz <schmitz@lcbvax.cchem.berkeley.edu>, Sat, 28 Feb 1998 12:58:07 -0800
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..a6bc796
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,185 @@
+mac-fdisk (0.1-18) unstable; urgency=medium
+
+  * New maintainer:
+    - Set myself as maintainer in debian/control
+  * Add missing debian/compat, set to 9
+  * Stop building udeb packages:
+    - Remove references to {mac,pmac}-fdisk-udeb from debian/control
+    - Remove references to udeb packages from debian/rules
+  * Add missing pmac-fdisk-cross package to debian/control as it
+    is actually being built in debian/rules (Closes: #408341)
+  * Build cross packages on i386 as well (Closes: #202019)
+  * Add Vcs-Git and Vcs-Browser URLs to debian/control
+  * Set Priority to optional in debian/control
+  * Remove Priority extra for cross packages in debian/control
+  * Set Section utils for {mac,pmac}-fdisk in debian/control
+  * Remove unnecessary build dependencies coreutils and grep
+  * Update and amend long and short descriptions in debian/control
+  * Remove trailing white-spaces in debian/control
+  * Remove cruft and fix formatting in debian/changelog
+
+ -- John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>  Fri, 22 Sep 2017 16:12:01 +0200
+
+mac-fdisk (0.1-17) unstable; urgency=low
+
+  * Fix postinst failure - dpkg --print-installation-architecture
+    is no longer supported. Patch by Finn Thain <fthain@telegraphics.com.au>
+    Closes: #644845.
+
+ -- Michael Schmitz <schmitzmic@gmail.com>  Tue, 11 AUg 2017 15:49:23 +1200
+
+mac-fdisk (0.1-16) unstable; urgency=low
+
+  * Fix udeb shlib dependencies - patch by Frans Pop <elendil@planet.nl>
+    Closes: #562190.
+
+ -- Michael Schmitz <schmitz@debian.org>  Sun, 03 Jan 2010 13:47:27 +1200
+
+mac-fdisk (0.1-15) unstable; urgency=low
+
+  * Rebuild against current glibc to get rid of sys_errlist type size
+    warning (bug reported by Rick Thomas).
+    Closes: #451386.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Mon, 25 Sep 2005 14:50:13 +0100
+
+mac-fdisk (0.1-14) unstable; urgency=low
+
+  * Fix dpme.h u32 typedef which caused a mismatch between disk and memory
+    partition map format.
+    Closes: #389379.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Mon, 25 Sep 2005 14:50:13 +0100
+
+mac-fdisk (0.1-13) unstable; urgency=low
+
+  * Add patch for broken dpkg --print-gnu-build-architecture
+    (patch by Andreas Jochens <aj@andaco.de>).
+    Closes: #328102.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Wed, 14 Sep 2005 17:25:23 +0100
+
+mac-fdisk (0.1-12) unstable; urgency=low
+
+  * Add makefile support for ppc64 arch (patch by Andreas Jochens
+    <aj@andaco.de>).
+    Closes: #307897.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Mon, 09 May 2005 12:58:47 +0100
+
+mac-fdisk (0.1-11) unstable; urgency=low
+
+  * Big fat overdue cleanup - back in business after replacing my stolen
+    Powerbook.
+  * fixes as suggested in proposed NMU: changes mostly by Frank Lichtenheld
+    <djpig@debian.org>, with subarchitecture modifications by Colin Watson
+    <cjwatson@debian.org>.
+  * Copy needed kernel definitions from kernel-headers 2.4.25 (powerpc) and
+    2.4.26-m68k (cjwatson; Closes: #262457).
+  * Add Subarchitecture: fields in DEBIAN/control of the udebs. "mac" for
+    mac-fdisk-udeb on m68k, "powermac_oldworld powermac_newworld" for
+    mac-fdisk-udeb on powerpc, and "chrp chrp_pegasos prep iseries" for
+    pmac-fdisk-udeb on powerpc (djpig; Closes: #250581).
+  * Remove XSI:sms in debian/rules and debian/postinst, patch by David
+    Weinehall (djpig; Closes: #254918).
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Thu, 26 Aug 2004 14:23:13 +0200
+
+mac-fdisk (0.1-10) unstable; urgency=high
+
+  * Added .udeb magic to rules (kudos to Gaudenz Steinlin
+    <gaudenz@soziologie.ch>); kept mac-fdisk in /sbin though).
+    Closes: #188420.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Wed, 04 Jun 2003 17:06:02 +0200
+
+mac-fdisk (0.1-9) unstable; urgency=high
+
+  * Rebuilt with woody binutils to allow for prelinking. Closes: #176353.
+
+  * Set 'automagically mount on boot' flag when creating HFS partitions
+    (thanks to Derrick Pates <dpates@dsdk12.net> for finding the
+    undocumented bit!). Experimental, but this is unstable, right?
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Fri, 24 Jan 2003 16:20:20 +0200
+
+mac-fdisk (0.1-8) unstable; urgency=high
+
+  * Update mac-fdisk man page (kudos to Chris Tillman). Closes: #121928.
+
+  * Remove mac-fdisk-cross from control file; remove Sparc from Arch: entries
+    (to get rid of outdated mac-fdisk-cross 0.1-1 in the archive). Change
+    package descrption line for pmac-fdisk to emphasize it's a fdisk clone.
+
+  * Change sync() to ioctl(fd, BLKFLSBUF) to flush partition table to disk
+    on write - hopefully work around a kernel bug on new machines.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Fri, 07 Dec 2001 13:38:10 +0200
+
+mac-fdisk (0.1-7) unstable; urgency=high
+
+  * Bugfix: mac-fdisk didn't properly handle devfs device names. Mangle disk
+    name (.../disc) in dump routine to end in .../part%d (patch by Colin
+    Walters <walters@verbum.org>). Closes: #110056.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Mon, 04 Sep 2001 16:02:45 +0200
+
+mac-fdisk (0.1-6.0potato1) stable; urgency=high
+
+  * Feature added: menu option to create bootstrap partition needed for
+    powerpc NewWorld machines with the proper type and size (patch supplied
+    by Ethan Benson). This should help newbies that won't read the docs
+    anyway. Closes: #99660.
+
+  * Bugfix: mac-fdisk used to get the disk size wrong when brute force
+    probing for end-of-disk by seek&read. Turns out gcc did not cope with
+    arithmetics on long long types without explicit cast. Closes: #99700.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Fri, 15 Jun 2001 12:16:35 +0200
+
+mac-fdisk (0.1-6) unstable; urgency=high
+
+  * Feature added: menu option to create bootstrap partition needed for
+    powerpc NewWorld machines with the proper type and size (patch supplied
+    by Ethan Benson). This should help newbies that won't read the docs
+    anyway. Closes: #99660.
+
+  * Bugfix: mac-fdisk used to get the disk size wrong when brute force
+    probing for end-of-disk by seek&read. Turns out gcc did not cope with
+    arithmetics on long long types without explicit cast. Closes: #99700.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Mon, 04 Jun 2001 13:54:21 +0200
+
+mac-fdisk (0.1-5) unstable; urgency=low
+
+  * Bugfix: fix build problems for glibc 2.2 (remove string.h includes,
+    use lseek64 for llseek, fix some petty gcc warnings)
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Wed, 02 Mar 2001 19:42:01 +0200
+
+mac-fdisk (0.1-4) unstable; urgency=low
+
+  * Bugfix: correct off-by-one error on moving a partition downwards in the
+    partition map. Clarification of various program messages and prompts
+    (closes #69148, #69149 and #69152). Update of mac-fdisk man page.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Wed, 08 Oct 2000 17:49:07 +0200
+
+mac-fdisk (0.1-3) unstable; urgency=low
+
+  * PowerPC install fixes (work around lack of /proc/hardware), rename pmac-fdisk
+    package (previously pmac-fdisk-cross). Add pmac-fdisk man page.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Wed, 08 Mar 2000 18:29:07 +0200
+
+mac-fdisk (0.1-2) unstable; urgency=low
+
+  * Change man page name and install location, changed man page, rebuild for 2.2.
+
+ -- Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>  Fri, 22 Oct 1999 20:29:07 +0200
+
+mac-fdisk (0.1-1) unstable; urgency=low
+
+  * Initial Release. (built from previous pdisk-0.4a2 with fixes by Roman Hodek)
+
+ -- Michael Schmitz <schmitz@lcbvax.cchem.berkeley.edu>  Sat, 28 Feb 1998 21:58:07 -0800
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..b0e71d9
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,58 @@
+Source: mac-fdisk
+Section: base
+Priority: optional
+Build-Depends: debhelper
+Maintainer: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+Standards-Version: 3.5.8.0
+Vcs-Git: git://github.com/glaubitz/mac-fdisk-debian.git
+Vcs-Browser: https://github.com/glaubitz/mac-fdisk-debian
+
+Package: mac-fdisk
+Architecture: m68k powerpc ppc64
+Section: utils
+Depends: ${shlibs:Depends}
+Description: Apple disk partition manipulation tool
+ The fdisk utilities from the MkLinux project, adopted for Linux/m68k.
+ Mac-fdisk allows you to create and edit the partition table of a disk.
+ It supports only the Apple partition format used on Macintosh and PowerMac,
+ use pmac-fdisk for PC partition format disks as used on PowerPC machines.
+ Mac-fdisk is an interactive tool with a menu similar to PC fdisk, supported
+ options are somewhat different from PC fdisk due to the differences in
+ partition format.
+
+Package: pmac-fdisk
+Architecture: powerpc ppc64
+Section: utils
+Depends: ${shlibs:Depends}
+Description: Apple fdisk partition manipulation tool for PowerPC
+ The fdisk utilities from the MkLinux project, adopted for Linux/ppc.
+ Pmac-fdisk allows you to create and edit the partition table of a disk.
+ It supports the PC partition format as used on PowerPC. It is an
+ interactive tool similar to PC fdisk.
+
+Package: mac-fdisk-cross
+Architecture: i386 m68k
+Section: otherosfs
+Depends: ${shlibs:Depends}
+Description: Apple disk partition manipulation tool, cross version
+ The fdisk utilities from the MkLinux project, adopted for Linux/m68k.
+ Mac-fdisk allows you to create and edit the partition table of a disk.
+ It supports only the Apple partition format used on Macintosh and PowerMac,
+ use pmac-fdisk for PC partition format disks as used on PowerPC machines.
+ Mac-fdisk is an interactive tool with a menu similar to PC fdisk, supported
+ options are somewhat different from PC fdisk due to the differences in
+ partition format.
+ .
+ This package contains the cross version of the package.
+
+Package: pmac-fdisk-cross
+Architecture: i386 m68k
+Section: otherosfs
+Depends: ${shlibs:Depends}
+Description: fdisk partition manipulation tool for PowerPC, cross version
+ The fdisk utilities from the MkLinux project, adopted for Linux/ppc.
+ Pmac-fdisk allows you to create and edit the partition table of a disk.
+ It supports the PC partition format as used on PowerPC. It is an
+ interactive tool similar to PC fdisk.
+ .
+ This package contains the cross version of the package.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..9a1bd62
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,25 @@
+This package was debianized by Michael Schmitz schmitz@lcbvax.cchem.berkeley.edu on
+Sun, 11 Jan 1998 22:58:07 -0800.
+
+It was downloaded from ftp.mklinux.apple.com:/pub/Other_Tools/
+
+Copyright:
+
+ * Copyright 1996,1997 by Apple Computer, Inc.
+ *              All Rights Reserved 
+ *  
+ * Permission to use, copy, modify, and distribute this software and 
+ * its documentation for any purpose and without fee is hereby granted, 
+ * provided that the above copyright notice appears in all copies and 
+ * that both the copyright notice and this permission notice appear in 
+ * supporting documentation. 
+ *  
+ * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE. 
+ *  
+ * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 
+ * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
diff --git a/debian/postinst b/debian/postinst
new file mode 100644
index 0000000..4c4a47e
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,50 @@
+#! /bin/sh
+set -e
+
+Arch=`dpkg --print-architecture`
+
+#
+# make symlink /sbin/fdisk point to the native fdisk
+#
+
+# This is also true if /sbin/fdisk is a dangling symlink; in that case we
+# want to update the link, too.
+if [ ! -e /sbin/fdisk ]; then
+	machine=""
+	if [ "$Arch" = "m68k" ]; then
+		case `awk '$1 == "Model:" { print $2 }' /proc/hardware` in
+			Atari)
+				machine=atari
+				;;
+			Amiga)
+				machine=amiga
+				;;
+			Macintosh)
+				machine=mac
+				;;
+			Motorola) # MVME
+				;;
+		esac
+	elif [ "$Arch" = "powerpc" ]; then
+		# case `awk '$1 == "motherboard" { print $6 }' /proc/cpuinfo` in
+		# case `cat /proc/cpuinfo | grep -E "^motherboard" | sed -e 's/.* \([a-zA-Z]*\)$/\1/'` in
+		case `awk '$1 == "motherboard" { print $NF }' /proc/cpuinfo` in
+			Macintosh)
+				machine=mac
+				;;
+			*)
+				machine=pmac
+				;;
+		esac
+
+	fi
+	if [ -n "$machine" ] && [ -f /sbin/$machine-fdisk ]; then
+		ln -sf $machine-fdisk /sbin/fdisk
+	else
+		echo "No native fdisk for this machine type!"
+	fi
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/rules b/debian/rules
new file mode 100644
index 0000000..c978557
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,154 @@
+#!/usr/bin/make -f
+# Made with the aid of debmake, by Christoph Lameter,
+# based on the sample debian/rules file for GNU hello by Ian Jackson.
+
+export DH_VERBOSE=1
+
+#BUILDARCH = $(shell dpkg --print-gnu-build-architecture)
+BUILDARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU)
+POWERPC = $(findstring $(BUILDARCH),powerpc ppc64)
+
+packmn  = mac-fdisk
+packmc  = mac-fdisk-cross
+packpmn = pmac-fdisk
+packpmc = pmac-fdisk-cross
+tmpmn   = debian/tmp
+tmpmc   = debian/$(packmc)
+tmppmn  = debian/$(packpmn)
+tmppmc  = debian/$(packpmc)
+docmn   = $(tmpmn)/usr/share/doc/$(packmn)
+docmc   = $(tmpmc)/usr/share/doc/$(packmc)
+docpmn  = $(tmppmn)/usr/share/doc/$(packpmn)
+docpmc  = $(tmppmc)/usr/share/doc/$(packpmc)
+
+ifeq "$(BUILDARCH)" "powerpc"
+mac_subarches=powermac_oldworld powermac_newworld
+pmac_subarches=chrp chrp_pegasos prep iseries
+else
+mac_subarches=mac
+endif
+
+build:
+	$(checkdir)
+	make CFLAGS="-O2 -g -Wall"
+	touch build
+
+clean:
+	$(checkdir)
+	-rm -f build
+	-make clean
+	-rm -f `find . -name "*~"`
+	-rm -rf $(tmpmn) $(tmpmc) $(tmppmn) $(tmppmc) debian/files* core debian/*substvars
+
+binary-indep: build
+	$(checkdir)
+# There are no architecture-independent files to be uploaded
+# generated by this package.  If there were any they would be
+# made here.
+
+binary-arch: build
+	dh_testdir pdisk.h
+	dh_testroot
+	dh_clean -k
+	#dh_installdirs
+	# we don't want to package the pdisk man page
+	mv pdisk.8 pdisk.8.in
+	set -e; if [ "$(BUILDARCH)" = "m68k" ] || [ -n "$(POWERPC)" ]; then \
+		install -d $(tmpmn)/sbin; \
+		install -m 755 pdisk $(tmpmn)/sbin/mac-fdisk; \
+		install -d $(tmpmn)/usr/share/man/man8; \
+		install -m 644 mac-fdisk.8.in $(tmpmn)/usr/share/man/man8/mac-fdisk.8; \
+		dh_installdocs README -p$(packmn); \
+		dh_installmanpages -p$(packmn); \
+		dh_installchangelogs HISTORY -p$(packmn); \
+	else \
+		install -d $(tmpmc)/usr/sbin; \
+		install -m 755 pdisk $(tmpmc)/usr/sbin/mac-fdisk; \
+		install -d $(tmpmn)/usr/share/man/man8; \
+		install -m 644 mac-fdisk.8.in $(tmpmn)/usr/share/man/man8/mac-fdisk.8; \
+		dh_installdocs README -p$(packmc); \
+		dh_installmanpages  -p$(packmc); \
+		dh_installchangelogs HISTORY -p$(packmc); \
+	fi
+	set -e; if [ -n "$(POWERPC)" ]; then \
+		install -d $(tmppmn)/sbin; \
+		install -m 755 fdisk $(tmppmn)/sbin/pmac-fdisk; \
+		install -d $(tmppmn)/usr/share/man/man8; \
+		install -m 644 pmac-fdisk.8.in $(tmppmn)/usr/share/man/man8/pmac-fdisk.8; \
+		dh_installdocs README -p$(packpmn); \
+		dh_installmanpages  -p$(packpmn); \
+		dh_installchangelogs HISTORY -p$(packpmn); \
+	else \
+		install -d $(tmppmc)/usr/sbin; \
+		install -m 755 fdisk $(tmppmc)/usr/sbin/pmac-fdisk; \
+		install -d $(tmppmc)/usr/share/man/man8; \
+		install -m 644 pmac-fdisk.8.in $(tmppmc)/usr/share/man/man8/pmac-fdisk.8; \
+		dh_installdocs README -p$(packpmc); \
+		dh_installmanpages  -p$(packpmc); \
+		dh_installchangelogs HISTORY -p$(packpmc); \
+	fi
+	# install README.Debian also in cross package (not done by dh_installdocs)
+	set -e; if [ "$(BUILDARCH)" != "m68k" ] && ! [ -n "$(POWERPC)" ]; then \
+		install -m 644 debian/README.debian $(docmc)/README.Debian; \
+	fi
+	# and move the pdisk man page back again ...
+	mv pdisk.8.in pdisk.8
+
+	# build native pdisk only for m68k, cross package only for others
+	set -e; if [ "$(BUILDARCH)" = "m68k" ] || [ -n "$(POWERPC)" ]; then \
+		dh_strip -p$(packmn) -P$(tmpmn); \
+		dh_compress -p$(packmn) -P$(tmpmn); \
+		dh_fixperms -p$(packmn) -P$(tmpmn); \
+		dh_installdeb -p$(packmn) -P$(tmpmn); \
+		dh_shlibdeps -p$(packmn) -P$(tmpmn); \
+		dh_gencontrol -p$(packmn) -P$(tmpmn); \
+		dh_md5sums -p$(packmn) -P$(tmpmn); \
+	else \
+		dh_strip -p$(packmc); \
+		dh_compress -p$(packmc); \
+		dh_fixperms -p$(packmc); \
+		dh_installdeb -p$(packmc); \
+		dh_shlibdeps -p$(packmc); \
+		dh_gencontrol -p$(packmc); \
+		dh_md5sums -p$(packmc); \
+	fi
+	# build native fdisk only for powerpc, cross package only for others
+	set -e; if [ -n "$(POWERPC)" ]; then \
+		dh_strip -p$(packpmn); \
+		dh_compress -p$(packpmn); \
+		dh_fixperms -p$(packpmn); \
+		dh_installdeb -p$(packpmn); \
+		dh_shlibdeps -p$(packpmn); \
+		dh_gencontrol -p$(packpmn); \
+		dh_md5sums -p$(packpmn); \
+	else \
+		dh_strip -p$(packpmc); \
+		dh_compress -p$(packpmc); \
+		dh_fixperms -p$(packpmc); \
+		dh_installdeb -p$(packpmc); \
+		dh_shlibdeps -p$(packpmc); \
+		dh_gencontrol -p$(packpmc); \
+		dh_md5sums -p$(packpmc); \
+	fi
+	set -e; if [ "$(BUILDARCH)" = "m68k" ] || [ -n "$(POWERPC)" ]; then \
+		dh_builddeb -p$(packmn) -P$(tmpmn); \
+	else \
+		dh_builddeb -p$(packmc); \
+	fi
+	set -e; if [ -n "$(POWERPC)" ]; then \
+		dh_builddeb -p$(packpmn); \
+	else \
+		dh_builddeb -p$(packpmc); \
+	fi
+
+define checkdir
+	test -f debian/rules
+endef
+
+binary: binary-indep binary-arch
+
+checkroot:
+	$(checkdir)
+	test root = "`whoami`"
+
+.PHONY: binary binary-arch binary-indep clean checkroot
diff --git a/dpme.h b/dpme.h
index 2994266..c2a9958 100644
--- a/dpme.h
+++ b/dpme.h
@@ -61,7 +61,7 @@
 //
 typedef	unsigned char	u8;
 typedef	unsigned short	u16;
-typedef	unsigned long	u32;
+typedef	unsigned int	u32;
 
 
 // Physical block zero of the disk has this format
@@ -113,10 +113,17 @@ struct dpme {
 #endif
     u32     dpme_boot_block         ;
     u32     dpme_boot_bytes         ;
+#ifdef __linux__
+    u32     dpme_load_addr          ;
+    u32     dpme_load_addr_2        ;
+    u32     dpme_goto_addr          ;
+    u32     dpme_goto_addr_2        ;
+#else
     u8     *dpme_load_addr          ;
     u8     *dpme_load_addr_2        ;
     u8     *dpme_goto_addr          ;
     u8     *dpme_goto_addr_2        ;
+#endif
     u32     dpme_checksum           ;
     char    dpme_process_id[16]     ;
     u32     dpme_boot_args[32]      ;
@@ -124,6 +131,7 @@ struct dpme {
 };
 typedef struct dpme DPME;
 
+#define	dpme_automount_set(p, v)	bitfield_set(&p->dpme_flags, 30, 1, v) /* MSch */
 #define	dpme_os_specific_1_set(p, v)	bitfield_set(&p->dpme_flags, 8, 1, v)
 #define	dpme_os_specific_2_set(p, v)	bitfield_set(&p->dpme_flags, 7, 1, v)
 #define	dpme_os_pic_code_set(p, v)	bitfield_set(&p->dpme_flags, 6, 1, v)
@@ -134,6 +142,7 @@ typedef struct dpme DPME;
 #define	dpme_allocated_set(p, v)	bitfield_set(&p->dpme_flags, 1, 1, v)
 #define	dpme_valid_set(p, v)		bitfield_set(&p->dpme_flags, 0, 1, v)
 
+#define	dpme_automount_get(p)		bitfield_get(p->dpme_flags, 30, 1)	/* MSch */
 #define	dpme_os_specific_1_get(p)	bitfield_get(p->dpme_flags, 8, 1)
 #define	dpme_os_specific_2_get(p)	bitfield_get(p->dpme_flags, 7, 1)
 #define	dpme_os_pic_code_get(p)		bitfield_get(p->dpme_flags, 6, 1)
diff --git a/dump.c b/dump.c
index 61ad91b..4153dc5 100644
--- a/dump.c
+++ b/dump.c
@@ -3,7 +3,11 @@
 //
 // Written by Eryk Vershen (eryk@apple.com)
 //
-
+/*
+ * Linux/m68k version by Christiaan Welvaart
+ * minor fixes and glibc change by Michael Schmitz
+ */
+ 
 /*
  * Copyright 1996,1997 by Apple Computer, Inc.
  *              All Rights Reserved 
@@ -60,6 +64,7 @@ typedef struct names {
 //
 NAMES plist[] = {
     "Drvr", "Apple_Driver",
+    "Dr43", "Apple_Driver43",
     "Free", "Apple_Free",
     " HFS", "Apple_HFS",
     " MFS", "Apple_MFS",
@@ -83,7 +88,7 @@ const char * kStringNot		= " not";
 // Forward declarations
 //
 void dump_block_zero(partition_map_header *map);
-void dump_partition_entry(partition_map *entry, int digits);
+void dump_partition_entry(partition_map *entry, int digits, char *dev);
 
 
 //
@@ -119,6 +124,7 @@ dump_block_zero(partition_map_header *map)
     }
     printf("\nBlock size=%u, Number of Blocks=%u\n",
 	    p->sbBlkSize, p->sbBlkCount);
+#ifndef __mc68000__
     printf("DeviceType=0x%x, DeviceId=0x%x\n",
 	    p->sbDevType, p->sbDevId);
     if (p->sbDrvrCount > 0) {
@@ -130,6 +136,7 @@ dump_block_zero(partition_map_header *map)
 	}
     }
     printf("\n");
+#endif
 }
 
 
@@ -138,31 +145,50 @@ dump_partition_map(partition_map_header *map, int disk_order)
 {
     partition_map * entry;
     int j;
+    size_t len;
+    char *buf;
 
     if (map == NULL) {
 	bad_input("No partition map exists");
 	return;
     }
+#ifdef __mc68000__
+    printf("Disk %s\n", map->name);
+#else
     printf("%s\n", map->name);
+#endif
 
     j = number_of_digits(map->media_size);
     if (j < 7) {
 	j = 7;
     }
-    printf("   #:                 type name               "
-	    "%*s   %-*s ( size )\n", j, "length", j, "base");
+#ifdef __mc68000__
+    printf("%*s  type name         "
+	    "%*s   %-*s ( size )  system\n", strlen(map->name)+1, "#", j, "length", j, "base");
+#else
+    printf("%*s                    type name               "
+	    "%*s   %-*s ( size )  system\n", strlen(map->name)+1, "#", j, "length", j, "base");
+#endif
+
+    /* Grok devfs names. (courtesy Colin Walters)*/
+
+    len = strlen(map->name);
+    buf = strdup(map->name);
+    if (len >= 4 && !strcmp(buf+len-4, "disc")) {
+	strcpy(buf+len-4, "part");
+    }
 
     if (disk_order) {
 	for (entry = map->disk_order; entry != NULL;
 		entry = entry->next_on_disk) {
 
-	    dump_partition_entry(entry, j);
+	    dump_partition_entry(entry, j, buf);
 	}
     } else {
 	for (entry = map->base_order; entry != NULL;
 		entry = entry->next_by_base) {
 
-	    dump_partition_entry(entry, j);
+	    dump_partition_entry(entry, j, buf);
 	}
     }
     dump_block_zero(map);
@@ -170,18 +196,23 @@ dump_partition_map(partition_map_header *map, int disk_order)
 
 
 void
-dump_partition_entry(partition_map *entry, int digits)
+dump_partition_entry(partition_map *entry, int digits, char *dev)
 {
     partition_map_header *map;
     int j;
     DPME *p;
     BZB *bp;
     char *s;
+#ifdef __mc68000__
+    int aflag = 1;
+#else
     int aflag = 0;
+#endif
     int pflag = 1;
     u32 size;
     double bytes;
 
+
     map = entry->the_map;
     p = entry->data;
     if (aflag) {
@@ -192,9 +223,13 @@ dump_partition_entry(partition_map *entry, int digits)
 		break;
 	    }
 	}
-	printf("%4d: %.4s %-18.32s ", entry->disk_address, s, p->dpme_name);
+#ifdef __mc68000__
+	printf("%s%-2d %.4s %-12.12s ", dev, entry->disk_address, s, p->dpme_name);
+#else
+	printf("%s%-4d  %.4s %-18.32s ", dev, entry->disk_address, s, p->dpme_name);
+#endif
     } else {
-	printf("%4d: %20.32s %-18.32s ",
+	printf("%s%-4d %20.32s %-18.32s ", dev, 
 		entry->disk_address, p->dpme_type, p->dpme_name);
     }
 
@@ -217,7 +252,10 @@ dump_partition_entry(partition_map *entry, int digits)
 	printf("@~%-*u", digits, p->dpme_pblock_start + p->dpme_lblock_start);
     }
     
+    j = 's';
+
     bytes = size / ONE_KILOBYTE_IN_BLOCKS;
+    j = 'k';
     if (bytes >= 1024.0) {
 	bytes = bytes / 1024.0;
 	if (bytes < 1024.0) {
@@ -226,58 +264,45 @@ dump_partition_entry(partition_map *entry, int digits)
 	    bytes = bytes / 1024.0;
 	    j = 'G';
 	}
-	printf(" (%#5.1f%c)", bytes, j);
     }
+    printf(" (%#5.1f%c)  ", bytes, j);
 
-#if 0
-    // Old A/UX fields that no one pays attention to anymore.
-    bp = (BZB *) (p->dpme_bzb);
-    j = -1;
-    if (bp->bzb_magic == BZBMAGIC) {
-	switch (bp->bzb_type) {
-	case FSTEFS:
-	    s = "EFS";
-	    break;
-	case FSTSFS:
-	    s = "SFS";
-	    j = 1;
-	    break;
-	case FST:
-	default:
-	    if (bzb_root_get(bp) != 0) {
-		if (bzb_usr_get(bp) != 0) {
-		    s = "RUFS";
-		} else {
-		    s = "RFS";
-		}
-		j = 0;
-	    } else if (bzb_usr_get(bp) != 0) {
-		s = "UFS";
-		j = 2;
-	    } else {
-		s = "FS";
-	    }
-	    break;
-	}
-	if (bzb_slice_get(bp) != 0) {
-	    printf(" s%1d %4s", bzb_slice_get(bp)-1, s);
-	} else if (j >= 0) {
-	    printf(" S%1d %4s", j, s);
-	} else {
-	    printf("    %4s", s);
-	}
-	if (bzb_crit_get(bp) != 0) {
-	    printf(" K%1d", bp->bzb_cluster);
-	} else if (j < 0) {
-	    printf("   ");
-	} else {
-	    printf(" k%1d", bp->bzb_cluster);
-	}
-	if (bp->bzb_mount_point[0] != 0) {
-	    printf("  %.64s", bp->bzb_mount_point);
-	}
+    if (!strcmp(p->dpme_type, "Apple_UNIX_SVR2"))
+    {
+         if (!strcmp(p->dpme_name, "Swap") || !strcmp(p->dpme_name, "swap"))
+            printf("Linux swap");
+         else
+            printf("Linux native");
     }
-#endif
+    else
+    if (!strcmp(p->dpme_type, "Apple_Bootstrap"))
+         printf("NewWorld bootblock");
+    else
+    if (!strcmp(p->dpme_type, "Apple_Scratch"))
+         printf("Linux swap");  //not just linux, but who cares
+    else
+    if (!strcmp(p->dpme_type, "Apple_HFS"))
+         printf("HFS");
+    else
+    if (!strcmp(p->dpme_type, "Apple_MFS"))
+        printf("MFS");
+    else
+    if (!strcmp(p->dpme_type, "Apple_Driver"))
+        printf("Driver");
+    else
+    if (!strcmp(p->dpme_type, "Apple_Driver43"))
+        printf("Driver 4.3");
+    else
+    if (!strcmp(p->dpme_type, "Apple_partition_map"))
+        printf("Partition map");
+    else
+    if (!strcmp(p->dpme_type, "Apple_PRODOS"))
+        printf("ProDOS");
+    else
+    if (!strcmp(p->dpme_type, "Apple_Free"))
+        printf("Free space");
+    else
+        printf("Unknown");
     printf("\n");
 }
 
@@ -316,6 +341,24 @@ list_all_disks()
 
 	dump(name);
     }
+#ifdef __linux__
+    for (i = 0; i < 4; i++) {
+	sprintf(name, "/dev/hd%c", 'a'+i);
+	if ((fd = open_device(name, O_RDONLY)) < 0) {
+	    if (errno == EACCES) {
+		error(errno, "can't open file '%s'", name);
+	    }
+	    continue;
+	}
+	if (read_block(fd, 1, (char *)data, 1) == 0) {
+	    close_device(fd);
+	    continue;
+	}
+	close_device(fd);
+
+	dump(name);
+    }
+#endif
     free(data);
 }
 
@@ -385,7 +428,7 @@ u32     dpme_reserved_3[62]     ;
 	printf("%2d: %20.32s ",
 		entry->disk_address, p->dpme_type);
 	printf("%7u @ %-7u ", p->dpme_pblocks, p->dpme_pblock_start);
-	printf("%c%c%c%c%c%c%c%c%c ",
+	printf("%c%c%c%c%c%c%c%c%c%c ",
 		(dpme_valid_get(p))?'V':'v',
 		(dpme_allocated_get(p))?'A':'a',
 		(dpme_in_use_get(p))?'I':'i',
@@ -394,7 +437,8 @@ u32     dpme_reserved_3[62]     ;
 		(dpme_writable_get(p))?'W':'w',
 		(dpme_os_pic_code_get(p))?'P':'p',
 		(dpme_os_specific_1_get(p))?'1':'.',
-		(dpme_os_specific_2_get(p))?'2':'.');
+		(dpme_os_specific_2_get(p))?'2':'.',
+		(dpme_automount_get(p))?'M':'m');
 	if (p->dpme_lblock_start != 0 || p->dpme_pblocks != p->dpme_lblocks) {
 	    printf("(%u @ %u)", p->dpme_lblocks, p->dpme_lblock_start);
 	}
diff --git a/fdisk.c b/fdisk.c
index 11e92db..d77619b 100644
--- a/fdisk.c
+++ b/fdisk.c
@@ -62,7 +62,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <fcntl.h>
 #include <ctype.h>
 #include <setjmp.h>
@@ -71,9 +70,9 @@
 
 #include <sys/ioctl.h>
 
-#include <linux/genhd.h>
-#include <linux/hdreg.h>
-#include <linux/fs.h>
+typedef unsigned short kdev_t;	/* BAD hack; kdev_t is not exported */
+
+#include "kernel-defs.h"
 
 #include "fdisk.h"
 
@@ -428,7 +427,7 @@ void read_extended(struct partition *p)
 		offsets[partitions] = extended_offset + SWAP32(p->start_sect);
 		if (!extended_offset)
 			extended_offset = SWAP32(p->start_sect);
-		if (llseek(fd, (loff_t)offsets[partitions]
+		if (lseek64(fd, (loff_t)offsets[partitions]
 			       * SECTOR_SIZE, SEEK_SET) < 0)
 			fatal(unable_to_seek);
 		if (!(buffers[partitions] = (char *) malloc(SECTOR_SIZE)))
@@ -438,14 +437,14 @@ void read_extended(struct partition *p)
 		part_table[partitions] = ext_pointers[partitions] = NULL;
 		q = p = offset(buffers[partitions], 0);
 		for (i = 0; i < 4; i++, p++) {
-			if (p->sys_ind == EXTENDED)
+			if (p->sys_ind == EXTENDED) {
 				if (ext_pointers[partitions])
 					fprintf(stderr, "Warning: extra link "
 						"pointer in partition table "
 						"%d\n", partitions + 1);
 				else
 					ext_pointers[partitions] = p;
-			else if (p->sys_ind)
+			} else if (p->sys_ind) {
 				if (part_table[partitions])
 					fprintf(stderr,
 						"Warning: ignoring extra data "
@@ -453,15 +452,18 @@ void read_extended(struct partition *p)
 						partitions + 1);
 				else
 					part_table[partitions] = p;
+			}
 		}
-		if (!part_table[partitions])
+		if (!part_table[partitions]) {
 			if (q != ext_pointers[partitions])
 				part_table[partitions] = q;
 			else part_table[partitions] = q + 1;
-		if (!ext_pointers[partitions])
+		}
+		if (!ext_pointers[partitions]) {
 			if (q != part_table[partitions])
 				ext_pointers[partitions] = q;
 			else ext_pointers[partitions] = q + 1;
+		}
 		p = ext_pointers[partitions++];
 	}
 }
@@ -497,11 +499,12 @@ void get_boot(void)
 	warn_geometry();
 
 	for (i = 0; i < 4; i++)
-		if(part_table[i]->sys_ind == EXTENDED)
+		if(part_table[i]->sys_ind == EXTENDED) {
 			if (partitions != 4)
 				fprintf(stderr, "Ignoring extra extended "
 					"partition %d\n", i + 1);
 			else read_extended(part_table[ext_index = i]);
+		}
 
 	for (i = 3; i < partitions; i++)
 		if (SWAP16(*table_check(buffers[i])) != PART_TABLE_FLAG) {
@@ -621,6 +624,7 @@ uint read_int(uint low, uint dflt, uint high, enum offset base, char *mesg)
 			case lower: i += low; break;
 			case upper: i += high; break;
 			case deflt: i += dflt; break;
+			default: break;
 			}
 		}
 		else
@@ -844,12 +848,12 @@ static void check_consistency(struct partition *p, int partition)
 		return;		/* do not check extended partitions */
 
 /* physical beginning c, h, s */
-	pbc = p->cyl & 0xff | (p->sector << 2) & 0x300;
+	pbc = (p->cyl & 0xff) | ((p->sector << 2) & 0x300);
 	pbh = p->head;
 	pbs = p->sector & 0x3f;
 
 /* physical ending c, h, s */
-	pec = p->end_cyl & 0xff | (p->end_sector << 2) & 0x300;
+	pec = (p->end_cyl & 0xff) | ((p->end_sector << 2) & 0x300);
 	peh = p->end_head;
 	pes = p->end_sector & 0x3f;
 
@@ -941,7 +945,7 @@ void x_list_table(int extend)
 		disk_device, heads, sectors, cylinders);
         printf("Nr AF  Hd Sec  Cyl  Hd Sec  Cyl   Start    Size ID\n");
 	for (i = 0 ; i < partitions; i++)
-		if (p = q[i]) {
+		if ((p = q[i])) {
                         printf("%2d %02x%4d%4d%5d%4d%4d%5d%8d%8d %02x\n",
 				i + 1, p->boot_ind, p->head,
 				sector(p->sector),
@@ -1026,7 +1030,7 @@ void verify(void)
 				last[i]);
 			total += last[i] + 1 - first[i];
 			for (j = 0; j < i; j++)
-			if (first[i] >= first[j] && first[i] <= last[j]
+			if ((first[i] >= first[j] && first[i] <= last[j])
 					|| (last[i] <= last[j] &&
 					last[i] >= first[j])) {
 				printf("Warning: partition %d overlaps "
@@ -1060,11 +1064,11 @@ void verify(void)
 	if (total > heads * sectors * cylinders)
 		printf("Total allocated sectors %d greater than the maximum "
 			"%d\n", total, heads * sectors * cylinders);
-	else if (total = heads * sectors * cylinders - total)
+	else if ((total = heads * sectors * cylinders - total))
 		printf("%d unallocated sectors\n", total);
 }
 
-void add_partition(int n, int sys)
+static void add_partition(int n, int sys)
 {
 	char mesg[48];
 	int i, read = 0;
@@ -1100,11 +1104,12 @@ void add_partition(int n, int sys)
 		for (i = 0; i < partitions; i++) {
 			if (start == offsets[i])
 				start += sector_offset;
-			if (start >= first[i] && start <= last[i])
+			if (start >= first[i] && start <= last[i]) {
 				if (n < 4)
 					start = last[i] + 1;
 				else
 					start = last[i] + sector_offset;
+			}
 		}
 		if (start > limit)
 			break;
@@ -1249,7 +1254,7 @@ void write_table(void)
 	for (i = 3; i < partitions; i++)
 		if (changed[i]) {
 			*table_check(buffers[i]) = SWAP16(PART_TABLE_FLAG);
-			if (llseek(fd, (loff_t)offsets[i]
+			if (lseek64(fd, (loff_t)offsets[i]
 					* SECTOR_SIZE, SEEK_SET) < 0)
 				fatal(unable_to_seek);
 			if (write(fd, buffers[i], SECTOR_SIZE) != SECTOR_SIZE)
@@ -1262,7 +1267,7 @@ void write_table(void)
 	       "(Reboot to ensure the partition table has been updated.)\n");
 	sync();
 	sleep(2);
-	if (i = ioctl(fd, BLKRRPART)) {
+	if ((i = ioctl(fd, BLKRRPART))) {
                 error = errno;
         } else {
                 /* some kernel versions (1.2.x) seem to have trouble
@@ -1270,7 +1275,7 @@ void write_table(void)
 		   twice, the second time works. - biro@yggdrasil.com */
                 sync();
                 sleep(2);
-                if(i = ioctl(fd, BLKRRPART))
+                if((i = ioctl(fd, BLKRRPART)))
                         error = errno;
         }
 
@@ -1391,7 +1396,7 @@ void xselect(void)
 void try(char *device)
 {
 	disk_device = device;
-	if (!setjmp(listingbuf))
+	if (!setjmp(listingbuf)) {
 		if ((fd = open(disk_device, type_open)) >= 0) {
 			close(fd);
 			get_boot();
@@ -1407,6 +1412,7 @@ void try(char *device)
 		    exit(1);
 		 }
 	      }
+	}
 }
 
 void main(int argc, char **argv)
diff --git a/fdisklabel.c b/fdisklabel.c
index 9344339..70c3cfa 100644
--- a/fdisklabel.c
+++ b/fdisklabel.c
@@ -38,7 +38,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <fcntl.h>
 #include <ctype.h>
 #include <setjmp.h>
@@ -47,9 +46,7 @@
 #include <sys/ioctl.h>
 #include <sys/param.h>
 
-#include <linux/genhd.h>
-#include <linux/hdreg.h>
-#include <linux/fs.h>
+#include "kernel-defs.h"
 
 #include "fdisk.h"
 #define DKTYPENAMES
@@ -377,7 +374,7 @@ bsd_create_disklabel (void)
     {
 #if defined (i386)
       if (bsd_initlabel (bsd_part, &bsd_dlabel, bsd_part_index) == 1)
-#elif defined (__alpha__) || defined (__powerpc__)
+#elif defined (__alpha__) || defined (__powerpc__) || defined (__mc68000__)
       if (bsd_initlabel (NULL, &bsd_dlabel, 0) == 1)
 #endif
       {
@@ -515,7 +512,7 @@ bsd_write_bootstrap (void)
   alpha_bootblock_checksum (buffer);
 #endif
 
-  if (llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
+  if (lseek64 (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
     fatal (unable_to_seek);
   if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE))
     fatal (unable_to_write);
@@ -679,7 +676,7 @@ bsd_readlabel (struct partition *p, struct disklabel *d)
   sector = 0;
 #endif
 
-  if (llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
+  if (lseek64 (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
     fatal (unable_to_seek);
   if (BSD_BBSIZE != read (fd, buffer, BSD_BBSIZE))
     fatal (unable_to_read);
@@ -724,12 +721,12 @@ bsd_writelabel (struct partition *p, struct disklabel *d)
 
 #if defined (__alpha__) && BSD_LABELSECTOR == 0
   alpha_bootblock_checksum (buffer);
-  if (llseek (fd, 0, SEEK_SET) == -1)
+  if (lseek64 (fd, 0, SEEK_SET) == -1)
     fatal (unable_to_seek);
   if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE))
     fatal (unable_to_write);
 #else
-  if (llseek (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1)
+  if (lseek64 (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1)
     fatal (unable_to_seek);
   if (sizeof (struct disklabel) != write (fd, d, sizeof (struct disklabel)))
     fatal (unable_to_write);
diff --git a/fdisklabel.h b/fdisklabel.h
index 0b5227c..a9c4d2e 100644
--- a/fdisklabel.h
+++ b/fdisklabel.h
@@ -52,6 +52,12 @@
 #define BSD_LABELOFFSET   0
 #define	BSD_BBSIZE        0
 #define	BSD_SBSIZE        0
+#elif defined (__mc68000__)
+/* LABELSECTOR, LABELOFFSET, BBSIZE & SBSIZE are undefined for __powerpc__ */
+#define BSD_LABELSECTOR   0
+#define BSD_LABELOFFSET   0
+#define	BSD_BBSIZE        0
+#define	BSD_SBSIZE        0
 #else
 #error unknown architecture
 #endif
diff --git a/io.c b/io.c
index 0c99d94..0937e29 100644
--- a/io.c
+++ b/io.c
@@ -30,6 +30,10 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <SCSI.h>
+#else
+#ifdef __GLIBC__
+#include <sys/types.h>
+#endif
 #endif
 #include <unistd.h>
 #include <string.h>
@@ -51,6 +55,8 @@
 #define SCSI_FD 8
 #define loff_t long
 #define llseek lseek
+#else
+#define llseek lseek64
 #endif
 
 
@@ -435,8 +441,8 @@ read_block(int fd, unsigned long num, char *buf, int quiet)
 #else
     {
 #endif
-	x = num * PBLOCK_SIZE;
-	if ((x = llseek(fd, x, 0)) < 0) {
+	x = ((long long) num * PBLOCK_SIZE); /* cast to ll to work around compiler bug */
+	if ((x = lseek64(fd, x, 0)) < 0) {
 	    if (quiet == 0) {
 		error(errno, "Can't seek on file");
 	    }
diff --git a/kernel-defs.h b/kernel-defs.h
new file mode 100644
index 0000000..5f15fd4
--- /dev/null
+++ b/kernel-defs.h
@@ -0,0 +1,64 @@
+/* from asm/types.h */
+typedef unsigned short __u16;
+typedef unsigned int __u32;
+
+/* from linux/hdreg.h */
+#define HDIO_GETGEO		0x0301	/* get device geometry */
+
+struct hd_geometry {
+      unsigned char heads;
+      unsigned char sectors;
+      unsigned short cylinders;
+      unsigned long start;
+};
+
+/* from asm/ioctl.h */
+#define _IOC_NRBITS	8
+#define _IOC_TYPEBITS	8
+#define _IOC_SIZEBITS	13
+#define _IOC_DIRBITS	3
+
+#define _IOC_NRMASK	((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK	((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK	((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK	((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT	0
+#define _IOC_TYPESHIFT	(_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT	(_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT	(_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+#ifdef __powerpc__
+#define _IOC_NONE	1U
+#define _IOC_READ	2U
+#define _IOC_WRITE	4U
+#else
+#define _IOC_NONE	0U
+#define _IOC_READ	2U
+#define _IOC_WRITE	1U
+#endif
+
+#define _IOC(dir,type,nr,size) \
+	(((dir)  << _IOC_DIRSHIFT) | \
+	 ((type) << _IOC_TYPESHIFT) | \
+	 ((nr)   << _IOC_NRSHIFT) | \
+	 ((size) << _IOC_SIZESHIFT))
+#define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)
+
+/* from linux/fs.h */
+#define BLKRRPART  _IO(0x12,95)      /* re-read partition table */
+#define BLKFLSBUF  _IO(0x12,97)      /* flush buffer cache */
+
+/* from linux/genhd.h */
+struct partition {
+	unsigned char boot_ind;		/* 0x80 - active */
+	unsigned char head;		/* starting head */
+	unsigned char sector;		/* starting sector */
+	unsigned char cyl;		/* starting cylinder */
+	unsigned char sys_ind;		/* What partition type */
+	unsigned char end_head;		/* end head */
+	unsigned char end_sector;	/* end sector */
+	unsigned char end_cyl;		/* end cylinder */
+	unsigned int start_sect;	/* starting sector counting from 0 */
+	unsigned int nr_sects;		/* nr of sectors in partition */
+} __attribute__((packed));
diff --git a/mac-fdisk.8.in b/mac-fdisk.8.in
new file mode 100644
index 0000000..31e3643
--- /dev/null
+++ b/mac-fdisk.8.in
@@ -0,0 +1,262 @@
+.TH MAC-FDISK 8 "1 December 2001" "Debian" "Apple Disk Partitioning Manual"
+.SH NAME
+mac-fdisk \- Apple partition table editor for Linux
+.SH SYNOPSIS
+.B mac-fdisk
+.B "[ \-h | \--help ] [ \-v | \--version ] [ \-l | \--list device ... ]"
+.br
+.B mac-fdisk
+.B "[ \-r | \--readonly ] device ... "
+.SH DESCRIPTION
+.B mac-fdisk
+is a command line type program which partitions disks using the standard Apple
+disk partitioning scheme described in "Inside Macintosh: Devices".
+The
+.I device
+is usually one of the following:
+
+.nf
+.RS
+/dev/sda
+/dev/sdb
+/dev/sdc
+/dev/sdd
+/dev/sde
+/dev/sdf
+/dev/sdg
+/dev/hda
+/dev/hdb
+
+.RE
+.fi
+/dev/sda is the first hard disk on the SCSI bus (i.e. the
+one with the lowest id), /dev/sdb is the second hard disk, and so on.
+The
+.I partition
+is a
+.I device
+name followed by a partition number.
+The partition number is the index (starting from one) of the partition
+map entry in the partition map (and the partition map itself occupies the
+first entry).
+For example,
+.B /dev/sda2
+is the partition described by the second entry in the partiton map on /dev/sda.
+
+.SH OPTIONS
+.TP
+.B \-v | \--version
+Prints version number of the
+.B mac-fdisk
+program.
+.TP
+.B \-h | \--help
+Prints a list of available commands for the
+.B mac-fdisk
+program.
+.TP
+.B \-l | \--list
+Lists the partition tables for the specified
+.IR device(s).
+With no 
+.IR device(s)
+given, lists all SCSI and IDE devices found in the system.
+.TP
+.B \-r | \--readonly
+Prevents
+.B mac-fdisk
+from writing to the device.
+.SH "Editing Partition Tables"
+An argument which is simply the name of a
+.I device
+indicates that
+.B mac-fdisk
+should edit the partition table of that device. Once started, 
+.B mac-fdisk 
+presents an interactive command prompt to edit the partition table. 
+The partition editing commands are:
+
+.nf
+.RS
+h    list available commands
+p    print (list) the current edited partition table status
+P    print ordered by base address
+i    initialize the partition map
+s    change size of partition map
+b    create new 800K Apple_Bootstrap partition (used by yaboot)
+c    create new standard Linux type partition
+C    create new partition, specifying the partition type
+d    delete a partition
+r    reorder partition entry
+w    write the partition table to disk
+q    quit 
+
+.RE
+.fi
+Commands which take arguments prompt for each argument in turn.
+You can also type the arguments separated by spaces
+and those prompts will be skipped. The
+.B i
+and
+.B w
+commands will prompt for confirmation. None of the editing you do will 
+actually affect the state of the disk you are partitioning until the 
+.B w 
+command is issued. Then the map in its edited state will be 
+permanently written to the disk.
+
+Partitions are always specified by their number, the index of the
+partition entry in the partition map.  Many commands will change the
+index numbers of partitions which follow the affected partition; you are
+encouraged to use the 
+.B p
+command to print the partition table as frequently as necessary. For SCSI
+disks, the partition table should not contain more than fifteen partitions 
+(partition map excluded). IDE disks have a limit of 31 partitions.
+
+Here is a more-or-less typical output for the print command:
+
+.nf
+.RS
+Command (? for help): p
+/dev/sdb
+        #                type name              length   base    ( size )  system
+/dev/sdb1 Apple_partition_map Apple                 63 @ 1       ( 31.5k)  Partition map
+/dev/sdb2      Apple_Driver43 Macintosh             54 @ 64      ( 27.0k)  Driver 4.3
+/dev/sdb3      Apple_Driver43 Macintosh             74 @ 118     ( 37.0k)  Driver 4.3
+/dev/sdb4  Apple_Driver_IOKit Macintosh            512 @ 192     (256.0k)  Unknown
+/dev/sdb5       Apple_Patches Patch Partition      512 @ 704     (256.0k)  Unknown
+/dev/sdb6           Apple_HFS untitled         3072000 @ 1216    (  1.5G)  HFS
+/dev/sdb7           Apple_HFS untitled 2        333026 @ 3073216 (162.6M)  HFS
+/dev/sdb8          Apple_Free Extra                 10 @ 3406242 (  5.0k)  Free space
+
+Block size=512, Number of Blocks=3406252
+DeviceType=0x0, DeviceId=0x0
+Drivers-
+1: @ 64 for 22, type=0x1
+2: @ 118 for 36, type=0xffff
+
+.RE
+.fi
+
+The
+.B i
+(initialize) command prompts for the size of the device.  You can just
+type Return to accept the offered size, which should be correct.
+
+The
+.B b
+command is a shortcut to create the bootstrap partition used on PowerPC
+NewWorld machines. It is equivalent to creating an 800k
+.B Apple_Bootstrap
+type partition using the 
+.B C
+command described below. The sole purpose of this partition is to
+store the boot loader. In multiboot environments, the first bootable
+partition found on the disk takes precedence unless a specific boot
+partition is set in OpenFirmware, so it's best to create the bootstrap
+partition first, or move it to a position before any
+.B Apple_HFS 
+or 
+.B Apple_Boot
+partitions using the 
+.B r
+command described below. Then you will still able to boot Linux after
+the occasional OpenFirmware reset.
+
+The
+.B c
+(create new partition) command has three arguments. As mentioned
+above you can type the arguments following the command, separated by
+spaces, or respond to prompts for each argument:
+
+  1) The base address of the start of the partition.
+
+     You can specify a number in blocks (most likely reading from the
+     existing partition map) or you can also type a partition number
+     followed by the letter 'p' to indicate that the new partition
+     should take the place of that existing free space partition.
+
+  2) The length of the partition.
+
+     Again, you can specify a number in blocks or type a partition
+     number followed by the letter 'p' to indicate use of the entire
+     partition. You can also type a number followed by 'k', 'm', or
+     'g' to indicate the size in kilobytes, megabytes, or gigabytes
+     respectively. (These are powers of 1024, of course, not powers
+     of 1000.)
+
+  3) The name of the partition.
+
+     This can be a single word without quotes, or a string surrounded
+     by single or double quotes. It is best to name any swap partition
+     you create `swap'; other partition names are up to you. The names
+     are not visible to Linux.
+
+The
+.B C
+command is identical to the
+.B c
+command, with the addition of a partition type argument after the
+other arguments. The partition type used for Linux swap and data partitons
+is 
+.B APPLE_UNIX_SVR2
+(this is the partition type created by the 
+.B c
+command). Under normal circumstances, you should not need to use this
+command.
+
+The
+.B d
+command deletes the partition number specified, replacing that partition 
+with partitionable free space.
+
+The
+.B r
+(reorder) command allows the index number of partitions to be changed.
+The index numbers are constrained to be a contiguous sequence. 
+.B mac-fdisk
+will enforce this constraint by recalculating the partition numbers
+after each insert, delete or reorder operation. OpenFirmware looks for
+bootable partitions in the order specified by the index. The
+partitions are not moved on the disk. This command takes two
+arguments, the number of the partition to be moved and the partition
+number it should become.
+
+The
+.B w
+command writes the partition map out to disk. Note that partition
+maps for disks with mounted partitions cannot immediately be
+reinterpreted by the kernel. In order to use the new partition map you
+must reboot. Within the Debian installer system, 
+.B mac-fdisk 
+is normally invoked before any partitions are mounted, thus a reboot is not 
+necessary before continuing the installation.
+
+The
+.B q
+command terminates the program. If there was no 
+.B w
+command issued during the program run, then there will be no effect on the disk.
+
+.SH BUGS
+Some people believe there should really be just one disk partitioning utility.
+
+.B mac-fdisk
+should be able to create HFS partitions that work. Currently, if a
+pre-existing HFS partition is resized, MacOS will continue to use the
+partition size stored in the HFS 'superblock' instead of using the size from
+the partition table (the MacOS volume on the partition remains valid even
+though the sizes don't match anymore). This can have undesired side effects
+especially when creating a smaller HFS partition followed by a few Linux 
+partitions in place of the previous HFS partition space. To avoid this 
+issue, create MacOS partitions within MacOS and then don't resize them 
+in 
+.B mac-fdisk.
+
+.SH "SEE ALSO"
+.BR fdisk (8), 
+.BR mkswap (8),
+.BR mkfs (8)
+.SH AUTHOR
+Eryk Vershen (eryk@apple.com), man page revised by Chris Tillman (tillman@azstarnet.com)
diff --git a/partition_map.c b/partition_map.c
index 113f66b..6ca2c16 100644
--- a/partition_map.c
+++ b/partition_map.c
@@ -30,14 +30,12 @@
 #include <stdlib.h>
 #include <unistd.h>
 #endif
-#include <string.h>
 #include <errno.h>
 
 #include <fcntl.h>
 #ifdef __linux__
 #include <sys/ioctl.h>
-#include <linux/fs.h>
-#include <linux/hdreg.h>
+#include "kernel-defs.h"
 #include <sys/stat.h>
 #endif
 
@@ -65,6 +63,8 @@
 const char * kFreeType	= "Apple_Free";
 const char * kMapType	= "Apple_partition_map";
 const char * kUnixType	= "Apple_UNIX_SVR2";
+const char * kBootstrapType = "Apple_Bootstrap";
+const char * kBootstrapName = "bootstrap";
 
 const char * kFreeName = "Extra";
 
@@ -288,15 +288,17 @@ write_partition_map(partition_map_header *map)
 	    free(block);
 	}
     }
-    printf("The partition table has been altered!\n\n");
+    printf("The partition map has been saved successfully!\n\n");
 
 #ifdef __linux__
     if (map->regular_file) {
 	close_device(map->fd);
     } else {
-	// printf("Calling ioctl() to re-read partition table.\n"
-	//       "(Reboot to ensure the partition table has been updated.)\n");
-	sync();
+	// printf("Calling ioctl() to re-read partition table.\n");
+	if ((i = ioctl(fd, BLKFLSBUF)) != 0) {
+	    perror("ioctl(BLKFLSBUF)");
+	    sync();
+	}
 	sleep(2);
 	if ((i = ioctl(fd, BLKRRPART)) != 0) {
 	    saved_errno = errno;
@@ -304,20 +306,26 @@ write_partition_map(partition_map_header *map)
 	    // some kernel versions (1.2.x) seem to have trouble
 	    // rereading the partition table, but if asked to do it
 	    // twice, the second time works. - biro@yggdrasil.com */
-	    sync();
+	    // printf("Again calling ioctl() to re-read partition table.\n");
+	    if ((i = ioctl(fd, BLKFLSBUF)) != 0) {
+	    	perror("ioctl(BLKFLSBUF)");
+		sync();
+	    }
 	    sleep(2);
 	    if ((i = ioctl(fd, BLKRRPART)) != 0) {
 		saved_errno = errno;
 	    }
 	}
+	printf("Syncing disks.\n");
+	if ((i = ioctl(fd, BLKFLSBUF)) != 0) {
+	    perror("ioctl(BLKFLSBUF)");
+	    sync();
+	}
 	close_device(map->fd);
-
-	// printf("Syncing disks.\n");
-	sync();
 	sleep(4);		/* for sync() */
 
 	if (i < 0) {
-	    error(saved_errno, "Re-read of partition table failed");
+	    error(saved_errno, "Re-read of partition map failed");
 	    printf("Reboot your system to ensure the "
 		    "partition table is updated.\n");
 	}
@@ -692,9 +700,9 @@ compute_device_size(int fd)
 		geometry.heads*geometry.sectors*geometry.cylinders);
     }
 
-    if ((pos = llseek(fd, 0, SEEK_END)) < 0) {
+    if ((pos = lseek64(fd, 0, SEEK_END)) < 0) {
 	printf("llseek to end of device failed\n");
-    } else if ((pos = llseek(fd, 0, SEEK_CUR)) < 0) {
+    } else if ((pos = lseek64(fd, 0, SEEK_CUR)) < 0) {
 	printf("llseek to end of device failed on second try\n");
     } else {
 	printf("llseek: pos = %d, blocks=%d\n", pos, pos/PBLOCK_SIZE);
@@ -895,6 +903,7 @@ move_entry_in_map(long old_index, long index, partition_map_header *map)
 	printf("No such partition\n");
     } else {
 	remove_from_disk_order(cur);
+	if (old_index < index) index++; /* renumber_disk_addresses(map); */
 	cur->disk_address = index;
 	insert_in_disk_order(cur);
 	renumber_disk_addresses(map);
diff --git a/partition_map.h b/partition_map.h
index 90f2210..526f605 100644
--- a/partition_map.h
+++ b/partition_map.h
@@ -69,6 +69,8 @@ typedef struct partition_map partition_map;
 extern const char * kFreeType;
 extern const char * kMapType;
 extern const char * kUnixType;
+extern const char * kBootstrapType;
+extern const char * kBootstrapName;
 
 extern const char * kFreeName;
 
diff --git a/pdisk.c b/pdisk.c
index 52f98c7..a9bc629 100644
--- a/pdisk.c
+++ b/pdisk.c
@@ -30,18 +30,17 @@
 #include <stdio.h>
 #ifdef __linux__
 #include <getopt.h>
+#include <stddef.h>
 #else
 #include <stdlib.h>
 #include <unistd.h>
 #include <SIOUX.h>
 #endif
-#include <string.h>
 #include <errno.h>
 
 #ifdef __linux__
 #include <sys/ioctl.h>
-#include <linux/fs.h>
-#include <linux/hdreg.h>
+#include "kernel-defs.h"
 #endif
 
 #include "pdisk.h"
@@ -94,6 +93,7 @@ int rflag;
 void do_add_intel_partition(partition_map_header *map);
 void do_change_map_size(partition_map_header *map);
 void do_create_partition(partition_map_header *map, int get_type);
+void do_create_bootstrap_partition(partition_map_header *map);
 void do_delete_partition(partition_map_header *map);
 int do_expert(partition_map_header *map);
 void do_reorder(partition_map_header *map);
@@ -114,6 +114,7 @@ int
 main(int argc, char **argv)
 {
     int name_index;
+    int err=0;
 
     if (sizeof(DPME) != PBLOCK_SIZE) {
 	fatal(-1, "Size of partion map entry (%d) "
@@ -150,7 +151,9 @@ main(int argc, char **argv)
     } else if (!vflag) {
 	usage("no device argument");
  	do_help();
+	err=-EINVAL;	// debatable
     }
+    exit(err);
 }
 #else
 main()
@@ -351,7 +354,8 @@ edit(char *name)
 	    printf("  P    (print ordered by base address)\n");
 	    printf("  i    initialize partition map\n");
 	    printf("  s    change size of partition map\n");
-	    printf("  c    create new partition\n");
+	    printf("  b    create new 800K bootstrap partition\n");
+	    printf("  c    create new Linux partition\n");
 	    printf("  C    (create with type also specified)\n");
 	    printf("  d    delete a partition\n");
 	    printf("  r    reorder partition entry in map\n");
@@ -378,6 +382,10 @@ edit(char *name)
 	case 'i':
 	    map = init_partition_map(name, map);
 	    break;
+	case 'B':
+	case 'b':
+	    do_create_bootstrap_partition(map);
+	    break;
 	case 'C':
 	    get_type = 1;
 	    // fall through
@@ -471,6 +479,30 @@ do_create_partition(partition_map_header *map, int get_type)
 }
 
 
+void
+do_create_bootstrap_partition(partition_map_header *map)
+{
+    long base;
+
+    if (map == NULL) {
+	bad_input("No partition map exists");
+	return;
+    }
+ 
+    if (!rflag && map->writeable == 0) {
+	printf("The map is not writeable.\n");
+    }
+
+    // XXX add help feature (i.e. '?' in any argument routine prints help string)
+    if (get_base_argument(&base, map) == 0) {
+	return;
+    }
+
+    // create 800K type Apple_Bootstrap partition named `bootstrap'
+    add_partition_to_map(kBootstrapName, kBootstrapType, base, 1600, map);
+}
+
+
 int
 get_base_argument(long *number, partition_map_header *map)
 {
@@ -508,7 +540,7 @@ get_size_argument(long *number, partition_map_header *map)
     int result = 0;
     long multiple;
 
-    if (get_number_argument("Length in blocks: ", number, kDefault) == 0) {
+    if (get_number_argument("Length (in blocks, kB (k), MB (M) or GB (G)): ", number, kDefault) == 0) {
 	bad_input("Bad length");
     } else {
 	result = 1;
@@ -605,13 +637,22 @@ do_write_partition_map(partition_map_header *map)
 	bad_input("The map is not writeable.");
 	return;
     }
-    printf("Writing the map destroys what was there before. ");
-    if (get_okay("Is that okay? [n/y]: ", 0) != 1) {
+//    printf("Writing the map destroys what was there before. ");
+    printf("IMPORTANT: You are about to write a changed partition map to disk. \n");
+    printf("For any partition you changed the start or size of, writing out \n");
+    printf("the map causes all data on that partition to be LOST FOREVER. \n");
+    printf("Make sure you have a backup of any data on such partitions you \n");
+    printf("want to keep before answering 'yes' to the question below! \n\n");
+    if (get_okay("Write partition map? [n/y]: ", 0) != 1) {
 	return;
     }
 
     write_partition_map(map);
 
+    printf("\nPartition map written to disk. If any partitions on this disk \n");
+    printf("were still in use by the system (see messages above), you will need \n");
+    printf("to reboot in order to utilize the new partition map.\n\n");
+
     // exit(0);
 }
 
diff --git a/pmac-fdisk.8.in b/pmac-fdisk.8.in
new file mode 100644
index 0000000..8e32c0c
--- /dev/null
+++ b/pmac-fdisk.8.in
@@ -0,0 +1,222 @@
+.\" Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu)
+.\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
+.\" Copyright 2000 Michael Schmitz (schmitz@biophys.uni-duesseldorf.de)
+.\" May be distributed under the GNU General Public License
+.TH PMAC-FDISK 8 "11 June 1998" "Linux 2.0" "Linux Programmer's Manual"
+.SH NAME
+pmac-fdisk \- Partition table manipulator for Linux
+.SH SYNOPSIS
+.BI "pmac-fdisk [\-u] " device
+.sp
+.BI "pmac-fdisk \-l [\-u] " "device ..."
+.sp
+.BI "pmac-fdisk \-s " "partition ..."
+.sp
+.BI "pmac-fdisk \-v
+.SH DESCRIPTION
+Hard disks can be divided into one or more logical disks called
+.IR partitions .
+This division is described in the
+.I "partition table"
+found in sector 0 of the disk.
+
+In the BSD world one talks about `disk slices' and a `disklabel'.
+
+Linux needs at least one partition, namely for its root file system.
+It can use swap files and/or swap partitions, but the latter are more
+efficient. So, usually one will want a second Linux partition
+dedicated as swap partition.
+On Intel compatible hardware, the BIOS that boots the system
+can often only access the first 1024 cylinders of the disk.
+For this reason people with large disks often create a third partition,
+just a few MB large, typically mounted on
+.IR /boot ,
+to store the kernel image and a few auxiliary files needed at boot time,
+so as to make sure that this stuff is accessible to the BIOS.
+There may be reasons of security, ease of administration and backup,
+or testing, to use more than the minimum number of partitions.
+
+.B pmac-fdisk
+(in the first form of invocation)
+is a menu driven program for creation and manipulation of
+partition tables.
+It understands DOS type partition tables and BSD or SUN type disklabels.
+
+The
+.I device
+is usually one of the following:
+.br
+.nf
+.RS
+/dev/hda
+/dev/hdb
+/dev/sda
+/dev/sdb
+.RE
+.fi
+(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks).
+A device name refers to the entire disk.
+
+The
+.I partition
+is a
+.I device
+name followed by a partition number.  For example,
+.B /dev/hda1
+is the first partition on the first IDE hard disk in the system.
+IDE disks can have up to 63 partitions, SCSI disks up to 15.
+See also
+.IR /usr/src/linux/Documentation/devices.txt .
+
+A BSD/SUN type disklabel can describe 8 partitions,
+the third of which should be a `whole disk' partition.
+Do not start a partition that actually uses its first sector
+(like a swap partition) at cylinder 0, since that will
+destroy the disklabel.
+
+An IRIX/SGI type disklabel can describe 16 partitions,
+the eleventh of which should be an entire `volume' partition,
+while the ninth should be labeled `volume header'.
+The volume header will also cover the partition table, i.e.,
+it starts at block zero and extends by default over five cylinders.
+The remaining space in the volume header may be used by header
+directory entries.  No partitions may overlap with the volume header.
+Also do not change its type and make some file system on it, since
+you will lose the partition table.  Use this type of label only when
+working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux.
+
+A DOS type partition table can describe an unlimited number
+of partitions. In sector 0 there is room for the description
+of 4 partitions (called `primary'). One of these may be an
+extended partition; this is a box holding logical partitions,
+with descriptors found in a linked list of sectors, each
+preceding the corresponding logical partitions.
+The four primary partitions, present or not, get numbers 1-4.
+Logical partitions start numbering from 5.
+
+In a DOS type partition table the starting offset and the size
+of each partition is stored in two ways: as an absolute number
+of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors
+triple (given in 10+8+6 bits). The former is OK - with 512-byte
+sectors this will work up to 2 TB. The latter has two different
+problems. First of all, these C/H/S fields can be filled only
+when the number of heads and the number of sectors per track
+are known. Secondly, even if we know what these numbers should be,
+the 24 bits that are available do not suffice.
+DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S.
+
+If possible,
+.B pmac-fdisk
+will obtain the disk geometry automatically.  This is not
+necessarily the physical disk geometry (indeed, modern disks do not
+really have anything like a physical geometry, certainly not something
+that can be described in simplistic Cylinders/Heads/Sectors form),
+but is the disk geometry that MS-DOS uses for the partition table.
+
+Usually all goes well by default, and there are no problems if
+Linux is the only system on the disk. However, if the disk has
+to be shared with other operating systems, it is often a good idea
+to let an fdisk from another operating system make at least one
+partition. When Linux boots it looks at the partition table, and
+tries to deduce what (fake) geometry is required for good
+cooperation with other systems.
+
+Whenever a partition table is printed out, a consistency check is performed
+on the partition table entries.  This check verifies that the physical and
+logical start and end points are identical, and that the partition starts
+and ends on a cylinder boundary (except for the first partition).
+
+Some versions of MS-DOS create a first partition which does not begin
+on a cylinder boundary, but on sector 2 of the first cylinder.
+Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
+this is unlikely to cause difficulty unless you have OS/2 on your machine.
+
+A sync() and a BLKRRPART ioctl() (reread partition table from disk)
+are performed before exiting when the partition table has been updated.
+Long ago it used to be necessary to reboot after the use of pmac-fdisk.
+I do not think this is the case anymore - indeed, rebooting too quickly
+might cause loss of not-yet-written data. Note that both the kernel
+and the disk hardware may buffer data.
+
+.SH "DOS 6.x WARNING"
+
+The DOS 6.x FORMAT command looks for some information in the first
+sector of the data area of the partition, and treats this information
+as more reliable than the information in the partition table.  DOS
+FORMAT expects DOS FDISK to clear the first 512 bytes of the data area
+of a partition whenever a size change occurs.  DOS FORMAT will look at
+this extra information even if the /U flag is given -- we consider
+this a bug in DOS FORMAT and DOS FDISK.
+
+The bottom line is that if you use pmac-fdisk to change the size of a
+DOS partition table entry, then you must also use
+.B dd
+to zero the first 512 bytes of that partition before using DOS FORMAT to
+format the partition.  For example, if you were using pmac-fdisk to make a 
+DOS partition table entry for /dev/hda1, then (after exiting pmac-fdisk 
+and rebooting Linux so that the partition table information is valid) you
+would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
+the first 512 bytes of the partition.
+
+.B BE EXTREMELY CAREFUL
+if you use the
+.B dd
+command, since a small typo can make all of the data on your disk useless.
+
+For best results, you should always use an OS-specific partition table
+program.  For example, you should make DOS partitions with the DOS FDISK
+program and Linux partitions with the Linux pmac-fdisk program.
+
+.SH OPTIONS
+.TP
+.B \-v
+Print version number of
+.B pmac-fdisk
+program and exit.
+.TP
+.B \-l
+List the partition tables for
+.BR /dev/hd[a-d] ,
+.BR /dev/sd[a-h] ,
+and then exit.
+.TP
+.B \-u
+When listing partition tables, give sizes in sectors instead
+of cylinders.
+.TP
+.BI "\-s " partition
+The
+.I size
+of the partition (in blocks) is printed on the standard output.
+.SH BUGS
+There are several *fdisk programs around.
+Each has its problems and strengths.
+Try them in the order
+.BR cfdisk ,
+.BR pmac-fdisk ,
+.BR sfdisk .
+(Indeed,
+.B cfdisk
+is a beautiful program that has strict requirements on
+the partition tables it accepts, and produces high quality partition
+tables. Use it if you can. 
+.B pmac-fdisk
+is a buggy program that does fuzzy things - usually it happens to
+produce reasonable results. Its single advantage is that it has
+some support for BSD disk labels and other non-DOS partition tables.
+Avoid it if you can.
+.B sfdisk
+is for hackers only - the user interface is terrible, but it is
+more correct than pmac-fdisk and more powerful than both pmac-fdisk and cfdisk.
+Moreover, it can be used noninteractively.)
+.PP
+The IRIX/SGI type disklabel is currently not supported by the kernel.
+Moreover, IRIX/SGI header directories are not fully supported yet.
+.PP
+The option `dump partition table to file' is missing.
+.\" .SH AUTHORS
+.\" A. V. Le Blanc (LeBlanc@mcc.ac.uk)
+.\" Bernhard Fastenrath (fasten@informatik.uni-bonn.de)
+.\" Jakub Jelinek (jj@sunsite.mff.cuni.cz)
+.\" Andreas Neuper (ANeuper@GUUG.de)
+.\" and many others.
-- 
2.26.2


debug log:

solving 98fbd3a8bf ...
found 98fbd3a8bf in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.