btrfs-util: introduce btrfs_get_file_physical_offset_fd
authorMike Yuan <me@yhndnzj.com>
Wed, 13 Sep 2023 05:52:55 +0000 (13:52 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 19 Sep 2023 13:45:27 +0000 (21:45 +0800)
commitefb6a76a2a097132087ee30720421136cba9e708
tree1e7ff9825da6c762232833d5d5ad1f5010fa7747
parent79de6eb1a7a2d46b3a582fae4b66315246598c0c
btrfs-util: introduce btrfs_get_file_physical_offset_fd

This calculates the physical offset of a file on btrfs,
similar to what FIEMAP does on other filesystems.

The implementation should generally be kept in sync with
btrfs-progs' inspect-internal map-swapfile command:
https://github.com/kdave/btrfs-progs/blob/92d04d4780886a9850716e5529f1dace97779931/cmds/inspect.c#L1516

Preparation for #25130
src/shared/btrfs-util.c
src/shared/btrfs-util.h