Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dumpfs(1M)

fsck(1M)

stat(2)

dir(4)

fs(4)

fsdb(1M)

NAME

fsdb − file system debugger

SYNOPSIS

/etc/fsdb special [−b block#] [−]

Remarks

Always execute fsck(1M) after having running fsdb.

DESCRIPTION

fsdb can be used to patch up a damaged file system after a crash.  It normally uses the first super block for the file system located at the beginning of the disk section as the effective super block.  If the −b flag is used, the block specified immediately after the flag is used as the super block for the file system.  An alternate super block will always be found at block ((SBSIZE + BBSIZE)/DEV_BSIZE), typically block 16. 

fsdb deals with the file system in terms of block fragments, which are the unit of addressing in the file system and the minimum unit of space allocation.  To avoid possible confusion, fragment is used to mean that, and block is reserved for the larger true block.  fsdb has conversions to translate fragment numbers and i-numbers into their corresponding disk addresses.  Also included are mnemonic offsets to access different parts of an inode.  These greatly simplify the process of correcting control block entries or descending the file system tree. 

fsdb contains several error-checking routines to verify inode and fragment addresses.  These can be disabled if necessary by invoking fsdb with the optional − argument, or by the use of the O symbol. 

Numbers are considered decimal by default.  Octal numbers must be prefixed with a zero.  Hexadecimal numbers must be prefixed with 0x.  During any assignment operation, numbers are checked for a possible truncation error due to a size mismatch between source and destination. 

fsdb reads a fragment at a time.  A buffer management routine is used to retain commonly used fragments of data in order to reduce the number of read system calls.  All assignment operations result in an immediate write-through of the corresponding fragment. 

The following symbols are recognized by fsdb:

# absolute address

i convert from i-number to inode address (for continuation inodes as well as primary inodes; see inode(4))

b convert from fragment number to disk address (historically "block")

d directory slot offset

+,− address arithmetic

q quit

>,< save, restore an address

= numerical assignment

=+ incremental assignment

=− decremental assignment

=" character string assignment

X hexadecimal flip flop

O error checking flip flop

p general print facilities

f file print facility

B byte mode

W word mode

D double-word mode

!  escape to shell

The print facilities generate a formatted output in various styles.  Octal numbers are prefixed with a zero.  Hexadecimal numbers are prefixed with 0x.  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 interrupt character.  If a number follows the p symbol, that many entries are printed.  A check is made to detect fragment boundary 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 fragment are printed.  The print options available are:

i print as inodes (primary or continuation)

d print as directories

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 fragments associated with the current inode.  If followed by a number, that fragment of the file is printed.  (Fragments are numbered from zero).  The desired print option letter follows the fragment number, if present, or the f symbol.  This print facility works for small as well as large files except for special files such as fifos, and device special files. 

Dots, tabs, and spaces can be used as function delimiters but are not necessary.  A line with just a new-line character increments 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 inode, 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 (hexadecimal if X toggle is used) address followed by the value in octal (hexadecimal if X toggle is used) and decimal.  A .B or .D is appended to the address for byte and double-word values, respectively.  Directories are printed as a directory slot offset followed by the decimal i-number and the character representation of the entry name.  Inodes are printed with labeled fields describing each element. 

The following mnemonics are used for inode examination and refer to the current working inode:

a# data block numbers (0 − 14)

at time last accessed

ci continuation inode number

cno cnode ID for a device file

ct last time inode changed

gid group ID number

ln link count

md mode

mt time last modified

maj major device number

min minor device number

sz file size in byte unit

uid user ID number

The following mnemonics are used for directory examination:

di i-number of the associated directory entry

nm name of the associated directory entry

EXAMPLES

386i prints i-number 386 in an inode format.  This now becomes the current working inode. 

ln=4 changes the link count for the working inode to 4. 

ln=+1 increments the link count by 1. 

fc prints in ASCII fragment zero of the file associated with the working inode. 

2i.fd prints the first fragment-size piece of directory entries for the root inode of this file system. 

d5i.fc changes the current inode to that associated with the fifth directory entry (numbered from zero) found from the above command.  The first fragment’s worth of bytes of the file are then printed in ASCII. 

1b.px prints the first fragment of the superblock of this file system in hexadecimal. 

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 if the first character of the name field is alphabetic. 

a2b.p0d prints the third fragment of the current inode as directory entries. 

WARNINGS

Use of fsdb should be limited to experienced fsdb users.  Failure to understand fully the usage of fsdb and the file system’s internal organization can lead to complete destruction of the file system and total loss of data. 

AUTHOR

fsdb was developed by HP and AT&T. 

SEE ALSO

dumpfs(1M), fsck(1M), stat(2), dir(4), fs(4). 

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026