fsdb(1M-ufs) fsdb(1M-ufs)
NAME
fsdb (ufs) - ufs file system debugger
SYNOPSIS
fsdb [-F ufs] [genericoptions] special [-]
DESCRIPTION
fsdb can be used to patch up a damaged ufs file system after a crash.
It has conversions to translate block and i-numbers into their corre-
sponding disk addresses. Also included are mnemonic offsets to access
different parts of an i-node. These greatly simplify the process of
correcting control block entries or descending the file system tree.
fsdb contains several error-checking routines to verify i-node and
block addresses. These can be disabled if necessary by invoking fsdb
with the optional "-" argument or by the use of the O symbol. (fsdb
reads the i-size and f-size entries from the superblock of the file
system as the basis for these checks.)
OPTIONS
-F ufs Specifies the ufs-FSType.
genericoptions Options supported by the generic fsdb command.
Numbers are considered decimal by default. Octal numbers must be pre-
fixed with a zero. During any assignment operation, numbers are
checked for a possible truncation error due to a size mismatch between
source and destination.
fsdb reads a block at a time and will therefore work with raw as well
as block I/O. A buffer management routine is used to retain commonly
used blocks of data in order to reduce the number of read system
calls. All assignment operations result in an immediate write-through
of the corresponding block.
The symbols recognized by fsdb are:
# absolute address
#i convert from i-number to i-node address
#b convert to block address
#f convert to fragment address
#fn same as above, except the fragment is regarded as having
length n, where n is either 1, 2, ..., MAXFRAG frags
c# convert from cylinder group summary number to cylinder
group summary address
d# directory slot offset
Page 1 Reliant UNIX 5.44 Printed 11/98
fsdb(1M-ufs) fsdb(1M-ufs)
d#i same as above, except instructs fsdb to skip to the inode
i associated with the directory
d#c same as above, except instructs fsdb to skip to the
cylinder group c associated with the directory
+, -, *, / address arithmetic
q quit
>, < save, restore an address
= numerical assignment
=+ incremental assignment
=- decremental assignment
=" character string assignment
O error checking flip flop
p general print facilities
f file print facility
B byte mode
S word (short) mode
L double word (int) mode
I i-node mode
R diRectory mode
W same as S
D same as L
! escape to shell
? print a help menu
N open a new file system for debugging
C print current specifications for the file system being
debugged
P print current state of fsdb global parameters
F print state of current disk block buffers
Page 2 Reliant UNIX 5.44 Printed 11/98
fsdb(1M-ufs) fsdb(1M-ufs)
The print facilities generate a formatted output in various styles.
The current address is normalized to an appropriate boundary before
printing begins. It advances with the printing and is left at the
address of the last item printed. The output can be terminated at any
time by typing the delete character. If a number follows the p symbol,
that many entries are printed. A check is made to detect block boun-
dary overflows since logically sequential blocks are generally not
physically sequential. If a count of zero is used, all entries to the
end of the current block are printed.
The print options available are:
i print as i-nodes
d print as directories
s print as cylinder group summary structures
o print as octal words
x print as hexadecimal words
e print as decimal words
c print as characters
b print as octal bytes
The f symbol is used to print data blocks associated with the current
i-node. If followed by a number, that block of the file is printed.
(Blocks are numbered from zero.) The desired print option letter fol-
lows the block number, if present, or the f symbol. This print facil-
ity works for small as well as large files. It checks for special
devices and that the block pointers used to find the data are not
zero.
Dots, tabs, and spaces may be used as function delimiters but are not
necessary. A line with just a new-line character will increment the
current address by the size of the data type last printed. That is,
the address is set to the next byte, word, double word, directory
entry or i-node, allowing the user to step through a region of a file
system. Information is printed in a format appropriate to the data
type. Bytes, words and double words are displayed with the octal
address followed by the value in octal and decimal. A .B, .W or .D is
appended to the address for byte, word (short) and double word (int)
values, respectively. Directories are printed as a directory slot
offset followed by the decimal i-number and the character representa-
tion of the entry name. I-nodes are printed with labeled fields
describing each element.
Page 3 Reliant UNIX 5.44 Printed 11/98
fsdb(1M-ufs) fsdb(1M-ufs)
The following mnemonics are used for i-node examination and refer to
the current working i-node:
md mode
ln link count
uid user ID number
gid group ID number
sz file size
bc block count
a# data block numbers (0-13)
db# direct data block numbers (0-10)
ib# indirect data block numbers (11-13)
at access time
mt modification time
ct inode creation time
maj major device number
min minor device number
The basic syntax of fsdb is as follows:
[item][offset][print/replace]
where item is either a block, directory, cylinder group, or i-node
number, offset is a mnemonic for an i-node offset or any arbitrary
number of bytes, and print/replace will either print the specified
item in the indicated style or replace the specified item with the
specified value. Also note that a series of commands separated by car-
riage returns are functionally equivalent to the same series of com-
mands when typed on a single line.
EXAMPLES
386i prints i-number 386 in an i-node format. This now
becomes the current working i-node.
ln=4 changes the link count for the working i-node to 4.
ln=+1 increments the link count by 1.
Page 4 Reliant UNIX 5.44 Printed 11/98
fsdb(1M-ufs) fsdb(1M-ufs)
fc prints, in ASCII, block zero of the file associated
with the working i-node.
2i.fd prints the first 32 directory entries for the root i-
node of this file system.
d5i.fc changes the current i-node to that associated with the
5th directory entry (numbered from zero) found from
the above command. The first logical block of the file
is then printed in ASCII.
8192B.p0o prints the superblock of this file system in octal.
2i.a0b.d7=3 changes the i-number for the seventh directory slot in
the root directory to 3. This example also shows how
several operations can be combined on one command
line.
d7.nm="name" changes the name field in the directory slot to the
given string. Quotes are optional when used with nm if
the first character is alphabetic.
a2b.p0d prints the third block of the current i-node as direc-
tory entries.
NOTES
Careless use of fsdb will result in an inconsistent file system and
may cause information to be lost. Furthermore, it may not be fully
recoverable by fsck.
SEE ALSO
fsck(1M), generic fsdb(1M), dir(4-ufs), fs(4-ufs).
Page 5 Reliant UNIX 5.44 Printed 11/98