Now maintains the inode field in the preloaded_image structure.

It will now load all modules only once by identifying them using their inode number.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7991 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-06-15 16:59:59 +00:00
parent 4807cd86ea
commit d88c45c6f2
+17
View File
@@ -289,6 +289,22 @@ elf_load_image(Directory *directory, const char *path)
if (fd < 0)
return fd;
// check if this file has already been loaded
struct stat stat;
fstat(fd, &stat);
image = gKernelArgs.preloaded_images;
for (; image != NULL; image = image->next) {
if (image->inode == stat.st_ino) {
// file has already been loaded, no need to load it twice!
close(fd);
return B_OK;
}
}
// we still need to load it, so do it
image = (preloaded_image *)kernel_args_malloc(sizeof(preloaded_image));
if (image == NULL) {
close(fd);
@@ -298,6 +314,7 @@ elf_load_image(Directory *directory, const char *path)
status_t status = elf_load_image(fd, image);
if (status == B_OK) {
image->name = kernel_args_strdup(path);
image->inode = stat.st_ino;
// insert to kernel args
image->next = gKernelArgs.preloaded_images;