* The module code now uses find_directory() and no hard-coded paths anymore.
* It now also supports the common directory path. * search_module() checked the module paths in the wrong order, ie. it preferred modules in the system directory over the user directory. * Clarified comment in vfs_get_module_path(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24323 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fa28330bbf
commit
3f89bce410
|
@ -3304,6 +3304,7 @@ vfs_get_fs_node_from_path(dev_t mountID, const char *path, bool kernel,
|
||||||
\c B_ENTRY_NOT_FOUNT if no file could be found.
|
\c B_ENTRY_NOT_FOUNT if no file could be found.
|
||||||
\a pathBuffer is clobbered in any case and must not be relied on if this
|
\a pathBuffer is clobbered in any case and must not be relied on if this
|
||||||
functions returns unsuccessfully.
|
functions returns unsuccessfully.
|
||||||
|
\a basePath and \a pathBuffer must not point to the same space.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
vfs_get_module_path(const char *basePath, const char *moduleName,
|
vfs_get_module_path(const char *basePath, const char *moduleName,
|
||||||
|
@ -3314,7 +3315,8 @@ vfs_get_module_path(const char *basePath, const char *moduleName,
|
||||||
size_t length;
|
size_t length;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
if (bufferSize == 0 || strlcpy(pathBuffer, basePath, bufferSize) >= bufferSize)
|
if (bufferSize == 0
|
||||||
|
|| strlcpy(pathBuffer, basePath, bufferSize) >= bufferSize)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
status = path_to_vnode(pathBuffer, true, &dir, NULL, true);
|
status = path_to_vnode(pathBuffer, true, &dir, NULL, true);
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
|
||||||
#include <boot_device.h>
|
#include <boot_device.h>
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
#include <lock.h>
|
#include <lock.h>
|
||||||
|
@ -147,15 +149,16 @@ static recursive_lock sModulesLock;
|
||||||
/* These are the standard base paths where we start to look for modules
|
/* These are the standard base paths where we start to look for modules
|
||||||
* to load. Order is important, the last entry here will be searched
|
* to load. Order is important, the last entry here will be searched
|
||||||
* first.
|
* first.
|
||||||
* ToDo: these should probably be retrieved by using find_directory().
|
|
||||||
*/
|
*/
|
||||||
static const char * const sModulePaths[] = {
|
static const directory_which kModulePaths[] = {
|
||||||
"/boot/beos/system/add-ons/kernel",
|
B_BEOS_ADDONS_DIRECTORY,
|
||||||
"/boot/home/config/add-ons/kernel",
|
B_COMMON_ADDONS_DIRECTORY,
|
||||||
|
B_USER_ADDONS_DIRECTORY,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_MODULE_PATHS (sizeof(sModulePaths) / sizeof(sModulePaths[0]))
|
static const uint32 kNumModulePaths = sizeof(kModulePaths)
|
||||||
#define FIRST_USER_MODULE_PATH (NUM_MODULE_PATHS - 1) /* first user path */
|
/ sizeof(kModulePaths[0]);
|
||||||
|
static const uint32 kFirstNonSystemModulePath = 1;
|
||||||
|
|
||||||
/* We store the loaded modules by directory path, and all known modules
|
/* We store the loaded modules by directory path, and all known modules
|
||||||
* by module name in a hash table for quick access
|
* by module name in a hash table for quick access
|
||||||
|
@ -467,17 +470,26 @@ search_module(const char *name)
|
||||||
|
|
||||||
TRACE(("search_module(%s)\n", name));
|
TRACE(("search_module(%s)\n", name));
|
||||||
|
|
||||||
for (i = 0; i < NUM_MODULE_PATHS; i++) {
|
for (i = kNumModulePaths; i-- > 0;) {
|
||||||
char path[B_FILE_NAME_LENGTH];
|
if (sDisableUserAddOns && i >= kFirstNonSystemModulePath)
|
||||||
|
continue;
|
||||||
if (sDisableUserAddOns && i >= FIRST_USER_MODULE_PATH)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// let the VFS find that module for us
|
// let the VFS find that module for us
|
||||||
|
|
||||||
status = vfs_get_module_path(sModulePaths[i], name, path, sizeof(path));
|
KPath basePath;
|
||||||
|
if (find_directory(kModulePaths[i], gBootDevice, true,
|
||||||
|
basePath.LockBuffer(), basePath.BufferSize()) != B_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
basePath.UnlockBuffer();
|
||||||
|
basePath.Append("kernel");
|
||||||
|
|
||||||
|
KPath path;
|
||||||
|
status = vfs_get_module_path(basePath.Path(), name, path.LockBuffer(),
|
||||||
|
path.BufferSize());
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
status = check_module_image(path, name);
|
path.UnlockBuffer();
|
||||||
|
status = check_module_image(path.Path(), name);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1122,15 +1134,23 @@ open_module_list(const char *prefix)
|
||||||
iterator->loaded_modules = false;
|
iterator->loaded_modules = false;
|
||||||
|
|
||||||
// put all search paths on the stack
|
// put all search paths on the stack
|
||||||
for (i = 0; i < NUM_MODULE_PATHS; i++) {
|
for (i = 0; i < kNumModulePaths; i++) {
|
||||||
if (sDisableUserAddOns && i >= FIRST_USER_MODULE_PATH)
|
if (sDisableUserAddOns && i >= kFirstNonSystemModulePath)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
KPath pathBuffer;
|
||||||
|
if (find_directory(kModulePaths[i], gBootDevice, true,
|
||||||
|
pathBuffer.LockBuffer(), pathBuffer.BufferSize()) != B_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pathBuffer.UnlockBuffer();
|
||||||
|
pathBuffer.Append("kernel");
|
||||||
|
|
||||||
// Copy base path onto the iterator stack
|
// Copy base path onto the iterator stack
|
||||||
char *path = strdup(sModulePaths[i]);
|
char *path = strdup(pathBuffer.Path());
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
size_t length = strlen(path);
|
size_t length = strlen(path);
|
||||||
|
|
||||||
// TODO: it would currently be nicer to use the commented
|
// TODO: it would currently be nicer to use the commented
|
||||||
|
|
Loading…
Reference in New Issue