Commit Graph

3 Commits

Author SHA1 Message Date
David Sterba
ed89c67132 btrfs-progs: fix struct btrfs_tree_search_args layout
Clang 19 reports:

In file included from common/fsfeatures.c:34:
  ./common/tree-search.h:11:2: warning: field '' with variable sized type
  'union btrfs_tree_search_args::(anonymous at
  ./common/tree-search.h:11:2)' not at the end of a struct or class is a
  GNU extension [-Wgnu-variable-sized-type-not-at-end]

which is correct. This does not still fix the problem with tree search
v2, disabled in d73e698248 ("btrfs-progs: temporarily disable usage
of v2 of search tree ioctl").

Signed-off-by: David Sterba <dsterba@suse.com>
2025-01-17 22:30:40 +01:00
David Sterba
abad680f5f btrfs-progs: clean up includes
Remove unused includes, add ones that are missing.

Signed-off-by: David Sterba <dsterba@suse.com>
2025-01-16 19:13:26 +01:00
David Sterba
a223764093 btrfs-progs: add API for selecting tree search support and ioctl
Add wrappers around v1 and v2 of TREE_SEARCH ioctl so it can be
transparently used by code. The structures partially overlap but due to
the buffer size the v2 is offset and also needs a filler to expand the
flexible buffer.

Usage:

- define struct btrfs_tree_search_args, all zeros
- btrfs_tree_search_sk() reads offset of the search key within the
  structures
- btrfs_tree_search_ioctl() detect support and call the highest
  supported ioctl version, v2 has been supported since 3.14 but we want
  to keep backward compatibility
- btrfs_tree_search_data() read data from the buffer previously filled
  by ioctl, a sequence of (search header, data)

Signed-off-by: David Sterba <dsterba@suse.com>
2024-03-16 18:08:38 +01:00