|
|
This example illustrates how to create adb scripts to display the contents of a directory file and the inode map of a UNIX file system. The directory file is assumed to be named dir, and contains a variety of files. The UNIX file system is assumed to be associated with the device file /dev/src, and has the necessary permissions for you to read it.
To display a directory file, create an appropriate script, then start adb with the name of the directory, redirecting its input to the script.
First, create a script file named script. A directory file normally contains one or more entries. Each entry consists of an unsigned inumber and a 14-character filename. To display this information, add the following command to the script file:
0,\5?ut14cnThis command displays one entry for each line, separating the number and filename with a tab. The display continues until the first five entries have been printed. If this command is placed at the beginning of the script, adb displays the strings as headings for the columns of numbers:
="inumber"8t"Name"Once you have the script file, type:
adb dir - <script(The dash (-) is used to prevent adb from attempting to open a core file.) The adb program reads the commands from the script and displays the following:
inumber name 652 . 82 .. 5971 cap.c 5323 cap 0 ppTo display the inode table of a file system, you must create a new script, then start adb with the filename of the device associated with the file system (such as the hard disk drive).
The structure of an inode table entry is defined in the file /usr/include/sys/ino.h. Each inode entry includes:
The inode table starts at the address ``04000'' of the filesystem. This is the address of the beginning of block 2 of the file system.
Display the first entry by typing:
04000,\1?onororon2un40b3Y2naSeveral Newlines are inserted within the display to make it easier to read.
To use the script on the inode table of /dev/src, type:
adb /dev/src - <script(Again, the dash (-) is used to prevent an unwanted core file.) Each entry in the inode table display has the following form:
LO.: O4O755 046 03 03 640 0 0121 06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1986 Dec 4 13:55:49 1986 Nov 20 20:46:13 1986 Nov 20 20:46:13