ufs_db: UFS debugging and exploration tool

Ali Mashtizadeh mashtizadeh at gmail.com
Fri Jul 9 06:15:58 UTC 2010


Hi Folks,

I just wanted to point folks to a tool I wrote to walk over a UFS
file-system and examine some of it's structures. It might be useful
for UFS development, analyzing corruptions, and more. I was curious to
gauge the interest in this tool if there is I'll continue to extend it
and add support for additional structures and support modification of
the file-system.

mercurial repository available at https://bitbucket.org/mashtizadeh/ufs_db

~ List of currently supported commands ~
help                 Print this message
echo                 Echo a string to stdout
exec                 Execute a script
opendev              Open a device
closedev             Close a device
bread                Read a block in as hex
sb                   Select superblock
cg                   Select a cylinder group
ino                  Get an Inode
read                 Read from the current file
list                 Show a directory listing

~ Example output on a newly created file system ~
ufs_db> opendev /dev/md0
ufs_db> ino 2
Inode 2 (block 0)
di_mode              16877           Mode bits
di_nlink             3               Link count
di_uid               0               File owner
di_gid               0               File group
di_blksize           0               Inode blocksize
di_size              512             File byte count
di_blocks            4               Blocks actually held
di_atime             1278655907      Last access time
di_mtime             1278655907      Last modified time
di_ctime             1278655907      Last inode change time
di_birthtime         1278655907      Inode creation time
di_mtimensec          0              Last modified time (ns)
di_atimensec          0              Last access time (ns)
di_ctimensec          0              Last inode change time (ns)
di_birthnsec          0              Inode creation time (ns)
di_kernflags         0               Kernel flags
di_flags             0               Status flags (chflags)
di_extsize            0              External attributes block size
di_extb             [0] 0               External attributes blocks
di_extb             [1] 0               External attributes blocks
di_db               [0] 584             Direct disk blocks
di_db               [1] 0               Direct disk blocks
di_db               [2] 0               Direct disk blocks
di_db               [3] 0               Direct disk blocks
di_db               [4] 0               Direct disk blocks
di_db               [5] 0               Direct disk blocks
di_db               [6] 0               Direct disk blocks
di_db               [7] 0               Direct disk blocks
di_db               [8] 0               Direct disk blocks
di_db               [9] 0               Direct disk blocks
di_db               [10] 0               Direct disk blocks
di_db               [11] 0               Direct disk blocks
di_ib               [0] 0               Indirect disk blocks
di_ib               [1] 0               Indirect disk blocks
di_ib               [2] 0               Indirect disk blocks
di_modrev            0               i_modrev for NFSv4
ufs_db> list
0 2336
Filename                         Inode      Type
.                                2          4
..                               2          4
.snap                            3          4

Thanks,
--
Ali Mashtizadeh
علی مشتی زاده


More information about the freebsd-fs mailing list