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>
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>