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 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258
|
<!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<Article>
<ArticleInfo>
<Title>EXT2ED - The Extended-2 filesystem editor - User's guide</Title>
<AUTHOR>
<FirstName>Gadi Oxman, tgud@tochnapc2.technion.ac.il</FirstName>
</AUTHOR>
<PubDate>v0.1, August 3 1995</PubDate>
<Abstract>
<Para>
This is only the initial version of this document. It may be unclear at
some places. Please send me feedback with anything regarding to it.
</Para>
</Abstract>
</ArticleInfo>
<Sect1>
<Title>About EXT2ED documentation</Title>
<Para>
The EXT2ED documentation consists of three parts:
<ItemizedList>
<ListItem>
<Para>
The ext2 filesystem overview.
</Para>
</ListItem>
<ListItem>
<Para>
The EXT2ED user's guide.
</Para>
</ListItem>
<ListItem>
<Para>
The EXT2ED design and implementation.
</Para>
</ListItem>
</ItemizedList>
</Para>
<Para>
If you intend to used EXT2ED, I strongly suggest that you would be familiar
with the material presented in the <Literal remap="tt">ext2 filesystem overview</Literal> as well.
</Para>
<Para>
If you also intend to browse and modify the source code, I suggest that you
will also read the article <Literal remap="tt">The EXT2ED design and implementation</Literal>, as it
provides a general overview of the structure of my source code.
</Para>
</Sect1>
<Sect1>
<Title>Introduction</Title>
<Para>
EXT2ED is a "disk editor" for the ext2 filesystem. Its purpose is to show
you the internal structures of the ext2 filesystem in an rather intuitive
and logical way, so that it will be easier to "travel" between the various
internal filesystem structures.
</Para>
</Sect1>
<Sect1>
<Title>Basic concepts in EXT2ED</Title>
<Para>
Two basic concepts in EXT2ED are <Literal remap="tt">commands</Literal> and <Literal remap="tt">types</Literal>.
</Para>
<Para>
EXT2ED is object-oriented in the sense that it defines objects in the
filesystem, like a <Literal remap="tt">super-block</Literal> or a <Literal remap="tt">directory</Literal>. An object is
something which "knows" how to handle some aspect of the filesystem.
</Para>
<Para>
Your interaction with EXT2ED is done through <Literal remap="tt">commands</Literal> which EXT2ED
accepts. There are three levels of commands:
<ItemizedList>
<ListItem>
<Para>
General Commands
</Para>
</ListItem>
<ListItem>
<Para>
Extended-2 Filesystem general commands
</Para>
</ListItem>
<ListItem>
<Para>
Type specific commands
</Para>
</ListItem>
</ItemizedList>
The General commands are always available.
</Para>
<Para>
The ext2 general commands are available only when editing an ext2 filesystem.
</Para>
<Para>
The Type specific commands are available when editing a specific object in the
filesystem. Each object typically comes with its own set of internal
variables, and its own set of commands, which are fine tuned handle the
corresponding structure in the filesystem.
</Para>
</Sect1>
<Sect1>
<Title>Running EXT2ED</Title>
<Para>
Running EXT2ED is as simple as typing <Literal remap="tt">ext2ed</Literal> from the shell prompt.
There are no command line switches.
</Para>
<Para>
When first run, EXT2ED parses its configuration file, <Literal remap="tt">ext2ed.conf</Literal>.
This file must exist.
</Para>
<Para>
When the configuration file processing is done, EXT2ED screen should appear
on the screen, with the command prompt <Literal remap="tt">ext2ed></Literal> displayed.
</Para>
</Sect1>
<Sect1>
<Title>EXT2ED user interface</Title>
<Para>
EXT2ED uses the <Emphasis>ncurses</Emphasis> library for screen management. Your screen
will be divided into four parts, from top to bottom:
<ItemizedList>
<ListItem>
<Para>
Title window
</Para>
</ListItem>
<ListItem>
<Para>
Status window
</Para>
</ListItem>
<ListItem>
<Para>
Main editing window
</Para>
</ListItem>
<ListItem>
<Para>
Command window
</Para>
</ListItem>
</ItemizedList>
The title window just displays the current version of EXT2ED.
</Para>
<Para>
The status window will display various information regarding the state of
the editing at this point.
</Para>
<Para>
The main editing window is the place at which the actual data will be shown.
Almost every command will cause some display at this window. This window, as
opposed to the three others, is of variable length - You always look at one
page of it. The current page and the total numbers of pages at this moment
is displayed at the status window. Moving between pages is done by the use
of the <Command>pgdn</Command> and <Command>pgup</Command> commands.
</Para>
<Para>
The command window is at the bottom of the screen. It always displays a
command prompt <Literal remap="tt">ext2ed></Literal> and allows you to type a command. Feedback
about the commands entered is displayed to this window also.
</Para>
<Para>
EXT2ED uses the <Emphasis>readline</Emphasis> library while processing a command line. All
the usual editing keys are available. Each entered command is placed into a
history of commands, and can be recalled later. Command Completion is also
supported - Just start to type a command, and press the completion key.
</Para>
<Para>
Pressing <Literal remap="tt">enter</Literal> at the command window, without entering a command,
recalls the last command. This is useful when moving between close entries,
in the <Command>next</Command> command, for example.
</Para>
</Sect1>
<Sect1>
<Title>Getting started</Title>
<Sect2>
<Title>A few precautions</Title>
<Para>
EXT2ED is a tool for filesystem <Literal remap="tt">editing</Literal>. As such, it can be
<Literal remap="tt">dangerous</Literal>. The summary to the subsections below is that
<Literal remap="tt">You must know what you are doing</Literal>.
</Para>
<Sect3 id="mounted-ref">
<Title>A mounted filesystem</Title>
<Para>
EXT2ED is not designed to work on a mounted filesystem - It is complicated
enough as it is; I didn't even try to think of handling the various race
conditions. As such, please respect the following advice:
</Para>
<Para>
<Literal remap="tt">Do not use EXT2ED on a mounted filesystem !</Literal>
</Para>
<Para>
EXT2ED will not allow write access to a mounted filesystem. Although it is
fairly easy to change EXT2ED so that it will be allowed, I hereby request
again- EXT2ED is not designed for that action, and will most likely corrupt
data if used that way. Please don't do that.
</Para>
<Para>
Concerning read access, I chose to leave the decision for the user through
the configuration file option <Literal remap="tt">AllowMountedRead</Literal>. Although read access
on a mounted partition will not do any damage to the filesystem, the data
displayed to you will not be reliable, and showing you incorrect information
may be as bad as corrupting the filesystem. However, you may still wish to
do that.
</Para>
</Sect3>
<Sect3>
<Title>Write access</Title>
<Para>
Considering the obvious sensitivity of the subject, I took the following
actions:
</Para>
<Para>
<OrderedList>
<ListItem>
<Para>
EXT2ED will always start with a read-only access. Write access mode
needs to be specifically entered by the <Command>enablewrite</Command> command.
Until this is done, no write will be allowed. Write access can be
disabled at any time with <Command>disablewrite</Command>. When
<Command>enablewrite</Command> is issued, the device is reopened in read-write
mode. Needless to say, the device permissions should allow that.
</Para>
</ListItem>
<ListItem>
<Para>
As a second level of protection, you can disallow write access in
the configuration file by using the <Literal remap="tt">AllowChanges off</Literal>
configuration option. In this case, the <Command>enablewrite</Command> command
will be refused.
</Para>
</ListItem>
<ListItem>
<Para>
When write access is enabled, the data will never change
immediately. Rather, a specific <Command>writedata</Command> command is needed
to update the object in the disk with the changed object in memory.
</Para>
</ListItem>
<ListItem>
<Para>
In addition, A logging option is provided through the configuration
file options <Literal remap="tt">LogChanges</Literal> and <Literal remap="tt">LogFile</Literal>. With logging
enabled, each change to the disk will be logged at a very primitive
level - A hex dump of the original data and of the new written data.
The log file will be a text file which is easily readable, and you
can make use of it to undo any changes which you made (EXT2ED doesn't
make use of the log file for that purpose, it just logs the changes).
</Para>
</ListItem>
</OrderedList>
Please remember that this is only the initial release of EXT2ED, and it is
not very much tested - It is reasonable to assume that <Literal remap="tt">there are
bugs</Literal>.
However, the logging option above can offer protection even from this
unfortunate case. Therefor, I highly recommend that at least when first
working with EXT2ED, the logging option will be enabled, despite the disk
space which it consumes.
</Para>
</Sect3>
</Sect2>
<Sect2 id="help-ref">
<Title>The help command</Title>
<Para>
When loaded, EXT2ED will show a short help screen. This help screen can
always be retrieved by the command <Command>help</Command>. The help screen displays a
list of all the commands which are available at this point. At startup, only
the <Literal remap="tt">General commands</Literal> are available.
This will change with time, since each object has its own commands. Thus,
commands which are available now may not be available later.
Using <Command>help</Command> <Emphasis>command</Emphasis> will display additional information about
the specific command <Emphasis>command</Emphasis>.
</Para>
</Sect2>
<Sect2 id="setdevice-ref">
<Title>The setdevice command</Title>
<Para>
The first command that is usually entered to EXT2ED is the <Command>setdevice</Command>
command. This command simply tells EXT2ED on which device the filesystem is
present. For example, suppose my ext2 filesystem is on the first partition
of my ide disk. The command will be:
<Screen>
setdevice /dev/hda1
</Screen>
The following actions will take place in the following order:
<OrderedList>
<ListItem>
<Para>
EXT2ED will check if the partition is mounted.
If the partition is mounted (<Literal remap="tt">highly not recommended</Literal>),
the accept/reject behavior will be decided by the configuration
file. Cross reference section <XRef LinkEnd="mounted-ref">.
</Para>
</ListItem>
<ListItem>
<Para>
The specified device will be opened in read-only mode. The
permissions of the device should be set in a way that allows
you to open the device for read access.
</Para>
</ListItem>
<ListItem>
<Para>
Autodetection of an ext2 filesystem will be made by searching for
the ext2 magic number in the main superblock.
</Para>
</ListItem>
<ListItem>
<Para>
In the case of a successful recognition of an ext2 filesystem, the
ext2 filesystem specific commands and the ext2 specific object
definitions will be registered. The object definitions will be read
at run time from a file specified by the configuration file.
In case of a corrupted ext2 filesystem, it is quite possible that
the main superblock is damaged and autodetection will fail. In that
case, use the configuration option <Literal remap="tt">ForceExt2 on</Literal>. This is not
the default case since EXT2ED can be used at a lower level to edit a
non-ext2 filesystem.
</Para>
</ListItem>
<ListItem>
<Para>
In a case of a successful autodetection, essential information about
the filesystem such as the block size will be read from the
superblock, unless the used overrides this behavior with an
configuration option (not recommended). In that case, the parameters
will be read from the configuration file.
In a case of an autodetection failure, the essential parameters
will be read from the configuration file.
</Para>
</ListItem>
</OrderedList>
Assuming that you are editing an ext2 filesystem and that everything goes
well, you will notice that additional commands are now available in the help
screen, under the section <Literal remap="tt">ext2 filesystem general commands</Literal>. In
addition, EXT2ED now recognizes a few objects which are essential to the
editing of an ext2 filesystem.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>Two levels of usage</Title>
<Sect2>
<Title>Low level usage</Title>
<Para>
This section explains what EXT2ED provides even when not editing an ext2
filesystem.
</Para>
<Para>
Even at this level, EXT2ED is more than just a hex editor. It still allows
definition of objects and variables in run time through a user file,
although of-course the objects will not have special fine tuned functions
connected to them. EXT2ED will allow you to move in the filesystem using
<Command>setoffset</Command>, and to apply an object definition on a specific place
using <Command>settype</Command> <Emphasis>type</Emphasis>. From this point and on, the object will
be shown <Literal remap="tt">in its native form</Literal> - You will see a list of the
variables rather than just a hex dump, and you will be able to change each
variable in the intuitive form <Command>set variable=value</Command>.
</Para>
<Para>
To define objects, use the configuration option <Literal remap="tt">AlternateDescriptors</Literal>.
</Para>
<Para>
There are now two forms of editing:
<ItemizedList>
<ListItem>
<Para>
Editing without a type. In this case, the disk block will be shown
as a text+hex dump, and you will be able to move along and change it.
</Para>
</ListItem>
<ListItem>
<Para>
Editing with a type. In this case, the object's variables will be
shown, and you will be able to change each variable in its native form.
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect2>
<Sect2>
<Title>High level usage</Title>
<Para>
EXT2ED was designed for the editing of the ext2 filesystem. As such, it
"understands" the filesystem structure to some extent. Each object now has
special fine tuned 'C' functions connected to it, which knows how to display
it in an intuitive form, and how the object fits in the general design of
the ext2 filesystem. It is of-course much easier to use this type of
editing. For example:
<Screen>
Issue <Emphasis>group 2</Emphasis> to look at the main copy of the third group block
descriptor. With <Emphasis>gocopy 1</Emphasis> you can move to its first backup copy,
and with <Emphasis>inode</Emphasis> you can start editing the inode table of the above
group block. From here, if the inode corresponds to a file, you can
use <Emphasis>file</Emphasis> to edit the file in a "continuous" way, using
<Emphasis>nextblock</Emphasis> to pass to its next block, letting EXT2ED following by
itself the direct blocks, indirect blocks, ..., while still preserving the
actual view of the exact block usage of the file.
</Screen>
The point is that the "tour" of the filesystem will now be synchronous rather
than asynchronous - Each object has the "links" to pass between connected
logical structures, and special fine-tuned functions to deal with it.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>General commands</Title>
<Para>
I will now start with a systematic explanation of the general commands.
Please feel free to experiment, but take care when using the
<Literal remap="tt">enablewrite</Literal> command.
</Para>
<Para>
Whenever a command syntax is specified, arguments which are optional are
enclosed with square brackets.
</Para>
<Para>
Please note that in EXT2ED, each command can be overridden by a specific
object to provide special fine-tuned functionality. In general, I was
attempting to preserve the similarity between those functions, which are
accessible by the same name.
</Para>
<Sect2 id="disablewrite-ref">
<Title>disablewrite</Title>
<Para>
<Screen>
Syntax: disablewrite
</Screen>
<Command>disablewrite</Command> is used to reopen the device with read-only access. When
first running EXT2ED, the device is opened in read-only mode, and an
explicit <Command>enablewrite</Command> is required for write access. When finishing
with changing, a <Command>disablewrite</Command> is recommended for safety. Cross
reference section <XRef LinkEnd="disablewrite-ref">.
</Para>
</Sect2>
<Sect2 id="enablewrite-ref">
<Title>enablewrite</Title>
<Para>
<Screen>
Syntax: enablewrite
</Screen>
<Command>enablewrite</Command> is used to reopen the device with read-write access.
When first running EXT2ED, the device is opened in read-only mode, and an
explicit <Command>enablewrite</Command> is required for write access.
<Command>enablewrite</Command> will fail if write access is disabled from the
configuration file by the <Literal remap="tt">AllowChanges off</Literal> configuration option.
Even after <Command>enablewrite</Command>, an explicit <Command>writedata</Command>
is required to actually write the new data to the disk.
When finishing with changing, a <Command>disablewrite</Command> is recommended for safety.
Cross reference section <XRef LinkEnd="enablewrite-ref">.
</Para>
</Sect2>
<Sect2>
<Title>help</Title>
<Para>
<Screen>
Syntax: help [command]
</Screen>
The <Command>help</Command> command is described at section <XRef LinkEnd="help-ref">.
</Para>
</Sect2>
<Sect2 id="next-ref">
<Title>next</Title>
<Para>
<Screen>
Syntax: next [number]
</Screen>
This section describes the <Emphasis>general command</Emphasis> <Command>next</Command>. <Command>next</Command>
is overridden by several types in EXT2ED, to provide fine-tuned
functionality.
</Para>
<Para>
The <Literal remap="tt">next general command</Literal> behavior is depended on whether you are editing a
specific object, or none.
</Para>
<Para>
<ItemizedList>
<ListItem>
<Para>
In the case where Type is <Literal remap="tt">none</Literal> (The current type is showed
on the status window by the <Command>show</Command> command), <Literal remap="tt">next</Literal>
passes to the next <Emphasis>number</Emphasis> bytes in the current edited block.
If <Emphasis>number</Emphasis> is not specified, <Emphasis>number=1</Emphasis> is assumed.
</Para>
</ListItem>
<ListItem>
<Para>
In the case where Type is defined, the <Command>next</Command> commands assumes
that you are editing an array of objects of that type, and the
<Command>next</Command> command will just pass to the next entry in the array.
If <Emphasis>number</Emphasis> is defined, it will pass <Emphasis>number</Emphasis> entries
ahead.
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect2>
<Sect2 id="pgdn-ref">
<Title>pgdn</Title>
<Para>
<Screen>
Syntax: pgdn
</Screen>
Usually the edited data doesn't fit into the visible main window. In this
case, the status window will indicate that there is more to see "below" by
the message <Literal remap="tt">Page x of y</Literal>. This means that there are <Emphasis>y</Emphasis> pages
total, and you are currently viewing the <Emphasis>x</Emphasis> page. With the <Command>pgdn</Command>
command, you can pass to the next available page.
</Para>
</Sect2>
<Sect2>
<Title>pgup</Title>
<Para>
<Screen>
Syntax: pgup
</Screen>
</Para>
<Para>
<Command>pgup</Command> is the opposite of <Command>pgdn</Command> - It will pass to the previous
page. Cross reference section <XRef LinkEnd="pgdn-ref">.
</Para>
</Sect2>
<Sect2>
<Title>prev</Title>
<Para>
<Screen>
Syntax: prev [number]
</Screen>
</Para>
<Para>
<Command>prev</Command> is the opposite of <Command>next</Command>. Cross reference section
<XRef LinkEnd="next-ref">.
</Para>
</Sect2>
<Sect2 id="recall-ref">
<Title>recall</Title>
<Para>
<Screen>
Syntax: recall object
</Screen>
<Command>recall</Command> is the opposite of <Command>remember</Command>. It will place you at the
place you where when saving the object position and type information. Cross
reference section <XRef LinkEnd="remember-ref">.
</Para>
</Sect2>
<Sect2>
<Title>redraw</Title>
<Para>
<Screen>
Syntax: redraw
</Screen>
Sometimes the screen display gets corrupted. I still have problems with
this. The <Command>redraw</Command> command simply redraws the entire display screen.
</Para>
</Sect2>
<Sect2 id="remember-ref">
<Title>remember</Title>
<Para>
<Screen>
Syntax: remember object
</Screen>
EXT2ED provides you <Literal remap="tt">memory</Literal> of objects; While editing, you may reach an
object which you will like to return to later. The <Command>remember</Command> command
will store in memory the current place and type of the object. You can
return to the object by using the <Command>recall</Command> command. Cross reference
section <XRef LinkEnd="recall-ref">.
</Para>
<Para>
<Literal remap="tt">Note:</Literal>
<ItemizedList>
<ListItem>
<Para>
When remembering a <Literal remap="tt">file</Literal> or a <Literal remap="tt">directory</Literal>, the
corresponding inode will be saved in memory. The basic reason is that
the inode is essential for finding the blocks of the file or the
directory.
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect2>
<Sect2>
<Title>set</Title>
<Para>
<Screen>
Syntax: set [text || hex] arg1 [arg2 arg3 ...]
or
Syntax: set variable=value
</Screen>
The <Command>set</Command> command is used to modify the current data.
The <Command>set general command</Command> behavior is depended on whether you are editing a
specific object, or none.
</Para>
<Para>
<ItemizedList>
<ListItem>
<Para>
In the case where Type is <Command>none</Command>, the first syntax should be
used. The set command affects the data starting at the current
highlighted position in the edited block.
<ItemizedList>
<ListItem>
<Para>
When using the <Command>set hex</Command> command, a list of
hexadecimal bytes should follow.
</Para>
</ListItem>
<ListItem>
<Para>
When using the <Command>set text</Command> command, it should be followed
by a text string.
</Para>
</ListItem>
</ItemizedList>
Examples:
<Screen>
set hex 09 0a 0b 0c 0d 0e 0f
set text Linux is just great !
</Screen>
</Para>
</ListItem>
<ListItem>
<Para>
In the case where Type is defined, the second syntax should be used.
The set commands just sets the variable <Emphasis>variable</Emphasis> with the
value <Emphasis>value</Emphasis>.
</Para>
</ListItem>
</ItemizedList>
In any case, the data is only changed in memory. For an actual update to the
disk, use the <Command>writedata</Command> command.
</Para>
</Sect2>
<Sect2>
<Title>setdevice</Title>
<Para>
<Screen>
Syntax: setdevice device
</Screen>
The <Command>setdevice</Command> command is described at section <XRef LinkEnd="setdevice-ref">.
</Para>
</Sect2>
<Sect2>
<Title>setoffset</Title>
<Para>
<Screen>
Syntax: setoffset [block || type] [+|-]offset
</Screen>
The <Command>setoffset</Command> command is used to move asynchronously inside the file
system. It is considered a low level command, and usually should not be used
when editing an ext2 filesystem, simply because movement is better
utilized through the specific ext2 commands.
</Para>
<Para>
The <Command>offset</Command> is in bytes, and meanwhile should be positive and smaller
than 2GB.
</Para>
<Para>
Use of the <Command>block</Command> modifier changes the counting unit to block.
</Para>
<Para>
Use of the <Literal remap="tt">+ or -</Literal> modifiers signals that the offset is relative to
the current position.
</Para>
<Para>
use of the <Literal remap="tt">type</Literal> modifier is allowed only with relative offset. This
modifier will multiply the offset by the size of the current type.
</Para>
</Sect2>
<Sect2>
<Title>settype</Title>
<Para>
<Screen>
Syntax: settype type || [none | hex]
</Screen>
The <Command>settype</Command> command is used to move apply the object definitions of
the type <Emphasis>type</Emphasis> on the current position. It is considered a low level
command and usually should not be used when editing an ext2 filesystem since
EXT2ED provides better tools. It is of-course very useful when editing a
non-ext2 filesystem and using user-defined objects.
</Para>
<Para>
When <Emphasis>type</Emphasis> is <Emphasis>hex</Emphasis> or <Emphasis>none</Emphasis>, the data will be displayed as
a hex and text dump.
</Para>
</Sect2>
<Sect2>
<Title>show</Title>
<Para>
<Screen>
Syntax: show
</Screen>
The <Command>show</Command> command will show the data of the current object at the
current position on the main display window. It will also update the status
window with type specific information. It may be necessary to use
<Command>pgdn</Command> and <Command>pgup</Command> to view the entire data.
</Para>
</Sect2>
<Sect2>
<Title>writedata</Title>
<Para>
<Screen>
Syntax: writedata
</Screen>
The <Command>writedata</Command> command will update the disk with the object data that
is currently in memory. This is the point at which actual change is made to
the filesystem. Without this command, the edited data will not have any
effect. Write access should be allowed for a successful update.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>Editing an ext2 filesystem</Title>
<Para>
In order to edit an ext2 filesystem, you should, of course, know the structure
of the ext2 filesystem. If you feel that you lack some knowledge in this
area, I suggest that you do some of the following:
<ItemizedList>
<ListItem>
<Para>
Read the supplied ext2 technical information. I tried to summarize
the basic information which is needed to get you started.
</Para>
</ListItem>
<ListItem>
<Para>
Get the slides that Remy Card (The author of the ext2 filesystem)
prepared concerning the ext2 filesystem.
</Para>
</ListItem>
<ListItem>
<Para>
Read the kernel sources.
</Para>
</ListItem>
</ItemizedList>
At this point, you should be familiar with the following terms:
<Literal remap="tt">block, inode, superblock, block groups, block allocation bitmap, inode
allocation bitmap, group descriptors, file, directory.</Literal>Most of the above
are objects in EXT2ED.
</Para>
<Para>
When editing an ext2 filesystem it is recommended that you use the ext2
specific commands, rather then the general commands <Command>setoffset</Command> and
<Command>settype</Command>, mainly because:
<OrderedList>
<ListItem>
<Para>
In most cases it will be unreliable, and will display incorrect
information.
Sometimes in order to edit an object, EXT2ED needs the information
of some other related objects. For example, when editing a
directory, EXT2ED needs access to the inode of the edited directory.
Simply setting the type to a directory <Literal remap="tt">will be unreliable</Literal>,
since the object assumes that you passed through its inode to reach
it, and expects this information, which isn't initialized if you
directly set the type to a directory.
</Para>
</ListItem>
<ListItem>
<Para>
EXT2ED offers far better tools for handling the ext2 filesystem
using the ext2 specific commands.
</Para>
</ListItem>
</OrderedList>
</Para>
</Sect1>
<Sect1>
<Title>ext2 general commands</Title>
<Para>
The <Literal remap="tt">ext2 general commands</Literal> are available only when you are editing an
ext2 filesystem. They are <Literal remap="tt">general</Literal> in the sense that they are not
specific to some object, and can be invoked anytime.
</Para>
<Sect2 id="general-superblock">
<Title>super</Title>
<Para>
<Screen>
Syntax: super
</Screen>
The <Command>super</Command> command will "bring you" to the main superblock copy. It
will automatically set the object type to <Literal remap="tt">ext2_super_block</Literal>. Then you
will be able to view and edit the superblock. When you are in the
superblock, other commands will be available.
</Para>
</Sect2>
<Sect2>
<Title>group</Title>
<Para>
<Screen>
Syntax: group [number]
</Screen>
The <Command>group</Command> command will "bring you" to the main copy of the
<Emphasis>number</Emphasis> group descriptor. It will automatically set the object type to
<Literal remap="tt">ext2_group_desc</Literal>. Then you will be able to view and edit the group
descriptor entry. When you are there, other commands will be available.
</Para>
</Sect2>
<Sect2>
<Title>cd</Title>
<Para>
<Screen>
Syntax: cd path
</Screen>
The <Command>cd</Command> command will let you travel in the filesystem in the nice way
that the mounted filesystem would have let you.
</Para>
<Para>
The <Command>cd</Command> command is a complicated command. Although it may sound
simple at first, an implementation of a typical cd requires passing through
the group descriptors, inodes, directory entries, etc. For example:
</Para>
<Para>
The innocent cd /usr command can be done by using more primitive
EXT2ED commands in the following way (It is implemented exactly this way):
<OrderedList>
<ListItem>
<Para>
Using <Command>group 0</Command> to go to the first group descriptor.
</Para>
</ListItem>
<ListItem>
<Para>
Using <Command>inode</Command> to get to the Bad blocks inode.
</Para>
</ListItem>
<ListItem>
<Para>
Using <Command>next</Command> to pass to the root directory inode.
</Para>
</ListItem>
<ListItem>
<Para>
Using <Command>dir</Command> to see the directory.
</Para>
</ListItem>
<ListItem>
<Para>
Using <Command>next</Command> until we find the directory usr.
</Para>
</ListItem>
<ListItem>
<Para>
Using <Command>followinode</Command> to pass to the inode corresponding to usr.
</Para>
</ListItem>
<ListItem>
<Para>
Using <Command>dir</Command> to see the directory of /usr.
</Para>
</ListItem>
</OrderedList>
And those commands aren't that primitive; For example, the tracing of the
blocks which belong to the root directory is done automatically by the dir
command behind the scenes, and the followinode command will automatically
"run" to the correct group descriptor in order to find the required inode.
</Para>
<Para>
The path to the <Command>general cd</Command> command needs to be a full pathname -
Starting from <Filename>/</Filename>. The <Command>cd</Command> command stops at the last reachable
point, which can be a directory entry, in which case the type will be set to
<Literal remap="tt">dir</Literal>, or an inode, in which case the type will be set to
<Literal remap="tt">ext2_inode</Literal>. Symbolic links (Only fast symbolic links, meanwhile) are
automatically followed (if they are not across filesystems, of-course). If
the type is set to <Literal remap="tt">dir</Literal>, you can use a path relative to the
"current directory".
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>The superblock</Title>
<Para>
The superblock can always be reached by the ext2 general command
<Command>super</Command>. Cross reference section <XRef LinkEnd="general-superblock">.
</Para>
<Para>
The status window will show you which copy of the superblock copies you are
currently editing.
</Para>
<Para>
The main data window will show you the values of the various superblock
variables, along with some interpretation of the values.
</Para>
<Para>
Data can be changed with the <Command>set</Command> and <Command>writedata</Command> commands.
<Screen>
For example, set s_r_blocks_count=1400 will reserve 1400 blocks for root.
</Screen>
</Para>
<Sect2>
<Title>gocopy</Title>
<Para>
<Screen>
Syntax: gocopy number
</Screen>
The <Command>gocopy</Command> command will "bring you" to the backup copy <Emphasis>number</Emphasis>
of the superblock copies. <Command>gocopy 0</Command>, for example, will bring you to
the main copy.
</Para>
</Sect2>
<Sect2>
<Title>setactivecopy</Title>
<Para>
<Screen>
Syntax: setactivecopy
</Screen>
The <Command>setactivecopy</Command> command will copy the contents of the current
superblock copy onto the contents of the main copy. It will also switch to
editing of the main copy. No actual data is written to disk, of-course,
until you issue the <Command>writedata</Command> command.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>The group descriptors</Title>
<Para>
The group descriptors can be edited by the <Command>group</Command> command.
</Para>
<Para>
The status window will indicate the current group descriptor, the total
number of group descriptors (and hence of group blocks), and the backup copy
number.
</Para>
<Para>
The main data window will just show you the values of the various variables.
</Para>
<Para>
Basically, you can use the <Command>next</Command> and <Command>prev</Command> commands, along with the
<Command>set</Command> command, to modify the group descriptors.
</Para>
<Para>
The group descriptors object is a junction, from which you can reach:
<ItemizedList>
<ListItem>
<Para>
The inode table of the corresponding block group (the <Literal remap="tt">inode</Literal>
command)
</Para>
</ListItem>
<ListItem>
<Para>
The block allocation bitmap (the <Literal remap="tt">blockbitmap</Literal> command)
</Para>
</ListItem>
<ListItem>
<Para>
The inode allocation bitmap (the <Literal remap="tt">inodebitmap</Literal> command)
</Para>
</ListItem>
</ItemizedList>
</Para>
<Sect2>
<Title>blockbitmap</Title>
<Para>
<Screen>
Syntax: blockbitmap
</Screen>
The <Command>blockbitmap</Command> command will let you edit the block bitmap allocation
block of the current group block.
</Para>
</Sect2>
<Sect2>
<Title>entry</Title>
<Para>
<Screen>
Syntax: entry number
</Screen>
The <Command>entry</Command> command will move you to the <Emphasis>number</Emphasis> group descriptor in the
group descriptors table.
</Para>
</Sect2>
<Sect2>
<Title>inode</Title>
<Para>
<Screen>
Syntax: inode
</Screen>
The <Command>inode</Command> command will pass you to the first inode in the current
group block.
</Para>
</Sect2>
<Sect2>
<Title>inodebitmap</Title>
<Para>
<Screen>
Syntax: inodebitmap
</Screen>
The <Command>inodebitmap</Command> command will let you edit the inode bitmap allocation
block of the current group block.
</Para>
</Sect2>
<Sect2>
<Title>next</Title>
<Para>
<Screen>
Syntax: next [number]
</Screen>
The <Command>next</Command> command will pass to the next <Emphasis>number</Emphasis> group
descriptor. If <Emphasis>number</Emphasis> is omitted, <Emphasis>number=1</Emphasis> is assumed.
</Para>
</Sect2>
<Sect2>
<Title>prev</Title>
<Para>
<Screen>
Syntax: prev [number]
</Screen>
The <Command>prev</Command> command will pass to the previous <Emphasis>number</Emphasis> group
descriptor. If <Emphasis>number</Emphasis> is omitted, <Emphasis>number=1</Emphasis> is assumed.
</Para>
</Sect2>
<Sect2>
<Title>setactivecopy</Title>
<Para>
<Screen>
Syntax: setactivecopy
</Screen>
The <Command>setactivecopy</Command> command copies the contents of the current group
descriptor, to its main copy. The updated main copy will then be shown. No
actual change is made to the disk until you issue the <Command>writedata</Command>
command.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>The inode</Title>
<Para>
An inode can be reached by the following two ways:
<ItemizedList>
<ListItem>
<Para>
Using <Command>inode</Command> from the corresponding group descriptor.
</Para>
</ListItem>
<ListItem>
<Para>
Using <Command>followinode</Command> from a directory entry.
</Para>
</ListItem>
<ListItem>
<Para>
Using the <Command>cd</Command> command with the pathname to the file.
For example, <Command>cd /usr/src/ext2ed/ext2ed.h</Command>
</Para>
</ListItem>
</ItemizedList>
</Para>
<Para>
The status window will indicate:
<ItemizedList>
<ListItem>
<Para>
The current global inode number.
</Para>
</ListItem>
<ListItem>
<Para>
The total total number of inodes.
</Para>
</ListItem>
<ListItem>
<Para>
On which block group the inode is allocated.
</Para>
</ListItem>
<ListItem>
<Para>
The total number of inodes in this group block.
</Para>
</ListItem>
<ListItem>
<Para>
The index of the current inode in the current group block.
</Para>
</ListItem>
<ListItem>
<Para>
The type of the inode (file, directory, special, etc).
</Para>
</ListItem>
</ItemizedList>
</Para>
<Para>
The main data window, in addition to the list of variables, will contain
some interpretations on the right side.
</Para>
<Para>
If the inode corresponds to a file, you can use the <Command>file</Command> command to
edit the file.
</Para>
<Para>
If the inode is an inode of a directory, you can use the <Command>dir</Command> command
to edit the directory.
</Para>
<Sect2>
<Title>dir</Title>
<Para>
<Screen>
Syntax: dir
</Screen>
If the inode mode corresponds to a directory (shown on the status window),
you can enter directory mode editing by using <Literal remap="tt">dir</Literal>.
</Para>
</Sect2>
<Sect2>
<Title>entry</Title>
<Para>
<Screen>
Syntax: entry number
</Screen>
The <Command>entry</Command> command will move you to the <Emphasis>number</Emphasis> inode in the
current inode table.
</Para>
</Sect2>
<Sect2>
<Title>file</Title>
<Para>
<Screen>
Syntax: file
</Screen>
If the inode mode corresponds to a file (shown on the status window),
you can enter file mode editing by using <Command>file</Command>.
</Para>
</Sect2>
<Sect2>
<Title>group</Title>
<Para>
<Screen>
Syntax: group
</Screen>
The <Command>group</Command> command is used to go to the group descriptor of the
current group block.
</Para>
</Sect2>
<Sect2>
<Title>next</Title>
<Para>
<Screen>
Syntax: next [number]
</Screen>
The <Command>next</Command> command will pass to the next <Emphasis>number</Emphasis> inode.
If <Emphasis>number</Emphasis> is omitted, <Emphasis>number=1</Emphasis> is assumed.
</Para>
</Sect2>
<Sect2>
<Title>prev</Title>
<Para>
<Screen>
Syntax: prev [number]
</Screen>
The <Command>prev</Command> command will pass to the previous <Emphasis>number</Emphasis> inode.
If <Emphasis>number</Emphasis> is omitted, <Emphasis>number=1</Emphasis> is assumed.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>The file</Title>
<Para>
When editing a file, EXT2ED offers you a both a continuous and a true
fragmented view of the file - The file is still shown block by block with
the true block number at each stage and EXT2ED offers you commands which
allow you to move between the <Literal remap="tt">file blocks</Literal>, while finding the
allocated blocks by using the inode information behind the scenes.
</Para>
<Para>
Aside from this, the editing is just a <Literal remap="tt">hex editing</Literal> - You move the
cursor in the current block of the file by using <Command>next</Command> and
<Command>prev</Command>, move between blocks by <Command>nextblock</Command> and <Command>prevblock</Command>,
and make changes by the <Command>set</Command> command. Note that the set command is
overridden here - There are no variables. The <Command>writedata</Command> command will
update the current block to the disk.
</Para>
<Para>
Reaching a file can be done by using the <Command>file</Command> command from its inode.
The inode can be reached by any other means, for example, by the
<Command>cd</Command> command, if you know the file name.
</Para>
<Para>
The status window will indicate:
<ItemizedList>
<ListItem>
<Para>
The global block number.
</Para>
</ListItem>
<ListItem>
<Para>
The internal file block number.
</Para>
</ListItem>
<ListItem>
<Para>
The file offset.
</Para>
</ListItem>
<ListItem>
<Para>
The file size.
</Para>
</ListItem>
<ListItem>
<Para>
The file inode number.
</Para>
</ListItem>
<ListItem>
<Para>
The indirection level - Whether it is a direct block (0), indirect
(1), etc.
</Para>
</ListItem>
</ItemizedList>
</Para>
<Para>
The main data window will display the file either in hex mode or in text
mode, select-able by the <Command>display</Command> command.
</Para>
<Para>
In hex mode, EXT2ED will display offsets in the current block, along with a
text and hex dump of the current block.
</Para>
<Para>
In either case the <Literal remap="tt">current place</Literal> will be highlighted. In the hex mode
it will be always highlighted, while in the text mode it will be highlighted
if the character is display-able.
</Para>
<Sect2>
<Title>block</Title>
<Para>
<Screen>
Syntax: block block_num
</Screen>
The <Command>block</Command> command is used to move inside the file. The
<Emphasis>block_num</Emphasis> argument is the requested internal file block number. A
value of 0 will reach the beginning of the file.
</Para>
</Sect2>
<Sect2>
<Title>display</Title>
<Para>
<Screen>
Syntax: display [text || hex]
</Screen>
The <Command>display</Command> command changes the display mode of the file.
<Command>display
hex</Command> will switch to <Command>hex mode</Command>, while <Command>display text</Command> will switch
to text mode. The default mode when no <Command>display</Command> command is issued is
<Command>hex mode</Command>.
</Para>
</Sect2>
<Sect2>
<Title>inode</Title>
<Para>
<Screen>
Syntax: inode
</Screen>
The <Command>inode</Command> command will return to the inode of the current file.
</Para>
</Sect2>
<Sect2>
<Title>next</Title>
<Para>
<Screen>
Syntax: next [num]
</Screen>
The <Command>next</Command> command will pass to the next byte in the file. If
<Emphasis>num</Emphasis> is supplied, it will pass to the next <Emphasis>num</Emphasis> bytes.
</Para>
</Sect2>
<Sect2>
<Title>nextblock</Title>
<Para>
<Screen>
Syntax: nextblock [num]
</Screen>
The <Command>nextblock</Command> command will pass to the next block in the file. If
<Emphasis>num</Emphasis> is supplied, it will pass to the next <Emphasis>num</Emphasis> blocks.
</Para>
</Sect2>
<Sect2>
<Title>prev</Title>
<Para>
<Screen>
Syntax: prev [num]
</Screen>
The <Command>prev</Command> command will pass to the previous byte in the file. If
<Emphasis>num</Emphasis> is supplied, it will pass to the previous <Emphasis>num</Emphasis> bytes.
</Para>
</Sect2>
<Sect2>
<Title>prevblock</Title>
<Para>
<Screen>
Syntax: prevblock [num]
</Screen>
The <Command>nextblock</Command> command will pass to the previous block in the file. If
<Emphasis>num</Emphasis> is supplied, it will pass to the previous <Emphasis>num</Emphasis> blocks.
</Para>
</Sect2>
<Sect2>
<Title>offset</Title>
<Para>
<Screen>
Syntax: offset file_offset
</Screen>
The <Command>offset</Command> command will move to the specified offset in the file.
</Para>
</Sect2>
<Sect2>
<Title>set</Title>
<Para>
<Screen>
Syntax: set [text || hex] arg1 [arg2 arg3 ...]
</Screen>
The <Command>file set</Command> command is working like the <Literal remap="tt">general set command</Literal>,
with <Literal remap="tt">type=none</Literal>. There are no variables.
</Para>
</Sect2>
<Sect2>
<Title>writedata</Title>
<Para>
<Screen>
Syntax: writedata
</Screen>
The <Command>writedata</Command> command will update the current file block in the disk.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>The directory</Title>
<Para>
When editing a file, EXT2ED analyzes for you both the allocation blocks of
the directory entries, and the directory entries.
</Para>
<Para>
Each directory entry is displayed on one row. You can move the highlighted
entry with the usual <Command>next</Command> and <Command>prev</Command> commands, and "dive in"
with the <Command>followinode</Command> command.
</Para>
<Para>
The status window will indicate:
<ItemizedList>
<ListItem>
<Para>
The directory entry number.
</Para>
</ListItem>
<ListItem>
<Para>
The total number of directory entries in this directory.
</Para>
</ListItem>
<ListItem>
<Para>
The current global block number.
</Para>
</ListItem>
<ListItem>
<Para>
The current offset in the entire directory - When viewing the
directory as a continuous file.
</Para>
</ListItem>
<ListItem>
<Para>
The inode number of the directory itself.
</Para>
</ListItem>
<ListItem>
<Para>
The indirection level - Whether it is a direct block (0), indirect
(1), etc.
</Para>
</ListItem>
</ItemizedList>
</Para>
<Sect2>
<Title>cd</Title>
<Para>
<Screen>
Syntax: cd [path]
</Screen>
The <Command>cd</Command> command is used in the usual meaning, like the global cd
command.
<ItemizedList>
<ListItem>
<Para>
If <Emphasis>path</Emphasis> is not specified, the current directory entry is
followed.
</Para>
</ListItem>
<ListItem>
<Para>
<Emphasis>path</Emphasis> can be relative to the current directory.
</Para>
</ListItem>
<ListItem>
<Para>
<Emphasis>path</Emphasis> can also end up in a file, in which case the file inode
will be reached.
</Para>
</ListItem>
<ListItem>
<Para>
Symbolic link (fast only, meanwhile) is automatically followed.
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect2>
<Sect2>
<Title>entry</Title>
<Para>
<Screen>
Syntax: entry [entry_num]
</Screen>
The <Command>entry</Command> command sets <Emphasis>entry_num</Emphasis> as the current directory
entry.
</Para>
</Sect2>
<Sect2>
<Title>followinode</Title>
<Para>
<Screen>
Syntax: followinode
</Screen>
The <Command>followinode</Command> command will move you to the inode pointed by the
current directory entry.
</Para>
</Sect2>
<Sect2>
<Title>inode</Title>
<Para>
<Screen>
Syntax: inode
</Screen>
The <Command>inode</Command> command will return you to the parent inode of the whole
directory listing.
</Para>
</Sect2>
<Sect2>
<Title>next</Title>
<Para>
<Screen>
Syntax: next [num]
</Screen>
The <Command>next</Command> command will pass to the next directory entry.
If <Emphasis>num</Emphasis> is supplied, it will pass to the next <Emphasis>num</Emphasis> entries.
</Para>
</Sect2>
<Sect2>
<Title>prev</Title>
<Para>
<Screen>
Syntax: prev [num]
</Screen>
The <Command>prev</Command> command will pass to the previous directory entry.
If <Emphasis>num</Emphasis> is supplied, it will pass to the previous <Emphasis>num</Emphasis> entries.
</Para>
</Sect2>
<Sect2>
<Title>writedata</Title>
<Para>
<Screen>
Syntax: writedata
</Screen>
The <Command>writedata</Command> command will write the current directory entry to the
disk.
</Para>
</Sect2>
</Sect1>
<Sect1 id="block-bitmap">
<Title>The block allocation bitmap</Title>
<Para>
The <Literal remap="tt">block allocation bitmap</Literal> of any block group can be reached from
the corresponding group descriptor.
</Para>
<Para>
You will be offered a bit listing of the entire blocks in the group. The
current block will be highlighted and its number will be displayed in the
status window.
</Para>
<Para>
A value of "1" means that the block is allocated, while a value of "0"
signals that it is free. The value is also interpreted in the status
window. You can use the usual <Command>next/prev</Command> commands, along with the
<Command>allocate/deallocate</Command> commands.
</Para>
<Sect2>
<Title>allocate</Title>
<Para>
<Screen>
Syntax: allocate [num]
</Screen>
The <Command>allocate</Command> command allocates <Emphasis>num</Emphasis> blocks, starting from the
highlighted position. If <Emphasis>num</Emphasis> is not specified, <Emphasis>num=1</Emphasis> is assumed.
Of-course, no actual change is made until you issue a <Command>writedata</Command> command.
</Para>
</Sect2>
<Sect2>
<Title>deallocate</Title>
<Para>
<Screen>
Syntax: deallocate [num]
</Screen>
The <Command>deallocate</Command> command deallocates <Emphasis>num</Emphasis> blocks, starting from the
highlighted position. If <Emphasis>num</Emphasis> is not specified, <Emphasis>num=1</Emphasis> is assumed.
Of-course, no actual change is made until you issue a <Command>writedata</Command> command.
</Para>
</Sect2>
<Sect2>
<Title>entry</Title>
<Para>
<Screen>
Syntax: entry [entry_num]
</Screen>
The <Command>entry</Command> command sets the current highlighted block to
<Emphasis>entry_num</Emphasis>.
</Para>
</Sect2>
<Sect2>
<Title>next</Title>
<Para>
<Screen>
Syntax: next [num]
</Screen>
The <Command>next</Command> command will pass to the next bit, which corresponds to the
next block. If <Emphasis>num</Emphasis> is supplied, it will pass to the next <Emphasis>num</Emphasis>
bits.
</Para>
</Sect2>
<Sect2>
<Title>prev</Title>
<Para>
<Screen>
Syntax: prev [num]
</Screen>
The <Command>prev</Command> command will pass to the previous bit, which corresponds to the
previous block. If <Emphasis>num</Emphasis> is supplied, it will pass to the previous
<Emphasis>num</Emphasis> bits.
</Para>
</Sect2>
</Sect1>
<Sect1>
<Title>The inode allocation bitmap</Title>
<Para>
The <Literal remap="tt">inode allocation bitmap</Literal> is very similar to the block allocation
bitmap explained above. It is also reached from the corresponding group
descriptor. Please refer to section <XRef LinkEnd="block-bitmap">.
</Para>
</Sect1>
<Sect1>
<Title>Filesystem size limitation</Title>
<Para>
While an ext2 filesystem has a size limit of <Literal remap="tt">4 TB</Literal>, EXT2ED currently
<Literal remap="tt">can't</Literal> handle filesystems which are <Literal remap="tt">bigger than 2 GB</Literal>.
</Para>
<Para>
I am sorry for the inconvenience. This will hopefully be fixed in future
releases.
</Para>
</Sect1>
<Sect1>
<Title>Copyright</Title>
<Para>
EXT2ED is Copyright (C) 1995 Gadi Oxman.
</Para>
<Para>
EXT2ED is hereby placed under the GPL - Gnu Public License. You are free and
welcome to copy, view and modify the sources. My only wish is that my
copyright presented above will be left and that a list of the bug fixes,
added features, etc, will be provided.
</Para>
<Para>
The entire EXT2ED project is based, of-course, on the kernel sources. The
<Literal remap="tt">ext2.descriptors</Literal> distributed with EXT2ED is a slightly modified
version of the main ext2 include file, /usr/include/linux/ext2_fs.h. Follows
the original copyright:
</Para>
<Para>
<Screen>
/*
* linux/include/linux/ext2_fs.h
*
* Copyright (C) 1992, 1993, 1994, 1995
* Remy Card (card@masi.ibp.fr)
* Laboratoire MASI - Institut Blaise Pascal
* Universite Pierre et Marie Curie (Paris VI)
*
* from
*
* linux/include/linux/minix_fs.h
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
</Screen>
</Para>
</Sect1>
<Sect1>
<Title>Acknowledgments</Title>
<Para>
EXT2ED was constructed as a student project in the software
laboratory of the faculty of electrical-engineering in the
<Literal remap="tt">Technion - Israel's institute of technology</Literal>.
</Para>
<Para>
At first, I would like to thank <PersonName><FirstName>Avner</FirstName> <SurName>Lottem</SurName></PersonName> and <PersonName><Honorific>Doctor</Honorific> <FirstName>Ilana</FirstName> <SurName>David</Surname></PersonName> for their interest and assistance in this project.
</Para>
<Para>
I would also like to thank the following people, who were involved in the
design and implementation of the ext2 filesystem kernel code and support
utilities:
<ItemizedList>
<ListItem>
<Para>
<PersonName><FirstName>Remy</FirstName> <SurName>Card</SurName></PersonName>
Who designed, implemented and maintains the ext2 filesystem kernel
code, and some of the ext2 utilities. Remy Card is also the author
of several helpful slides concerning the ext2 filesystem.
Specifically, he is the author of <Literal remap="tt">File Management in the Linux
Kernel</Literal> and of <Literal remap="tt">The Second Extended File System - Current State,
Future Development</Literal>.
</Para>
</ListItem>
<ListItem>
<Para>
<PersonName><FirstName>Wayne</FirstName> <SurName>Davison</SurName></PersonName>
Who designed the ext2 filesystem.
</Para>
</ListItem>
<ListItem>
<Para>
<PersonName><FirstName>Stephen</FirstName> <Surname>Tweedie</SurName></PersonName>
Who helped designing the ext2 filesystem kernel code and wrote the
slides <Literal remap="tt">Optimizations in File Systems</Literal>.
</Para>
</ListItem>
<ListItem>
<Para>
<PersonName><FirstName>Theodore</FirstName> <SurName>Ts'o</SurName></PersonName>
Who is the author of several ext2 utilities and of the ext2 library
<Literal remap="tt">libext2fs</Literal> (which I didn't use, simply because I didn't know
it exists when I started to work on my project).
</Para>
</ListItem>
</ItemizedList>
</Para>
<Para>
Lastly, I would like to thank, of-course, <PersonName><FirstName>Linus</FirstName> <SurName>Torvalds</SurName></PersonName> and the
Linux community for providing all of us with such a great operating
system.
</Para>
<Para>
Please contact me in a case of bug report, suggestions, or just about
anything concerning EXT2ED.
</Para>
<Para>
Enjoy,
</Para>
<Para>
Gadi Oxman <tgud@tochnapc2.technion.ac.il>
</Para>
<Para>
Haifa, August 95
</Para>
</Sect1>
</Article>
|