Crates.io | btrd |
lib.rs | btrd |
version | 0.5.3 |
source | src |
created_at | 2021-04-29 00:18:09.082359 |
updated_at | 2023-10-23 14:18:02.311211 |
description | The btrfs debugger |
homepage | |
repository | https://github.com/danobi/btrd |
max_upload_size | |
id | 390814 |
size | 329,614 |
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.
$ sudo btrd
btrd (the btrfs debugger) v0.1.0
Type 'help' for help
(btrd) filesystem "/mnt/btrfs"
(btrd) k = key(BTRFS_DEV_TREE_OBJECTID, BTRFS_ROOT_ITEM_KEY, 0, 0)
(btrd) print k
struct _btrfs_ioctl_search_key {
.min_objectid = 4,
.max_objectid = 18446744073709551615,
.min_type = 132,
.max_type = 255,
.min_offset = 0,
.max_offset = 18446744073709551615,
.min_transid = 0,
.max_transid = 18446744073709551615,
}
(btrd) res = search(BTRFS_ROOT_TREE_OBJECTID, k)
(btrd) len(res)
297
(btrd) res[0]
struct btrfs_root_item {
.inode = struct btrfs_inode_item {
.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 btrfs_root_item"
(btrd) keyof(res[0])
struct btrfs_key {
.objectid = 4,
.type = 132,
.offset = 0,
}
$ git clone https://github.com/danobi/btrd.git
$ cd btrd
$ cargo build --release
$ sudo ./target/release/btrd
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:
+
, -
, /
, %
, >>
, &&
, ==
, etc.)-
, ~
, !
)(struct btrfs_root) physical_bytenr
)Control flow:
while
for
(ranged based)if/else
There is not and will not be support for: