-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some indexing to block_devices
#8037
Add some indexing to block_devices
#8037
Conversation
This extends the work originally done in osquery#7209 to the `block_devices` table. With it, I hope to fix an o(n^2) bug. As the underlying code doesn't support this on darwin, I opted to flag the spec as `additional=True` and not `index=True`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
built and ran it locally and on a VM, seems to run great! took a quick look at udev man pages, and I think we ought to check for null/failure return codes?
udev_enumerate_unref(enumerate); | ||
if (runSelectAll) { | ||
struct udev_enumerate* enumerate = udev_enumerate_new(udev); | ||
udev_enumerate_add_match_subsystem(enumerate, "block"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to check if enumerate
is not a nullptr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure? The prior code did not, and of the other places I see this call most don't check.
I can't really find something authoritative, but the code for udev_list_entry_foreach
looks like it handles it.
|
||
std::map<std::string, std::string> lvm_lv2pv; | ||
struct udev_list_entry *devices, *dev_list_entry; | ||
devices = udev_enumerate_get_list_entry(enumerate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we should check if devices
is also not null before continuing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as above)
This reverts commit b1f3ff6.
This extends the work originally done in #7209 to the
block_devices
table. And relates to #8033With it, I hope to fix an o(n^2) bug.
As the underlying code doesn't support this on darwin, I opted to flag the spec as
additional=True
and notindex=True
(Thanks @uptycs-rmack for talking through this with me)