/usr/share/doc/python3-btrfs/examples/show_default_subvolid.py is in python3-btrfs 9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/usr/bin/python3
import btrfs
import sys
from btrfs.ctree import Key, DirItemList
from btrfs.ctree import ROOT_TREE_OBJECTID, ROOT_TREE_DIR_OBJECTID, DIR_ITEM_KEY, ULLONG_MAX
if len(sys.argv) < 2:
print("Usage: {} <mountpoint>".format(sys.argv[0]))
sys.exit(1)
fs = btrfs.FileSystem(sys.argv[1])
tree = ROOT_TREE_OBJECTID
min_key = Key(ROOT_TREE_DIR_OBJECTID, DIR_ITEM_KEY, 0)
max_key = Key(ROOT_TREE_DIR_OBJECTID, DIR_ITEM_KEY, ULLONG_MAX)
for header, data in btrfs.ioctl.search_v2(fs.fd, tree, min_key, max_key, nr_items=1):
for dir_item in DirItemList(header, data):
print(dir_item.location.objectid)
|