fsdb
PURPOSE
Debugs file systems.
SYNOPSIS
fsdb [ [ filesystem ] [ - ] ]
DESCRIPTION
Warning: This program is not intended for use with
diskette-based file systems because of the difference in
superblock structure and the general format of the file
system.
You can use the fsdb command to examine and patch a
damaged file system after a system crash. It allows you
to access blocks and i-numbers and to examine various
parts of an i-node. You can reference components of the
i-node symbolically. These features simplify procedures
for correcting control-block entries or for descending
the file-system tree.
The file system to be examined can be specified by a
block device name, a raw device name, or a mounted file
system name. In the latter case, fsdb determines the
associated file name by reading the file
/etc/filesystems.
Any numbers you enter are considered decimal by default,
unless you prefix them with a 0 (zero) to indicate an
octal number.
Because fsdb reads and writes one block at a time, it
works with raw as well as with block I/O. It uses a
buffer management routine to retain commonly used blocks
of data in order to reduce the number of read system
calls. All assignment operations write the corresponding
block immediately.
FLAG
- Disables the error checking routines used to verify
i-node and block addresses. The O subcommand toggles
these routines on and off. When these routines are
running, fsdb reads the i-size and f-size entries from
the superblock of the file system.
SUBCOMMANDS
The subcommands you give to fsdb are requests to display
or modify information. A display subcommand is a block
address optionally followed by a display format specifi-
cation. A field modification subcommand is similar to
the display subcommand but may include a subfield spec-
ification, an operator, and a value. An address specifi-
cation is a number optionally followed by a type
specifier and subfield specification.
The display subcommands are:
num Display data at absolute address
num.
i-numberi Display data at i-number.
block-addressb Display data at block-address.
directory-slot-offsetd Display data at directory-slot-
offset.
q Quit.
! Escape to the shell.
The display formats are:
p General display facilities
f File display facility.
You can step through the i-node information examining
each byte, word, or double word. Select the desired
display mode by entering one of the following subcom-
mands:
B Begin displaying in byte mode.
D Begin displaying in double word
mode.
W Begin displaying in word mode.
O Toggle error checking on or off.
Moving forward or backward through the i-node data is
done with the following symbols:
+num Move forward the specified number
of units currently in effect.
-num Move backward the specified
number of units currently in
effect.
The following symbols allow you to store the current
address and return to it conveniently:
>address Store address for later refer-
ence. If you do not specify
address, fsdb stores the current
address.
< Return to the previously stored
address.
The display format applied to the information at the
selected address is the one currently in effect. You may
receive an error message indicating improper alignment if
the address you specify does not fall on an even
boundary.
The display facilities display a formatted output in
various styles. The current address is normalized to an
appropriate boundary before display begins. It advances
with the displaying and is left at the address of the
last item displayed. The output can be ended at any time
by pressing INTERRUPT (Alt-Pause).
If you enter a number after the p symbol, fsdb displays
that number of entries. A check is made to detect block
boundary overflows because logically sequential blocks
are generally not physically sequential. If you enter a
count of zero, fsdb displays all entries to the end of
the current block.
The display formats available are:
i Display as i-nodes.
d Display as directories.
o Display as octal words.
e Display as decimal words.
c Display as characters.
b Display as octal bytes.
y Display as hex bytes.
Use the f symbol to display data blocks associated with
the current i-node. If you enter a number after f, fsdb
displays that block of the file. Block numbering begins
at zero. The desired display subcommand follows the
block number, if present, or the f symbol. The display
facility works for large as well as small files. It
checks for special devices and also checks the data are
not zero.
You can use dots (.), tabs, and spaces as subcommand
delimiters, but they are not necessary. Pressing just
the Enter key (entering a blank line) increments the
current address by the size of the data type last dis-
played. That is, the address is set to the next byte,
word, double word, directory entry or i-node, allowing
you to step through a region of a file system. fsdb dis-
plays information in a format appropriate to the data
type. Bytes, words and double words are displayed as an
octal address followed by the octal representation of the
data at that address and the decimal equivalent enclosed
in parentheses. fsdb adds a .B or .D to the end of the
address to indicate a display of byte or double word
values. It displays directories as a directory slot
offset followed by the decimal i-number and the character
representation of the entry name. It displays i-nodes
with labeled fields describing each element. The envi-
ronment variables NLLDATE and NLTIME control the formats
of the date and time.
The following mnemonics are used for the names of the
fields of an i-node and refer to the current working
i-node:
md Permission mode
ln Link count
uid User number
gid Group number
sz File size
an Data block numbers (0 - 12)
at Access time
mt Modification time
maj Major device number
min Minor device number.
The general form for assigning new values is:
mnemonic operator new-value
The fsdb command modifies the value of the field speci-
fied by mnemonic according to the operator and new-value.
Valid operators include:
= Assign new-value to the specified mnemonic.
_
=+ Increment the mnemonic by the specified new-value.
__
The default new-value is 1.
=- Decrease the mnemonic by the specified new-value.
__
The default new-value is 1.
=" Assign character string new-value to the specified
__
mnemonic.
EXAMPLES
The following examples show subcommands that you can use
after starting fsdb.
1. To display an i-node:
386i
This displays i-number "386" in i-node format. It
now becomes the current i-node.
2. To change the link count for the current i-node to
"4":
ln=4
3. To increase the link count of the current i-node by
"1":
ln=+1
4. To display part of the file associated with the
current i-node:
fc
This displays as ASCII text block zero of the file
associated with the current i-node.
5. To display entries of a directory:
2i.fd
This changes the current i-node to the root i-node
(i-node "2"), then displays the directory entries in
the first block associated with that i-node.
6. To go down a level of the directory tree:
d5i.fc
This changes the current i-node to the one associated
with directory entry "5". Then it displays the first
block of the file as ASCII text ("fc"). Directory
entries are numbered starting from 0 (zero).
7. To display a block when you know its block number:
1b.p0o
This displays the superblock (block "1") of file
system in octal.
8. To change the i-number of a directory entry:
2i.a0b.d7=3
This changes the i-number of directory entry "7" in
the root directory ("2i") to "3". This example also
shows how several operations can be combined on one
line.
9. To change the file name of a directory entry:
d7.nm="chap1.rec"
This changes the name field of directory entry "7" to
"chap1.rec".
10. To display a given block of the file associated with
the current i-node:
a2b.p0d
This displays block "2" of the current i-node as
directory entries.
RELATED INFORMATION
The following command: "fsck, dfsck."
The fs and dir files and the environment miscellaneous
facility in AIX Operating System Technical Reference.
The "Overview of International Character Support" in Man-
aging the AIX Operating System.