1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 21:35:45 +02:00

fs: if search fails, return empty result set

Make sure the result set is empty before running the ioctl in case
something tries to consume the result without checking the error status.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2018-11-08 23:09:14 -05:00
parent a676928ed5
commit 0d5c018c3c

View File

@ -823,6 +823,8 @@ namespace crucible {
ioctl_ptr->buf_size = m_buf_size; ioctl_ptr->buf_size = m_buf_size;
m_result.clear();
// Don't bother supporting V1. Kernels that old have other problems. // Don't bother supporting V1. Kernels that old have other problems.
int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_ptr); int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_ptr);
if (rv != 0) { if (rv != 0) {
@ -831,8 +833,6 @@ namespace crucible {
static_cast<btrfs_ioctl_search_key&>(*this) = ioctl_ptr->key; static_cast<btrfs_ioctl_search_key&>(*this) = ioctl_ptr->key;
m_result.clear();
size_t offset = pointer_distance(ioctl_ptr->buf, ioctl_ptr); size_t offset = pointer_distance(ioctl_ptr->buf, ioctl_ptr);
for (decltype(nr_items) i = 0; i < nr_items; ++i) { for (decltype(nr_items) i = 0; i < nr_items; ++i) {
BtrfsIoctlSearchHeader item; BtrfsIoctlSearchHeader item;