View the dumped inode in a readable format.
# xxd debugfs-dump | less
Every entry consist of five fields. For the first two fields the bytes representing the field comes in backward order. That means the first byte is the least significant.
Description of the fields.
Four bytes - Inode number.
Two bytes - Directory entry length.
One byte - Filename length (1-255).
One byte - File type (0-7).
0 = Unknown
1 = Regular file
2 = Directory
3 = Character device
4 = Block device
5 = FIFO
6 = SOCK
7 = Symbolic link
Filename (1-255 characters).
If an entry in the directory is to be deleted, then the second field at the entry before will be increased by the value of the deleted entrys second field.
If a filename is renamed to a shorter one, then the third field will be decreased.
The first entry you will see is the directory itself, represented by a dot.
Suppose that we have the following directory entry.
c1 02 0e 00 40 00 05 01 'u' 't' 'i' 'l' 's'
Then the inode would be e02c1 in hexadecimal representation or 918209 in decimal. The next entry would be located after 64 bytes (40 in hex). We see that the filename consist of 5 bytes ("utils") and the file type (01) is a regular file.
Now recalculate the directories inode numbers in decimal representation.
If you do not like to calculate this by hand I have made a small program in C that will do this for you. The program takes as input a directory dump (created by debugfs as described in Section 4). The output (at stdout) consist of each entrys inode number and filename.
Before you run the program you need to load the dump into a hexeditor and change the directory entry length field at the entry before the one you want to get back. But it is simple. If we name the field before to x and the field at the entry you want to get back to y. Then change x to x - y.
The program called e2dirana (ext2fs directory analyse) can be found at http://www.matematik.su.se/~tomase/ext2fs-undeletion/
Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:01