fsdb_ufs - ufs file system debugger
fsdb -F ufs [generic_options] [specific_options] special
The fsdb_ufs command is an interactive tool that can be used to patch up a damaged UFS file system. It has conversions to translate block 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 block addresses. These can be disabled if necessary by invoking fsdb with the -o option or by the use of the o command.
fsdb reads a block at a time and will therefore work with raw as well as block I/O devices. 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. Note that in order to modify any portion of the disk, fsdb must be invoked with the w option.
Wherever possible, adb-like syntax was adopted to promote the use of fsdb through familiarity.
The following option is supported:
Numbers are considered hexadecimal by default. However, the user has control over how data is to be displayed or accepted. The base command will display or set the input/output base. Once set, all input will default to this base and all output will be shown in this base. The base can be overridden temporarily for input by preceding hexadecimal numbers with '0x', preceding decimal numbers with '0t', or octal numbers with '0'. Hexadecimal numbers beginning with a-f or A-F must be preceded with '0x' to distinguish them from commands.
Disk addressing by fsdb is at the byte level. However, fsdb offers many commands to convert a desired inode, directory entry, block, superblock and so forth to a byte address. Once the address has been calculated, fsdb will record the result in dot (.).
Several global values are maintained by fsdb:
Most commands use the preset value of dot in their execution. For example,
will first set the value of dot to 2, ':', will alert the start of a command, and the inode command will set inode to 2. A count is specified after a ','. Once set, count will remain at this value until a new command is encountered which will then reset the value back to 1 (the default). So, if
is typed, 400 hex longs are listed from 2000, and when completed, the value of dot will be 2000 + 400 * sizeof (long). If a RETURN is then typed, the output routine will use the current values of dot, count, and type and display 400 more hex longs. A '*' will cause the entire block to be displayed.
End of fragment, block and file are maintained by fsdb. When displaying data as fragments or blocks, an error message will be displayed when the end of fragment or block is reached. When displaying data using the db, ib, directory, or file commands an error message is displayed if the end of file is reached. This is mainly needed to avoid passing the end of a directory or file and getting unknown and unwanted results.
An example showing several commands and the use of RETURN would be:
> 2:ino; 0:dir?d or > 2:ino; 0:db:block?d
The two examples are synonymous for getting to the first directory entry of the root of the file system. Once there, any subsequent RETURN (or +, -) will advance to subsequent entries. Note that
> 2:inode; :ls or > :ls /
is again synonymous.
The symbols recognized by fsdb are:
dot = dot + e * sizeof (type)
The default for e is 1.
= [s] [e]
A command must be prefixed by a ':' character. Only enough letters of the command to uniquely distinguish it are needed. Multiple commands may be entered on one line by separating them by a SPACE, TAB or ';'.
In order to view a potentially unmounted disk in a reasonable manner, fsdb offers the cd, pwd, ls and find commands. The functionality of these commands substantially matches those of its UNIX counterparts. See individual commands for details. The '*', '?', and '[-]' wild card characters are available.
find dir [ -name n] [-inum i]
In addition to the above commands, there are several commands that deal with inode fields and operate directly on the current inode (they still require the ':'). They may be used to more easily display or change the particular fields. The value of dot is only used by the ':db' and ':ib' commands. Upon completion of the command, the value of dot is changed to point to that particular field. For example,
would increment the link count of the current inode and set the value of dot to the address of the link count field.
would get the contents of data block field 1 from the inode and convert it to a block address. 20 longs are then displayed in hexadecimal. See FormattedOutput.
will get the 7th directory entry of the current inode and change its name to foo. Note that names cannot be made larger than the field is set up for. If an attempt is made, the string is truncated to fit and a warning message to this effect is displayed.
There are two styles and many format types. The two styles are structured and unstructured. Structured output is used to display inodes, directories, superblocks and the like. Unstructured displays raw data. The following shows the different ways of displaying:
The format specifier immediately follows the '/' or '?' character. The values displayed by '/b' and all '?' formats are displayed in the current base. Also, type is appropriately updated upon completion.
Example 1 Displaying in Decimal
The following command displays 2010 in decimal (use of fsdb as a calculator for complex arithmetic):
Example 2 Displaying an i-number in Inode Format
The following command displays i-number 386 in an inode format. This now becomes the current inode:
Example 3 Changing the Link Count
The following command changes the link count for the current inode to 4:
Example 4 Incrementing the Link Count
The following command increments the link count by 1:
Example 5 Displaying the Creation Time
The following command displays the creation time as a hexadecimal long:
Example 6 Displaying the Modification Time
The following command displays the modification time in time format:
Example 7 Displaying in ASCII
The following command displays in ASCII, block zero of the file associated with the current inode:
Example 8 Displaying the First Block's Worth of Directorty Entries
The following command displays the first block's worth of directory entries for the root inode of this file system. It will stop prematurely if the EOF is reached:
Example 9 Displaying Changes to the Current Inode
The following command displays changes the current inode to that associated with the 5th directory entry (numbered from zero) of the current inode. The first logical block of the file is then displayed in ASCII:
> 5:dir:inode; 0:file,*/c
Example 10 Displaying the Superblock
The following command displays the superblock of this file system:
Example 11 Displaying the Cylinder Group
The following command displays cylinder group information and summary for cylinder group 1:
Example 12 Changing the i-number
The following command changes the i-number for the seventh directory slot in the root directory to 3:
> 2:inode; 7:dir=3
Example 13 Displaying as Directory Entries
The following command displays the third block of the current inode as directory entries:
Example 14 Changing the Name Field
The following command changes the name field in the directory slot to name:
Example 15 Getting and Filling Elements
The following command gets fragment 3c3 and fill 20 type elements with 0x20:
Example 16 Setting the Contents of an Address
The following command sets the contents of address 2050 to 0xffffffff. 0xffffffff may be truncated depending on the current type:
Example 17 Placing ASCII
The following command places the ASCII for the string at 1c92434:
> 1c92434="this is some text"
Example 18 Displaying Shadow Inode Data
The following command displays all of the shadow inode data in the shadow inode associated with the root inode of this file system:
See attributes(5) for descriptions of the following attributes:
clri(1M), fsck_ufs(1M), dir_ufs(4), attributes(5), ufs(7FS)
Since fsdb reads the disk raw, extreme caution is advised in determining its availability of fsdb on the system. Suggested permissions are 600 and owned by bin.
The old command line syntax for clearing i-nodes using the ufs-specific '-z i-number' option is still supported by the new debugger, though it is obsolete and will be removed in a future release. Use of this flag will result in correct operation, but an error message will be printed warning of the impending obsolesence of this option to the command. The equivalent functionality is available using the more flexible clri(1M) command.
Закладки на сайте
Проследить за страницей
Created 1996-2020 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру