From 51aacbbb3941461a98e73be5510446707949ddd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 12 Mar 2006 19:48:28 +0000 Subject: [PATCH] * open_module_list() put the wrong base path length onto the stack, and thus, no on-disk modules could be found... (since revision 16584). * iterator_get_next_module() now makes use of the KPath features, and doesn't build the new path manually anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16745 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/module.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/system/kernel/module.cpp b/src/system/kernel/module.cpp index 94bec31cb5..d6bd9210a4 100644 --- a/src/system/kernel/module.cpp +++ b/src/system/kernel/module.cpp @@ -774,27 +774,25 @@ nextModuleImage: goto nextModuleImage; // build absolute path to current file - KPath pathBuffer; - if (pathBuffer.InitCheck() != B_OK) + KPath path(iterator->current_path); + if (path.InitCheck() != B_OK) return B_NO_MEMORY; - char *path = pathBuffer.LockBuffer(); - strlcpy(path, iterator->current_path, sizeof(path)); - strlcat(path, "/", sizeof(path)); - strlcat(path, dirent->d_name, sizeof(path)); + if (path.Append(dirent->d_name) != B_OK) + return B_BUFFER_OVERFLOW; // find out if it's a directory or a file struct stat st; - if (stat(path, &st) < 0) + if (stat(path.Path(), &st) < 0) return errno; - iterator->current_module_path = strdup(path); + iterator->current_module_path = strdup(path.Path()); if (iterator->current_module_path == NULL) return B_NO_MEMORY; if (S_ISDIR(st.st_mode)) { status = iterator_push_path_on_stack(iterator, iterator->current_module_path, - iterator->path_base_length); + iterator->path_base_length); if (status < B_OK) return status; @@ -805,9 +803,9 @@ nextModuleImage: if (!S_ISREG(st.st_mode)) return B_BAD_TYPE; - TRACE(("open module at %s\n", path)); + TRACE(("open module at %s\n", path.Path())); - status = get_module_image(path, &iterator->module_image); + status = get_module_image(path.Path(), &iterator->module_image); if (status < B_OK) { free((void *)iterator->current_module_path); iterator->current_module_path = NULL; @@ -1116,7 +1114,7 @@ open_module_list(const char *prefix) path[length] = '/'; memcpy(path + length + 1, prefix, iterator->prefix_length + 1); - iterator_push_path_on_stack(iterator, path, strlen(path) + 1); + iterator_push_path_on_stack(iterator, path, length + 1); } return (void *)iterator;