kernel/legacy_drivers: reverse order of search for kernel add-ons

* DirectoryIterator uses a stack to hold the paths values, pushed in SetTo(),
then popped with GetNext(). So the path directories have to added in reverse
order.
* fix #17264

Change-Id: I728365f069071f109c79e647d6a33cd24f68ce0e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8498
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Jérôme Duval 2024-10-21 16:22:05 +02:00 committed by waddlesplash
parent 8cc3ed34bc
commit 89264cfe2e

View File

@ -939,14 +939,12 @@ DirectoryIterator::SetTo(const char* path, const char* subPath, bool recursive)
Unset();
fRecursive = recursive;
const bool disableUserAddOns = get_safemode_boolean(B_SAFEMODE_DISABLE_USER_ADD_ONS, false);
if (path == NULL) {
// add default paths
// add default paths in reverse order as AddPath() will add on a stack
KPath pathBuffer;
bool disableUserAddOns = get_safemode_boolean(
B_SAFEMODE_DISABLE_USER_ADD_ONS, false);
for (uint32 i = 0; i < sizeof(kDriverPaths) / sizeof(kDriverPaths[0]); i++) {
for (int32 i = B_COUNT_OF(kDriverPaths) - 1; i >= 0; i--) {
if (i < 3 && disableUserAddOns)
continue;