btrd

The btrfs debugger (pronounced "buttered").

btrd is a REPL debugger that helps inspect mounted btrfs filesystems. btrd is particularly useful in exploring on-disk structures and has full knowledge of all on-disk types.

Demo

``` $ sudo btrd btrd (the btrfs debugger) v0.1.0 Type 'help' for help

(btrd) filesystem "/mnt/btrfs" (btrd) k = key(BTRFSDEVTREEOBJECTID, BTRFSROOTITEMKEY, 0, 0) (btrd) print k struct btrfsioctlsearchkey { .minobjectid = 4, .maxobjectid = 18446744073709551615, .mintype = 132, .maxtype = 255, .minoffset = 0, .maxoffset = 18446744073709551615, .mintransid = 0, .maxtransid = 18446744073709551615, }

(btrd) res = search(BTRFSROOTTREE_OBJECTID, k) (btrd) len(res) 297

(btrd) res[0] struct btrfsrootitem { .inode = struct btrfsinodeitem { .generation = 1, .transid = 0, .size = 3, .nbytes = 16384, <...> .sequence = 0, .reserved = [ 0, 0, 0, 0, ], .atime = struct btrfs_timespec { .sec = 0, .nsec = 0, }, <...>

(btrd) print res[0].inode.nbytes 16384

(btrd) typeof(res[0]) "struct btrfsrootitem"

(btrd) keyof(res[0]) struct btrfs_key { .objectid = 4, .type = 132, .offset = 0, } ```

Building

bash $ git clone https://github.com/danobi/btrd.git $ cd btrd $ cargo build --release $ sudo ./target/release/btrd

Language features

btrd's scripting language is not a hack -- it's a dynamically typed language tailored to filesystem debugging. The following is a list of language features:

Types:

Expressions:

Control flow:

There is not and will not be support for: