File: show_dev_extents.py

package info (click to toggle)
python-btrfs 11-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 724 kB
  • sloc: python: 4,445; makefile: 195
file content (17 lines) | stat: -rwxr-xr-x 510 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/python3

import btrfs
import sys

if len(sys.argv) < 2:
    print("Usage: {} <mountpoint>".format(sys.argv[0]))
    sys.exit(1)

with btrfs.FileSystem(sys.argv[1]) as fs:
    chunks = {chunk.vaddr: chunk for chunk in fs.chunks()}
    for d in fs.dev_extents():
        print("devid {} type {} pstart {} length {} pend {} vaddr {}".format(
            d.devid,
            btrfs.utils.block_group_flags_str(chunks[d.vaddr].type),
            d.paddr, d.length, d.paddr + d.length, d.vaddr
        ))