This example shows how to create adb scripts to display the contents of a directory and the i-node map of a file system. In the example, the directory is named dir and contains a variety of files. The file system is associated with the /dev/hd3 device file (/tmp), which has the necessary permissions to be read by the user.
To display a directory, create an appropriate script. A directory normally contains one or more entries. Each entry consists of an unsigned i-node number (i-number) and a 14-character file name. You can display this information by including a command in your script file. The adb debug program expects the object file to be an xcoff format file. This is not the case with a directory. The adb program indicates that the directory, because it is not an xcoff format file, has a text length of 0. Use the m command to indicate to the adb program that this directory has a text length of greater than 0. Therefore, display entries in your adb session by entering:
,0?m 360 0
For example, the following command displays the first 20 entries separating the i-node number and file name with a tab:
You can change the second number, 20, to specify the number of entries in the directory. If you place the following command at the beginning of the script, the adb program displays the strings as headings for each column of numbers:
Once you have created the script file, redirect it as input when you start the adb program with the name of your directory. For example, the following command starts the adb program on the geo directory using command input from the ddump script file:
adb geo - <ddump
The minus sign (-) prevents the adb program from opening a core file. The adb program reads the commands from the script file.
To display the i-node table of a file system, create a new script and then start the adb program with the file name of the device associated with the file system. The i-node table of a file system has a complex structure. Each entry contains:
The following is an example directory dump output:
inumber Name 0: 26 . 2 .. 27 .estate 28 adbsamp 29 adbsamp.c 30 calc.lex 31 calc.yacc 32 cbtest 68 .profile 66 .profile.bak 46 adbsamp2.c 52 adbsamp2 35 adbsamp.s 34 adbsamp2.s 48 forktst1.c 49 forktst2.c 50 forktst3.c 51 lpp&us1.name 33 adbsamp3.c 241 sample 198 adbsamp3 55 msgqtst.c 56 newsig.c
The i-node table starts at the address 02000. You can display the first entry by putting the following command in your script file:
The command specifies several new-line characters for the output display to make it easier to read.
To use the script file with the i-node table of the /dev/hd3 file, enter the following command:
adb /dev/hd3 - <script
Each entry in the display has the form:
02000: 073145 0163 0164 0141 0162 10356 28770 8236 25956 27766 25455 8236 25956 25206 1976 Feb 5 08:34:56 1975 Dec 28 10:55:15
adb Debug Program Overview
Using adb Expressions
Displaying and Manipulating the Source File with the adb Program
Example adb Program: adbsamp2
Example adb Program: adbsamp3