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
|
http://bugs.gentoo.org/show_bug.cgi?id=256234
http://sourceforge.net/tracker/?func=detail&aid=2550325&group_id=2406&atid=302406
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/Makefile.in e2fsprogs-1.41.3-mint/lib/ext2fs/Makefile.in
--- e2fsprogs-1.41.3/lib/ext2fs/Makefile.in 2008-10-07 14:22:39.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/Makefile.in 2009-01-23 10:48:50.000000000 +0000
@@ -74,7 +74,9 @@
unix_io.o \
unlink.o \
valid_blk.o \
- version.o
+ version.o \
+ mint_io.o \
+ xhdi.o
SRCS= ext2_err.c \
$(srcdir)/alloc.c \
@@ -146,6 +148,8 @@
$(srcdir)/unlink.c \
$(srcdir)/valid_blk.c \
$(srcdir)/version.c \
+ $(srcdir)/mint_io.c \
+ $(srcdir)/xhdi.c \
$(srcdir)/write_bb_file.c
HFILES= bitops.h ext2fs.h ext2_io.h ext2_fs.h ext2_ext_attr.h ext3_extents.h \
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/bitops.h e2fsprogs-1.41.3-mint/lib/ext2fs/bitops.h
--- e2fsprogs-1.41.3/lib/ext2fs/bitops.h 2008-10-07 14:22:39.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/bitops.h 2009-01-23 10:47:35.000000000 +0000
@@ -125,7 +125,7 @@
*/
#ifdef NO_INLINE_FUNCS
#if (defined(__GNUC__) && (defined(__i386__) || defined(__i486__) || \
- defined(__i586__) || defined(__mc68000__)))
+ defined(__i586__) || defined(__mc68020__)))
/* This prevents bitops.c from trying to include the C */
/* function version of these functions */
#define _EXT2_HAVE_ASM_BITOPS_
@@ -246,7 +246,7 @@
#endif /* i386 */
#if ((defined __GNUC__) && !defined(_EXT2_USE_C_VERSIONS_) && \
- (defined(__mc68000__)))
+ (defined(__mc68020__)))
#define _EXT2_HAVE_ASM_BITOPS_
@@ -280,6 +280,50 @@
return retval;
}
+#elif defined(__mc68000__)
+
+#define _EXT2_HAVE_ASM_BITOPS_
+
+_INLINE_ int
+ext2fs_set_bit (unsigned int nr, void *addr)
+{
+ int mask, retval;
+ unsigned char *ADDR = (unsigned char *) addr;
+
+ ADDR += nr >> 3;
+ mask = 1UL << (nr & 0x07);
+ retval = (mask & *ADDR) != 0;
+ *ADDR |= mask;
+
+ return retval;
+}
+
+_INLINE_ int
+ext2fs_clear_bit (unsigned int nr, void *addr)
+{
+ int mask, retval;
+ unsigned char *ADDR = (unsigned char *) addr;
+
+ ADDR += nr >> 3;
+ mask = 1UL << (nr & 0x07);
+ retval = (mask & *ADDR) != 0;
+ *ADDR &= ~mask;
+
+ return retval;
+}
+
+_INLINE_ int
+ext2fs_test_bit (unsigned int nr, const void *addr)
+{
+ int mask;
+ const unsigned char *ADDR = (const unsigned char *) addr;
+
+ ADDR += nr >> 3;
+ mask = 1UL << (nr & 0x07);
+
+ return ((mask & *ADDR) != 0);
+}
+
#endif /* __mc68000__ */
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/ext2_fs.h e2fsprogs-1.41.3-mint/lib/ext2fs/ext2_fs.h
--- e2fsprogs-1.41.3/lib/ext2fs/ext2_fs.h 2009-01-23 10:01:34.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/ext2_fs.h 2009-01-23 10:49:44.000000000 +0000
@@ -307,6 +307,7 @@
#define _IOT_ext2_new_group_input _IOT (_IOTS(__u32), 5, _IOTS(__u16), 2, 0, 0)
#endif
+#ifndef __MINT__
#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
@@ -316,6 +317,9 @@
#define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
#define EXT2_IOC_GROUP_ADD _IOW('f', 8,struct ext2_new_group_input)
#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
+#else
+#include <mint/dcntl.h>
+#endif
/*
* Structure of an inode on the disk
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/getsize.c e2fsprogs-1.41.3-mint/lib/ext2fs/getsize.c
--- e2fsprogs-1.41.3/lib/ext2fs/getsize.c 2008-10-07 14:22:39.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/getsize.c 2009-01-23 10:47:35.000000000 +0000
@@ -58,6 +58,11 @@
#define BLKGETSIZE DKIOCGETBLOCKCOUNT32
#endif /* APPLE_DARWIN */
+#ifdef __MINT__
+#include <sys/ioctl.h>
+#include "mint_io.h"
+#endif
+
#include "ext2_fs.h"
#include "ext2fs.h"
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/llseek.c e2fsprogs-1.41.3-mint/lib/ext2fs/llseek.c
--- e2fsprogs-1.41.3/lib/ext2fs/llseek.c 2008-10-07 14:22:39.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/llseek.c 2009-01-23 10:47:35.000000000 +0000
@@ -115,6 +115,8 @@
#else /* !linux */
+#ifndef __MINT__
+
#ifndef EINVAL
#define EINVAL EXT2_ET_INVALID_ARGUMENT
#endif
@@ -133,6 +135,8 @@
#endif
}
+#endif /* __MINT__ */
+
#endif /* linux */
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/mint_io.c e2fsprogs-1.41.3-mint/lib/ext2fs/mint_io.c
--- e2fsprogs-1.41.3/lib/ext2fs/mint_io.c 1970-01-01 00:00:00.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/mint_io.c 2009-01-23 10:49:51.000000000 +0000
@@ -0,0 +1,858 @@
+/*
+ * $Id: e2fsprogs-1.41-mint.patch,v 1.1 2010/11/19 18:49:02 jlec Exp $
+ *
+ * This file belongs to FreeMiNT. It's not in the original MiNT 1.12
+ * distribution. See the file CHANGES for a detailed log of changes.
+ *
+ *
+ * Copyright 2000 Frank Naumann <fnaumann@freemint.de>
+ * All rights reserved.
+ *
+ * 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 2, or (at your option)
+ * any later version.
+ *
+ * This file 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * Author: Frank Naumann <fnaumann@freemint.de>
+ * Started: 200-06-14
+ *
+ * Please send suggestions, patches or bug reports to me or
+ * the MiNT mailing list.
+ *
+ */
+
+# ifdef __MINT__
+
+# include <assert.h>
+# include <ctype.h>
+# include <errno.h>
+# include <fcntl.h>
+# include <limits.h>
+# include <stdarg.h>
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+# include <time.h>
+# include <unistd.h>
+
+# include "et/com_err.h"
+# include "ext2fs/ext2_io.h"
+# include <sys/ioctl.h>
+# include <sys/stat.h>
+# define loff_t ext2_loff_t
+# define llseek ext2fs_llseek
+
+# include <mintbind.h>
+# include "mint_io.h"
+# include "xhdi.h"
+
+
+# if 0
+# define DEBUG(x) printf x
+# else
+# define DEBUG(x)
+# endif
+
+
+/* prototypes */
+
+int __open_v(const char *_filename, int iomode, va_list argp);
+
+int open(__const char *__file, int __oflag, ...) __THROW;
+int __open(__const char *__file, int __oflag, ...) __THROW;
+
+int ioctl(int fd, int cmd, void *arg);
+int __ioctl(int fd, int cmd, void *arg);
+
+int fsync(int __fd) __THROW;
+int __fsync(int __fd) __THROW;
+
+__off_t lseek(int __fd, __off_t __offset, int __whence) __THROW;
+__off_t __lseek(int __fd, __off_t __offset, int __whence) __THROW;
+
+int close(int __fd) __THROW;
+int __close(int __fd) __THROW;
+
+ssize_t read(int __fd, void *__buf, size_t __nbytes) __THROW;
+ssize_t __read(int __fd, void *__buf, size_t __nbytes) __THROW;
+
+ssize_t write(int __fd, __const void *__buf, size_t __n) __THROW;
+ssize_t __write(int __fd, __const void *__buf, size_t __n) __THROW;
+
+int fstat(int __fd, struct stat *__buf) __THROW;
+int __fstat(int __fd, struct stat *__buf) __THROW;
+
+int stat(const char *filename, struct stat *st) __THROW;
+
+
+struct device
+{
+ int used;
+
+ int drv;
+ int open_flags;
+
+ ushort xhdi_maj;
+ ushort xhdi_min;
+ ulong xhdi_start;
+ ulong xhdi_blocks;
+ ulong xhdi_blocksize;
+ char xhdi_id[4];
+
+ loff_t pos;
+};
+
+# define DEVS 16
+static struct device devs[DEVS];
+
+static void
+init_device(struct device *dev)
+{
+ dev->used = 0;
+
+ dev->drv = -1;
+ dev->open_flags = 0;
+ dev->xhdi_maj = 0;
+ dev->xhdi_min = 0;
+ dev->xhdi_start = 0;
+ dev->xhdi_blocks = 0;
+ dev->xhdi_blocksize = 0;
+
+ dev->pos = 0;
+}
+
+static inline void
+init(void)
+{
+ static int done = 0;
+ int i;
+
+ if (done)
+ return;
+
+ assert(sizeof(loff_t) == sizeof(long long));
+
+ for (i = 0; i < DEVS; i++)
+ init_device (&devs[i]);
+
+ init_XHDI();
+
+ /* we are now initialized */
+ done = 1;
+}
+
+static struct device *
+get_device(int fd)
+{
+ struct device *dev;
+
+ if ((fd < 1024) || (fd >= (1024 + DEVS)))
+ return NULL;
+
+ fd -= 1024;
+ dev = &devs[fd];
+
+ assert(dev->used);
+
+ return dev;
+}
+
+static int
+alloc_device(void)
+{
+ int i;
+
+ for (i = 0; i < DEVS; i++)
+ {
+ struct device *dev = &devs[i];
+
+ if (!dev->used)
+ {
+ dev->used = 1;
+ return (i + 1024);
+ }
+ }
+
+ __set_errno(ENOMEM);
+ return -1;
+}
+
+static void
+free_device(struct device *dev)
+{
+ assert(dev->used);
+
+ init_device (dev);
+}
+
+
+int
+open(const char *filename, int iomode, ...)
+{
+ const char *f = filename;
+ struct device *mydev = NULL;
+ int dev = -1;
+ long ret;
+
+ init();
+
+ if (!filename)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ if ((f[1] == ':') && (f[2] == '\0'))
+ {
+ int c = tolower(f[0]);
+
+ if (c >= 'a' && c <= 'z')
+ c = c - 'a';
+ else if (c >= '1' && c <= '6')
+ c = 26 + (c - '1');
+
+ if ((c >= 0) && (c < 32))
+ {
+ dev = alloc_device();
+ if (dev != -1)
+ {
+ mydev = get_device(dev);
+ assert(mydev);
+
+ mydev->drv = c;
+ mydev->open_flags = iomode;
+ }
+ }
+ }
+
+ if (dev == -1)
+ {
+ /* fall through */
+
+ va_list args;
+ int retval;
+
+ va_start(args, iomode);
+ retval = __open_v(filename, iomode, args);
+ va_end(args);
+
+ return retval;
+ }
+
+ if (mydev->open_flags == O_RDONLY)
+ {
+ DEBUG(("readonly mode!\n"));
+ sync();
+ }
+ else if (Dlock(1, mydev->drv))
+ {
+ printf("Can't lock partition %c:!\n", mydev->drv+'A');
+
+ if (mydev)
+ free_device(mydev);
+
+ __set_errno(EACCES);
+ return -1;
+ }
+
+ __set_errno(EERROR);
+
+ ret = XHGetVersion ();
+ DEBUG(("XHDI version: %lx\n", ret));
+
+ ret = XHInqDev2(mydev->drv,
+ &mydev->xhdi_maj, &mydev->xhdi_min,
+ &mydev->xhdi_start, NULL,
+ &mydev->xhdi_blocks, mydev->xhdi_id);
+ if (ret)
+ {
+ printf("XHInqDev2 [%c] fail (ret = %li, errno = %i)\n",
+ mydev->drv+'A', ret, errno);
+ ret = -1;
+ }
+ else
+ {
+ ret = XHInqTarget(mydev->xhdi_maj, mydev->xhdi_min,
+ &mydev->xhdi_blocksize, NULL, NULL);
+ if (ret)
+ {
+ printf("XHInqTarget [%i:%i] fail (ret = %li, errno = %i)\n",
+ mydev->xhdi_maj, mydev->xhdi_min, ret, errno);
+ ret = -1;
+ }
+ else
+ {
+ char *xhdi_id = mydev->xhdi_id;
+
+ if ( 0
+ || ((xhdi_id[0] == 'G') && (xhdi_id[1] == 'E') && (xhdi_id[2] == 'M')) /* GEM */
+ || ((xhdi_id[0] == 'B') && (xhdi_id[1] == 'G') && (xhdi_id[2] == 'M')) /* BGM */
+ || ((xhdi_id[0] == 'F') && (xhdi_id[1] == '3') && (xhdi_id[2] == '2')) /* F32 */
+ || ((xhdi_id[0] == 'M') && (xhdi_id[1] == 'I') && (xhdi_id[2] == 'X')) /* MIX */
+ || ((xhdi_id[0] == 'R') && (xhdi_id[1] == 'A') && (xhdi_id[2] == 'W')) /* RAW */
+ || ((xhdi_id[0] == 'L') && (xhdi_id[1] == 'N') && (xhdi_id[2] == 'X')) /* LNX */
+ || ((xhdi_id[0] == '\0') && (xhdi_id[1] == 'D'))) /* any DOS */
+ {
+ DEBUG(("Partition ok and accepted!\n"));
+ DEBUG(("start = %lu, blocks = %lu, blocksize = %lu\n",
+ mydev->xhdi_start, mydev->xhdi_blocks,
+ mydev->xhdi_blocksize));
+ }
+ else
+ {
+ xhdi_id [3] = '\0';
+ printf("Wrong partition ID [%s]!\n", xhdi_id);
+ printf("Only 'RAW', 'LNX' and DOS partitions are supported.\n");
+
+ __set_errno(EPERM);
+ ret = -1;
+ }
+ }
+ }
+
+ if (ret)
+ {
+ if (mydev)
+ free_device(mydev);
+
+ dev = -1;
+ }
+
+ return dev;
+}
+
+int
+close(int fd)
+{
+ struct device *mydev = get_device(fd);
+ int ret = 0;
+
+ if (!mydev)
+ /* fall through */
+ return __close(fd);
+
+ if (mydev->open_flags == O_RDONLY)
+ {
+ ;
+ }
+ else if (Dlock(0, mydev->drv))
+ {
+ printf("Can't unlock partition %c:!\n", 'A'+mydev->drv);
+
+ __set_errno(EACCES);
+ ret = -1;
+ }
+
+ free_device(mydev);
+ return ret;
+}
+
+/* simple buffer */
+static char buffer[1024L * 128];
+static ulong buf_recno = 0;
+static long buf_n = 0;
+
+static long
+rwabs_xhdi(struct device *mydev, ushort rw, void *buf, ulong size, ulong recno)
+{
+ ulong n = size / mydev->xhdi_blocksize;
+ long r;
+
+ assert((size % mydev->xhdi_blocksize) == 0);
+
+ if (!n || (recno + n) > mydev->xhdi_blocks)
+ {
+ printf("rwabs_xhdi: access outside partition (drv = %c:)\n", 'A'+mydev->drv);
+ exit(2);
+ }
+
+ if (n > 65535UL)
+ {
+ printf("rwabs_xhdi: n to large (drv = %c)\n", 'A'+mydev->drv);
+ exit(2);
+ }
+
+ if (!rw && (buf_recno == recno) && (buf_n == n))
+ {
+ bcopy(buffer, buf, buf_n * mydev->xhdi_blocksize);
+ return 0;
+ }
+
+ r = XHReadWrite (mydev->xhdi_maj, mydev->xhdi_min, rw, mydev->xhdi_start + recno, n, buf);
+
+ if (!r && (n * mydev->xhdi_blocksize) <= sizeof(buffer))
+ {
+ bcopy(buf, buffer, n * mydev->xhdi_blocksize);
+
+ buf_recno = recno;
+ buf_n = n;
+ }
+ else
+ buf_n = 0;
+
+ return r;
+}
+
+# define max(a,b) (a > b ? a : b)
+# define min(a,b) (a > b ? b : a)
+
+int
+read(int fd, void *_buf, size_t size)
+{
+ struct device *mydev = get_device(fd);
+
+ if (!mydev)
+ /* fall through */
+ return __read(fd, _buf, size);
+
+{
+ char *buf = _buf;
+ long todo; /* characters remaining */
+ long done; /* characters processed */
+
+ todo = size;
+ done = 0;
+
+ if (todo == 0)
+ return 0;
+
+ /* partial block copy
+ */
+ if (mydev->pos % mydev->xhdi_blocksize)
+ {
+ char tmp[mydev->xhdi_blocksize];
+
+ ulong recno = mydev->pos / mydev->xhdi_blocksize;
+ ulong offset = mydev->pos % mydev->xhdi_blocksize;
+ ulong data;
+ long ret;
+
+ ret = rwabs_xhdi(mydev, 0, tmp, mydev->xhdi_blocksize, recno);
+ if (ret)
+ {
+ DEBUG(("read: partial part: read failure (r = %li, errno = %i)\n", ret, errno));
+ goto out;
+ }
+
+ data = mydev->xhdi_blocksize - offset;
+ data = min (todo, data);
+
+ memcpy(buf, tmp + offset, data);
+
+ buf += data;
+ todo -= data;
+ done += data;
+ mydev->pos += data;
+ }
+
+ if (todo)
+ {
+ assert((todo > 0));
+ assert((mydev->pos % mydev->xhdi_blocksize) == 0);
+ }
+
+
+ /* full blocks
+ */
+ if (todo / mydev->xhdi_blocksize)
+ {
+ ulong recno = mydev->pos / mydev->xhdi_blocksize;
+ ulong data = (todo / mydev->xhdi_blocksize) * mydev->xhdi_blocksize;
+ long ret;
+
+ ret = rwabs_xhdi (mydev, 0, buf, data, recno);
+ if (ret)
+ {
+ DEBUG(("read: full blocks: read failure (r = %li, errno = %i)\n", ret, errno));
+ goto out;
+ }
+
+ buf += data;
+ todo -= data;
+ done += data;
+ mydev->pos += data;
+ }
+
+ if (todo)
+ {
+ assert((todo > 0) && (todo < mydev->xhdi_blocksize));
+ assert((mydev->pos % mydev->xhdi_blocksize) == 0);
+ }
+
+ /* anything left?
+ */
+ if (todo)
+ {
+ char tmp[mydev->xhdi_blocksize];
+
+ ulong recno = mydev->pos / mydev->xhdi_blocksize;
+ long ret;
+
+ ret = rwabs_xhdi (mydev, 0, tmp, mydev->xhdi_blocksize, recno);
+ if (ret)
+ {
+ DEBUG(("read: left part: read failure (r = %li, errno = %i)]\n", ret, errno));
+ goto out;
+ }
+
+ memcpy(buf, tmp, todo);
+
+ done += todo;
+ mydev->pos += todo;
+ }
+
+ assert(done == size);
+
+out:
+ return done;
+}
+}
+
+int
+write(int fd, const void *_buf, size_t size)
+{
+ struct device *mydev = get_device(fd);
+
+ if (!mydev)
+ /* fall through */
+ return __write(fd, _buf, size);
+
+ if (mydev->open_flags == O_RDONLY)
+ {
+ __set_errno(EPERM);
+ return -1;
+ }
+{
+ const char *buf = _buf;
+ long todo; /* characters remaining */
+ long done; /* characters processed */
+
+ todo = size;
+ done = 0;
+
+ if (todo == 0)
+ return 0;
+
+ /* partial block copy
+ */
+ if (mydev->pos % mydev->xhdi_blocksize)
+ {
+ char tmp[mydev->xhdi_blocksize];
+
+ ulong recno = mydev->pos / mydev->xhdi_blocksize;
+ ulong offset = mydev->pos % mydev->xhdi_blocksize;
+ ulong data;
+ long ret;
+
+ ret = rwabs_xhdi(mydev, 0, tmp, mydev->xhdi_blocksize, recno);
+ if (ret)
+ {
+ DEBUG(("write: partial part: read failure (r = %li, errno = %i)\n", ret, errno));
+ goto out;
+ }
+
+ data = mydev->xhdi_blocksize - offset;
+ data = min (todo, data);
+
+ memcpy(tmp + offset, buf, data);
+
+ ret = rwabs_xhdi(mydev, 1, tmp, mydev->xhdi_blocksize, recno);
+ if (ret)
+ {
+ DEBUG(("write: partial part: write failure (r = %li, errno = %i)\n", ret, errno));
+ goto out;
+ }
+
+ buf += data;
+ todo -= data;
+ done += data;
+ mydev->pos += data;
+ }
+
+ if (todo)
+ {
+ assert((todo > 0));
+ assert((mydev->pos % mydev->xhdi_blocksize) == 0);
+ }
+
+ /* full blocks
+ */
+ if (todo / mydev->xhdi_blocksize)
+ {
+ ulong recno = mydev->pos / mydev->xhdi_blocksize;
+ ulong data = (todo / mydev->xhdi_blocksize) * mydev->xhdi_blocksize;
+ long ret;
+
+ ret = rwabs_xhdi(mydev, 1, (void *)buf, data, recno);
+ if (ret)
+ {
+ DEBUG(("write: full blocks: write failure (r = %li, errno = %i)\n", ret, errno));
+ goto out;
+ }
+
+ buf += data;
+ todo -= data;
+ done += data;
+ mydev->pos += data;
+ }
+
+ if (todo)
+ {
+ assert((todo > 0) && (todo < mydev->xhdi_blocksize));
+ assert((mydev->pos % mydev->xhdi_blocksize) == 0);
+ }
+
+ /* anything left?
+ */
+ if (todo)
+ {
+ char tmp[mydev->xhdi_blocksize];
+
+ ulong recno = mydev->pos / mydev->xhdi_blocksize;
+ long ret;
+
+ ret = rwabs_xhdi(mydev, 0, tmp, mydev->xhdi_blocksize, recno);
+ if (ret)
+ {
+ DEBUG(("write: left part: read failure (r = %li, errno = %i)]\n", ret, errno));
+ goto out;
+ }
+
+ memcpy(tmp, buf, todo);
+
+ ret = rwabs_xhdi(mydev, 1, tmp, mydev->xhdi_blocksize, recno);
+ if (ret)
+ {
+ DEBUG(("write: partial part: write failure (r = %li, errno = %i)\n", ret, errno));
+ goto out;
+ }
+
+ done += todo;
+ mydev->pos += todo;
+ }
+
+ assert(done == size);
+
+out:
+ return done;
+}
+}
+
+int
+ioctl(int fd, int cmd, void *arg)
+{
+ struct device *mydev = get_device(fd);
+
+ if (!mydev)
+ /* fall through */
+ return __ioctl(fd, cmd, arg);
+
+ DEBUG(("ioctl: cmd = %i\n", cmd));
+
+ switch (cmd)
+ {
+ case BLKGETSIZE:
+ {
+ ulong *size = arg;
+ *size = mydev->xhdi_blocks * (mydev->xhdi_blocksize / 512);
+ break;
+ }
+ case BLOCKSIZE:
+ {
+ ulong *block_size = arg;
+ *block_size = mydev->xhdi_blocksize;
+ break;
+ }
+ default:
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+fstat(int fd, struct stat *st)
+{
+ struct device *mydev = get_device(fd);
+
+ if (!mydev)
+ /* fall through */
+ return __fstat(fd, st);
+
+ bzero(st, sizeof(*st));
+
+ st->st_dev = mydev->xhdi_maj;
+ st->st_ino = mydev->drv;
+ st->st_mode = S_IFBLK | S_IRUSR | S_IWUSR;
+ st->st_nlink = 1;
+ st->st_uid = 0;
+ st->st_gid = 0;
+ st->st_rdev = mydev->xhdi_min;
+ st->st_atime = time (NULL);
+ st->st_mtime = time (NULL);
+ st->st_ctime = time (NULL);
+ st->st_size = (int64_t) mydev->xhdi_blocks * mydev->xhdi_blocksize;
+ st->st_blocks = (int64_t) mydev->xhdi_blocks * mydev->xhdi_blocksize / 512;
+ st->st_blksize = mydev->xhdi_blocksize;
+ st->st_flags = 0;
+ st->st_gen = 0;
+
+ return 0;
+}
+
+int
+stat(const char *filename, struct stat *st)
+{
+ struct device *mydev;
+ int fd, res;
+
+ fd = open(filename, O_RDONLY);
+ if (fd == -1)
+ return -1;
+
+ mydev = get_device(fd);
+ if (!mydev)
+ {
+ close(fd);
+
+ /* fall through */
+ return __stat(filename, st);
+ }
+
+ res = fstat(fd, st);
+ close(fd);
+
+ return res;
+}
+
+int
+fsync(int fd)
+{
+ struct device *mydev = get_device(fd);
+
+ if (!mydev)
+ /* fall through */
+ return __fsync(fd);
+
+ /* nothing todo */
+ return 0;
+}
+
+loff_t llseek(int fd, loff_t offset, int origin);
+
+loff_t
+llseek(int fd, loff_t offset, int origin)
+{
+ struct device *mydev = get_device(fd);
+
+ if (!mydev)
+ /* fall through */
+ return __lseek(fd, (off_t) offset, origin);
+
+
+ switch (origin)
+ {
+ case SEEK_SET:
+ break;
+ case SEEK_CUR:
+ offset += mydev->pos;
+ break;
+ case SEEK_END:
+ offset += (int64_t) mydev->xhdi_blocks * mydev->xhdi_blocksize;
+ break;
+ default:
+ return -1;
+ }
+
+ if (offset > (loff_t) mydev->xhdi_blocks * mydev->xhdi_blocksize)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ mydev->pos = offset;
+ return mydev->pos;
+}
+
+loff_t lseek64(int fd, loff_t offset, int origin);
+
+loff_t
+lseek64(int fd, loff_t offset, int origin)
+{
+ return llseek(fd, offset, origin);
+}
+
+__off_t
+lseek(int fd, __off_t offset, int mode)
+{
+ struct device *mydev = get_device(fd);
+
+ if (!mydev)
+ /* fall through */
+ return __lseek(fd, offset, mode);
+
+{
+ loff_t _offset = offset;
+
+ switch (mode)
+ {
+ case SEEK_SET:
+ break;
+ case SEEK_CUR:
+ _offset += mydev->pos;
+ break;
+ case SEEK_END:
+ _offset += (loff_t) mydev->xhdi_blocks * mydev->xhdi_blocksize;
+ break;
+ default:
+ return -1;
+ }
+
+ if (_offset > LONG_MAX)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ if (_offset > (loff_t) mydev->xhdi_blocks * mydev->xhdi_blocksize)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ mydev->pos = _offset;
+ return (off_t) mydev->pos;
+}
+}
+
+int gettype(int fd);
+
+int
+gettype(int fd)
+{
+ struct device *mydev = get_device(fd);
+ char *xhdi_id;
+
+ if (!mydev)
+ return -1;
+
+ /* Get filesystem type by XHDI ID */
+ xhdi_id = mydev->xhdi_id;
+ if ((xhdi_id[0] == '\0') && (xhdi_id[1] == 'D'))
+ return 0; /* DOS (\0D*) */
+ else
+ return 1; /* Atari (GEM/GBM) */
+}
+
+# endif /* __MINT__ */
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/mint_io.h e2fsprogs-1.41.3-mint/lib/ext2fs/mint_io.h
--- e2fsprogs-1.41.3/lib/ext2fs/mint_io.h 1970-01-01 00:00:00.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/mint_io.h 2009-01-23 10:49:53.000000000 +0000
@@ -0,0 +1,22 @@
+/*
+ * mint_io.h
+ *
+ * Copyright (C) 2000 Frank Naumann <fnaumann@freemint.de>.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+# ifdef __MINT__
+
+# ifndef _mint_io_h
+# define _mint_io_h
+
+# define BLKGETSIZE (('b'<< 8) | 1)
+# define BLOCKSIZE (('b'<< 8) | 2)
+
+# endif /* _mint_io_h */
+
+# endif /* __MINT__ */
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/unix_io.c e2fsprogs-1.41.3-mint/lib/ext2fs/unix_io.c
--- e2fsprogs-1.41.3/lib/ext2fs/unix_io.c 2008-10-13 03:12:22.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/unix_io.c 2009-01-23 10:47:35.000000000 +0000
@@ -51,9 +51,15 @@
#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */
#endif
+#ifdef __MINT__
+#include <sys/ioctl.h>
+#include "mint_io.h"
+#endif
+
#include "ext2_fs.h"
#include "ext2fs.h"
+
/*
* For checking structure magic numbers...
*/
@@ -512,6 +518,16 @@
}
}
#endif
+
+#ifdef __MINT__
+ {
+ unsigned long block_size;
+ retval = ioctl(data->dev, BLOCKSIZE, &block_size);
+ if (retval == 0)
+ io->block_size = block_size;
+ }
+#endif
+
*channel = io;
return 0;
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/xhdi.c e2fsprogs-1.41.3-mint/lib/ext2fs/xhdi.c
--- e2fsprogs-1.41.3/lib/ext2fs/xhdi.c 1970-01-01 00:00:00.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/xhdi.c 2009-01-23 10:49:55.000000000 +0000
@@ -0,0 +1,577 @@
+/*
+ * Copyright 2000 Frank Naumann <fnaumann@freemint.de>
+ * All rights reserved.
+ *
+ * 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 2, or (at your option)
+ * any later version.
+ *
+ * This file 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * Started: 2000-05-02
+ *
+ * Changes:
+ *
+ * 0.1:
+ *
+ * fix: Cookie handling stuff; use Getcookie from MiNT-Lib now
+ * requires an actual MiNT-Lib (>= PL49)
+ *
+ * 0.0:
+ *
+ * - inital version
+ *
+ */
+
+# include "xhdi.h"
+
+# include <stdio.h>
+# include <stdlib.h>
+# include <errno.h>
+# include <mintbind.h>
+# include <mint/cookie.h>
+
+
+/*
+ * internal usage
+ */
+
+/* dummy routine */
+static long
+XHDIfail (void)
+{
+ return -ENOSYS;
+}
+
+/* XHDI handler function */
+static long (*XHDI)() = XHDIfail;
+
+ushort XHDI_installed = 0;
+
+
+# define C_XHDI 0x58484449L
+# define XHDIMAGIC 0x27011992L
+
+/* initalize flag */
+static ushort init = 1;
+
+long
+init_XHDI (void)
+{
+ long *val;
+ long r;
+
+ init = 0;
+
+ r = Getcookie (C_XHDI, (long *) &val);
+ if (r == C_FOUND)
+ {
+ long *magic_test = val;
+
+ /* check magic */
+ if (magic_test)
+ {
+ magic_test--;
+ if (*magic_test == XHDIMAGIC)
+ {
+ XHDI = val;
+ }
+ }
+ }
+
+ r = XHGetVersion ();
+ if (r < 0)
+ {
+ perror ("XHGetVersion");
+
+ XHDI = XHDIfail;
+ return r;
+ }
+
+ /* we need at least XHDI 1.10 */
+ if (r >= 0x110)
+ {
+ XHDI_installed = r;
+ return 0;
+ }
+
+ XHDI = XHDIfail;
+ return -1;
+}
+
+
+/*
+ * XHDI wrapper routines
+ */
+
+# define CALL \
+ long oldstack = 0; \
+ long r; \
+ \
+ if (init) init_XHDI (); \
+ \
+ if (!Super (1L)) \
+ oldstack = Super (0L); \
+ \
+ r = XHDI (args); \
+ if (r < 0) \
+ { \
+ __set_errno (-r); \
+ r = -1; \
+ } \
+ \
+ if (oldstack) \
+ Super (oldstack); \
+ \
+ return r
+
+long
+XHGetVersion (void)
+{
+ struct args_XHGetVersion
+ {
+ ushort opcode;
+ }
+ args =
+ {
+ 0
+ };
+
+ CALL;
+}
+
+long
+XHInqTarget (ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name)
+{
+ struct args_XHInqTarget
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ulong *block_size;
+ ulong *device_flags;
+ char *product_name;
+ }
+ args =
+ {
+ 1,
+ major,
+ minor,
+ block_size,
+ device_flags,
+ product_name
+ };
+
+ CALL;
+}
+
+long
+XHReserve (ushort major, ushort minor, ushort do_reserve, ushort key)
+{
+ struct args_XHReserve
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ushort do_reserve;
+ ushort key;
+ }
+ args =
+ {
+ 2,
+ major,
+ minor,
+ do_reserve,
+ key
+ };
+
+ CALL;
+}
+
+long
+XHLock (ushort major, ushort minor, ushort do_lock, ushort key)
+{
+ struct args_XHLock
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ushort do_lock;
+ ushort key;
+ }
+ args =
+ {
+ 3,
+ major,
+ minor,
+ do_lock,
+ key
+ };
+
+ CALL;
+}
+
+long
+XHStop (ushort major, ushort minor, ushort do_stop, ushort key)
+{
+ struct args_XHStop
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ushort do_stop;
+ ushort key;
+ }
+ args =
+ {
+ 4,
+ major,
+ minor,
+ do_stop,
+ key
+ };
+
+ CALL;
+}
+
+long
+XHEject (ushort major, ushort minor, ushort do_eject, ushort key)
+{
+ struct args_XHEject
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ushort do_eject;
+ ushort key;
+ }
+ args =
+ {
+ 5,
+ major,
+ minor,
+ do_eject,
+ key
+ };
+
+ CALL;
+}
+
+long
+XHDrvMap (void)
+{
+ struct args_XHDrvMap
+ {
+ ushort opcode;
+ }
+ args =
+ {
+ 6
+ };
+
+ CALL;
+}
+
+long
+XHInqDev (ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb)
+{
+ struct args_XHInqDev
+ {
+ ushort opcode;
+ ushort bios;
+ ushort *major;
+ ushort *minor;
+ ulong *start;
+ __BPB *bpb;
+ }
+ args =
+ {
+ 7,
+ bios,
+ major,
+ minor,
+ start,
+ bpb
+ };
+
+ CALL;
+}
+
+long
+XHInqDriver (ushort bios, char *name, char *version, char *company, ushort *ahdi_version, ushort *maxIPL)
+{
+ struct args_XHInqDriver
+ {
+ ushort opcode;
+ ushort bios;
+ char *name;
+ char *version;
+ char *company;
+ ushort *ahdi_version;
+ ushort *maxIPL;
+ }
+ args =
+ {
+ 8,
+ bios,
+ name,
+ version,
+ company,
+ ahdi_version,
+ maxIPL
+ };
+
+ CALL;
+}
+
+long
+XHNewCookie (void *newcookie)
+{
+ struct args_XHNewCookie
+ {
+ ushort opcode;
+ void *newcookie;
+ }
+ args =
+ {
+ 9,
+ newcookie
+ };
+
+ CALL;
+}
+
+long
+XHReadWrite (ushort major, ushort minor, ushort rwflag, ulong recno, ushort count, void *buf)
+{
+ struct args_XHReadWrite
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ushort rwflag;
+ ulong recno;
+ ushort count;
+ void *buf;
+ }
+ args =
+ {
+ 10,
+ major,
+ minor,
+ rwflag,
+ recno,
+ count,
+ buf
+ };
+
+ CALL;
+}
+
+long
+XHInqTarget2 (ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name, ushort stringlen)
+{
+ struct args_XHInqTarget2
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ulong *block_size;
+ ulong *device_flags;
+ char *product_name;
+ ushort stringlen;
+ }
+ args =
+ {
+ 11,
+ major,
+ minor,
+ block_size,
+ device_flags,
+ product_name,
+ stringlen
+ };
+
+ CALL;
+}
+
+long
+XHInqDev2 (ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb, ulong *blocks, char *partid)
+{
+ struct args_XHInqDev2
+ {
+ ushort opcode;
+ ushort bios;
+ ushort *major;
+ ushort *minor;
+ ulong *start;
+ __BPB *bpb;
+ ulong *blocks;
+ char *partid;
+ }
+ args =
+ {
+ 12,
+ bios,
+ major,
+ minor,
+ start,
+ bpb,
+ blocks,
+ partid
+ };
+
+ CALL;
+}
+
+long
+XHDriverSpecial (ulong key1, ulong key2, ushort subopcode, void *data)
+{
+ struct args_XHDriverSpecial
+ {
+ ushort opcode;
+ ulong key1;
+ ulong key2;
+ ushort subopcode;
+ void *data;
+ }
+ args =
+ {
+ 13,
+ key1,
+ key2,
+ subopcode,
+ data
+ };
+
+ CALL;
+}
+
+long
+XHGetCapacity (ushort major, ushort minor, ulong *blocks, ulong *bs)
+{
+ struct args_XHGetCapacity
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ulong *blocks;
+ ulong *bs;
+ }
+ args =
+ {
+ 14,
+ major,
+ minor,
+ blocks,
+ bs
+ };
+
+ CALL;
+}
+
+long
+XHMediumChanged (ushort major, ushort minor)
+{
+ struct args_XHMediumChanged
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ }
+ args =
+ {
+ 15,
+ major,
+ minor
+ };
+
+ CALL;
+}
+
+long
+XHMiNTInfo (ushort op, void *data)
+{
+ struct args_XHMiNTInfo
+ {
+ ushort opcode;
+ ushort op;
+ void *data;
+ }
+ args =
+ {
+ 16,
+ op,
+ data
+ };
+
+ CALL;
+}
+
+long
+XHDOSLimits (ushort which, ulong limit)
+{
+ struct args_XHDOSLimits
+ {
+ ushort opcode;
+ ushort which;
+ ulong limit;
+ }
+ args =
+ {
+ 17,
+ which,
+ limit
+ };
+
+ CALL;
+}
+
+long
+XHLastAccess (ushort major, ushort minor, ulong *ms)
+{
+ struct args_XHLastAccess
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ ulong *ms;
+ }
+ args =
+ {
+ 18,
+ major,
+ minor,
+ ms
+ };
+
+ CALL;
+}
+
+long
+XHReaccess (ushort major, ushort minor)
+{
+ struct args_XHReaccess
+ {
+ ushort opcode;
+ ushort major;
+ ushort minor;
+ }
+ args =
+ {
+ 19,
+ major,
+ minor
+ };
+
+ CALL;
+}
diff -ur --new-file e2fsprogs-1.41.3/lib/ext2fs/xhdi.h e2fsprogs-1.41.3-mint/lib/ext2fs/xhdi.h
--- e2fsprogs-1.41.3/lib/ext2fs/xhdi.h 1970-01-01 00:00:00.000000000 +0000
+++ e2fsprogs-1.41.3-mint/lib/ext2fs/xhdi.h 2009-01-23 10:49:56.000000000 +0000
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2000 Frank Naumann <fnaumann@freemint.de>
+ * All rights reserved.
+ *
+ * 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 2, or (at your option)
+ * any later version.
+ *
+ * This file 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+# ifndef _xhdi_h
+# define _xhdi_h
+
+# include <sys/types.h>
+
+typedef unsigned char uchar;
+
+
+/*
+ * BIOS parameter block (osbind.h is buggy)
+ */
+
+typedef struct
+{
+ ushort recsiz; /* bytes per sector */
+ short clsiz; /* sectors per cluster */
+ ushort clsizb; /* bytes per cluster */
+ short rdlen; /* root directory size */
+ short fsiz; /* size of FAT */
+ short fatrec; /* startsector of second FAT */
+ short datrec; /* first data sector */
+ ushort numcl; /* total number of clusters */
+ short bflags; /* some flags */
+
+} __BPB;
+
+
+/*
+ * Extended BIOS Parameter Block (XHDI)
+ */
+
+typedef struct
+{
+ ushort recsiz; /* bytes per sector */
+ short clsiz; /* sectors per cluster */
+ ushort clsizb; /* bytes per cluster */
+ short rdlen; /* root directory size or 0 if FAT32 */
+ short fsiz; /* size of FAT or 0 if FAT32 */
+ short fatrec; /* startsector of second FAT or 0 if FAT32 */
+ short datrec; /* first data sector or 0 if FAT32 */
+ ushort numcl; /* total number of clusters or 0 if FAT32 */
+ short bflags; /* bit 0: 0 = FAT12, 1 = FAT16
+ * bit 1: 0 = 2 FATs, 1 = 1 FAT
+ * bit 2: 0 = BPB, 1 = EXTENDED_BPB
+ */
+
+ /* Ab hier undokumentiert, nur A: und B:! */
+ short ntracks; /* Anzahl Spuren */
+ short nsides; /* Anzahl Seiten */
+ short spc; /* Sektoren pro Zylinder */
+ short spt; /* Sektoren pro Spur */
+ ushort nhid; /* Anzahl versteckte Sektoren */
+ uchar ser[3]; /* Seriennummer */
+ uchar serms[4]; /* ab TOS 2.06: MS-DOS-4.0-Seriennummer */
+ char unused;
+
+ /* if bit 2 of bflags are set */
+ long l_recsiz; /* bytes per sector */
+ long l_clsiz; /* sectors per cluster */
+ long l_clsizb; /* bytes per cluster */
+ long l_rdlen; /* root directory size */
+ long l_fsiz; /* size of FAT */
+ long l_fatrec; /* startsector of second FAT */
+ long l_datrec; /* first data sector */
+ long l_numcl; /* total number of clusters */
+ long l_rdstcl; /* if FAT32: startcluster of root directory
+ * otherwise 0
+ */
+} __xhdi_BPB;
+
+
+# define XH_TARGET_STOPPABLE 0x00000001L
+# define XH_TARGET_REMOVABLE 0x00000002L
+# define XH_TARGET_LOCKABLE 0x00000004L
+# define XH_TARGET_EJECTABLE 0x00000008L
+# define XH_TARGET_LOCKED 0x20000000L
+# define XH_TARGET_STOPPED 0x40000000L
+# define XH_TARGET_RESERVED 0x80000000L
+
+# define XH_MI_SETKERINFO 0
+# define XH_MI_GETKERINFO 1
+
+# define XH_DL_SECSIZ 0
+# define XH_DL_MINFAT 1
+# define XH_DL_MAXFAT 2
+# define XH_DL_MINSPC 3
+# define XH_DL_MAXSPC 4
+# define XH_DL_CLUSTS 5
+# define XH_DL_MAXSEC 6
+# define XH_DL_DRIVES 7
+# define XH_DL_CLSIZB 8
+# define XH_DL_RDLEN 9
+# define XH_DL_CLUSTS12 12
+# define XH_DL_CLUSTS32 13
+# define XH_DL_BFLAGS 14
+
+
+extern ushort XHDI_installed;
+
+long init_XHDI (void);
+
+long XHGetVersion (void);
+long XHInqTarget (ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name);
+long XHReserve (ushort major, ushort minor, ushort do_reserve, ushort key);
+long XHLock (ushort major, ushort minor, ushort do_lock, ushort key);
+long XHStop (ushort major, ushort minor, ushort do_stop, ushort key);
+long XHEject (ushort major, ushort minor, ushort do_eject, ushort key);
+long XHDrvMap (void);
+long XHInqDev (ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb);
+long XHInqDriver (ushort bios, char *name, char *version, char *company, ushort *ahdi_version, ushort *maxIPL);
+long XHNewCookie (void *newcookie);
+long XHReadWrite (ushort major, ushort minor, ushort rwflag, ulong recno, ushort count, void *buf);
+long XHInqTarget2 (ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name, ushort stringlen);
+long XHInqDev2 (ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb, ulong *blocks, char *partid);
+long XHDriverSpecial (ulong key1, ulong key2, ushort subopcode, void *data);
+long XHGetCapacity (ushort major, ushort minor, ulong *blocks, ulong *bs);
+long XHMediumChanged (ushort major, ushort minor);
+long XHMiNTInfo (ushort op, void *data);
+long XHDOSLimits (ushort which, ulong limit);
+long XHLastAccess (ushort major, ushort minor, ulong *ms);
+long XHReaccess (ushort major, ushort minor);
+
+
+# endif /* _xhdi_h */
diff -ur --new-file e2fsprogs-1.41.3/misc/e2undo.c e2fsprogs-1.41.3-mint/misc/e2undo.c
--- e2fsprogs-1.41.3/misc/e2undo.c 2009-01-23 12:59:44.000000000 +0000
+++ e2fsprogs-1.41.3-mint/misc/e2undo.c 2009-01-23 12:56:40.000000000 +0000
@@ -19,6 +19,7 @@
#if HAVE_ERRNO_H
#include <errno.h>
#endif
+#include <sys/types.h>
#include "ext2fs/tdb.h"
#include "ext2fs/ext2fs.h"
#include "nls-enable.h"
diff -ur --new-file e2fsprogs-1.41.3/misc/e2initrd_helper.c e2fsprogs-1.41.3-mint/misc/e2initrd_helper.c
--- e2fsprogs-1.41.3/misc/e2initrd_helper.c 2009-01-23 12:58:29.000000000 +0000
+++ e2fsprogs-1.41.3-mint/misc/e2initrd_helper.c 2009-01-23 12:59:11.000000000 +0000
@@ -50,7 +50,7 @@
int ptr;
};
-struct fs_info {
+struct _fs_info {
char *device;
char *mountpt;
char *type;
@@ -58,7 +58,7 @@
int freq;
int passno;
int flags;
- struct fs_info *next;
+ struct _fs_info *next;
};
static void usage(void)
@@ -230,7 +230,7 @@
*q = 0;
}
-static int parse_fstab_line(char *line, struct fs_info *fs)
+static int parse_fstab_line(char *line, struct _fs_info *fs)
{
char *dev, *device, *mntpnt, *type, *opts, *freq, *passno, *cp;
@@ -280,7 +280,7 @@
return 0;
}
-static void free_fstab_line(struct fs_info *fs)
+static void free_fstab_line(struct _fs_info *fs)
{
if (fs->device)
fs->device = 0;
@@ -290,7 +290,7 @@
fs->type = 0;
if (fs->opts)
fs->opts = 0;
- memset(fs, 0, sizeof(struct fs_info));
+ memset(fs, 0, sizeof(struct _fs_info));
}
@@ -334,7 +334,7 @@
errcode_t retval;
struct mem_file file;
char *buf;
- struct fs_info fs_info;
+ struct _fs_info _fs_info;
int ret;
retval = get_file(fs, "/etc/fstab", &file);
@@ -344,14 +344,14 @@
if (!buf)
continue;
- ret = parse_fstab_line(buf, &fs_info);
+ ret = parse_fstab_line(buf, &_fs_info);
if (ret < 0)
goto next_line;
- if (!strcmp(fs_info.mountpt, "/"))
- printf("%s\n", fs_info.type);
+ if (!strcmp(_fs_info.mountpt, "/"))
+ printf("%s\n", _fs_info.type);
- free_fstab_line(&fs_info);
+ free_fstab_line(&_fs_info);
next_line:
free(buf);
diff -ur --new-file e2fsprogs-1.41.3/misc/mke2fs.c e2fsprogs-1.41.3-mint/misc/mke2fs.c
--- e2fsprogs-1.41.3/misc/mke2fs.c 2008-10-07 14:22:39.000000000 +0000
+++ e2fsprogs-1.41.3-mint/misc/mke2fs.c 2009-01-23 10:47:35.000000000 +0000
@@ -1819,6 +1819,36 @@
return retval;
}
+#ifdef __MINT__
+void
+warn (const char *drv)
+{
+ char c;
+ int check;
+
+ check = open (drv, O_RDONLY);
+ if (check == -1)
+ return;
+
+ close (check);
+
+ if (check < 1024)
+ return;
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "WARNING: THIS WILL TOTALLY DESTROY ANY DATA ON %s:\n", drv);
+ fprintf (stderr, "Are you ABSOLUTELY SURE you want to do this? (y/n) ");
+ scanf ("%c", &c);
+ fprintf (stderr, "\n");
+
+ if (c == 'y' || c == 'Y')
+ return;
+
+ fprintf (stderr, "Aborted\n");
+ exit (1);
+}
+#endif
+
int main (int argc, char *argv[])
{
errcode_t retval = 0;
@@ -1839,6 +1869,11 @@
#endif
PRS(argc, argv);
+#ifdef __MINT__
+ if (!quiet)
+ warn (device_name);
+#endif
+
#ifdef CONFIG_TESTIO_DEBUG
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
io_ptr = test_io_manager;
|