open_module_list()/read_next_module_name() now take built-in modules into account as well.
The prefix will obviously ignored currently! Fixed get_next_loaded_module_name(); it will now work correctly (doesn't check, though, if the module is currently loaded...). Removed the module_test() function - doesn't belong here. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7465 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
44c7b3db82
commit
0a4a7dee30
@ -88,19 +88,20 @@ typedef struct module {
|
|||||||
|
|
||||||
typedef struct module_iterator {
|
typedef struct module_iterator {
|
||||||
const char **path_stack;
|
const char **path_stack;
|
||||||
int stack_size;
|
int32 stack_size;
|
||||||
int stack_current;
|
int32 stack_current;
|
||||||
|
|
||||||
char *prefix;
|
char *prefix;
|
||||||
DIR *current_dir;
|
DIR *current_dir;
|
||||||
int status;
|
status_t status;
|
||||||
int module_offset;
|
int32 module_offset;
|
||||||
/* This is used to keep track of which module_info
|
/* This is used to keep track of which module_info
|
||||||
* within a module we're addressing. */
|
* within a module we're addressing. */
|
||||||
module_image *module_image;
|
module_image *module_image;
|
||||||
module_info **current_header;
|
module_info **current_header;
|
||||||
const char *current_path;
|
const char *current_path;
|
||||||
const char *current_module_path;
|
const char *current_module_path;
|
||||||
|
bool builtin_modules;
|
||||||
} module_iterator;
|
} module_iterator;
|
||||||
|
|
||||||
|
|
||||||
@ -748,6 +749,15 @@ iterator_get_next_module(module_iterator *iterator, char *buffer, size_t *_buffe
|
|||||||
|
|
||||||
TRACE(("iterator_get_next_module() -- start\n"));
|
TRACE(("iterator_get_next_module() -- start\n"));
|
||||||
|
|
||||||
|
if (iterator->builtin_modules) {
|
||||||
|
if (sBuiltInModules[iterator->module_offset] != NULL) {
|
||||||
|
*_bufferSize = strlcpy(buffer,
|
||||||
|
sBuiltInModules[iterator->module_offset++]->name, *_bufferSize);
|
||||||
|
return B_OK;
|
||||||
|
} else
|
||||||
|
iterator->builtin_modules = false;
|
||||||
|
}
|
||||||
|
|
||||||
nextDirectory:
|
nextDirectory:
|
||||||
if (iterator->current_dir == NULL) {
|
if (iterator->current_dir == NULL) {
|
||||||
// get next directory path from the stack
|
// get next directory path from the stack
|
||||||
@ -929,32 +939,6 @@ module_init(kernel_args *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
void
|
|
||||||
module_test(void)
|
|
||||||
{
|
|
||||||
void *cookie;
|
|
||||||
|
|
||||||
dprintf("module_test() - start!\n");
|
|
||||||
|
|
||||||
cookie = open_module_list(NULL);
|
|
||||||
if (cookie == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
char name[SYS_MAX_PATH_LEN];
|
|
||||||
size_t size = sizeof(name);
|
|
||||||
|
|
||||||
if (read_next_module_name(cookie, name, &size) < B_OK)
|
|
||||||
break;
|
|
||||||
|
|
||||||
dprintf("module: %s\n", name);
|
|
||||||
}
|
|
||||||
close_module_list(cookie);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
// Exported Kernel API (public part)
|
// Exported Kernel API (public part)
|
||||||
|
|
||||||
@ -990,6 +974,9 @@ open_module_list(const char *prefix)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// first, we'll traverse over the built-in modules
|
||||||
|
iterator->builtin_modules = true;
|
||||||
|
|
||||||
// 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 < NUM_MODULE_PATHS; i++) {
|
||||||
const char *p;
|
const char *p;
|
||||||
@ -1091,34 +1078,33 @@ read_next_module_name(void *cookie, char *buffer, size_t *_bufferSize)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
get_next_loaded_module_name(uint32 *cookie, char *buffer, size_t *_bufferSize)
|
get_next_loaded_module_name(uint32 *_cookie, char *buffer, size_t *_bufferSize)
|
||||||
{
|
{
|
||||||
hash_iterator *iterator = (hash_iterator *)*cookie;
|
hash_iterator *iterator = (hash_iterator *)*_cookie;
|
||||||
module_image *moduleImage;
|
struct module *module;
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
TRACE(("get_next_loaded_module_name()\n"));
|
TRACE(("get_next_loaded_module_name()\n"));
|
||||||
|
|
||||||
if (cookie == NULL || buffer == NULL || _bufferSize == NULL)
|
if (_cookie == NULL || buffer == NULL || _bufferSize == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (iterator == NULL) {
|
if (iterator == NULL) {
|
||||||
iterator = hash_open(gModuleImagesHash, NULL);
|
iterator = hash_open(gModulesHash, NULL);
|
||||||
if (iterator == NULL)
|
if (iterator == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
*(hash_iterator **)cookie = iterator;
|
*(hash_iterator **)_cookie = iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive_lock_lock(&gModulesLock);
|
recursive_lock_lock(&gModulesLock);
|
||||||
|
|
||||||
moduleImage = hash_next(gModuleImagesHash, iterator);
|
module = hash_next(gModulesHash, iterator);
|
||||||
if (moduleImage != NULL) {
|
if (module != NULL) {
|
||||||
strlcpy(buffer, moduleImage->path, *_bufferSize);
|
*_bufferSize = strlcpy(buffer, module->name, *_bufferSize);
|
||||||
*_bufferSize = strlen(moduleImage->path);
|
|
||||||
status = B_OK;
|
status = B_OK;
|
||||||
} else {
|
} else {
|
||||||
hash_close(gModuleImagesHash, iterator, true);
|
hash_close(gModulesHash, iterator, true);
|
||||||
status = B_ENTRY_NOT_FOUND;
|
status = B_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user