Ticket #2185: devfs.cpp.diff
File devfs.cpp.diff, 2.2 KB (added by , 16 years ago) |
---|
-
src/system/kernel/fs/devfs.cpp
25 25 #include <boot_device.h> 26 26 #include <debug.h> 27 27 #include <elf.h> 28 #include <FindDirectory.h> 28 29 #include <kdevice_manager.h> 29 30 #include <KPath.h> 30 31 #include <lock.h> … … 490 491 491 492 492 493 static int32 493 get_priority(const char *path)494 get_priority(const char* path) 494 495 { 495 // TODO: use find_directory() 496 const char *kPaths[] = {"/boot/beos", "/boot/common", "/boot/home", NULL}; 496 const directory_which whichPath[] = { 497 B_BEOS_DIRECTORY, 498 B_COMMON_DIRECTORY, 499 B_USER_DIRECTORY 500 }; 501 KPath pathBuffer; 497 502 498 for (int32 i = 0; kPaths[i] != NULL; i++) { 499 if (!strncmp(kPaths[i], path, strlen(kPaths[i]))) 500 return i; 503 for (uint32 index = 0; index < sizeof(whichPath) / sizeof(whichPath[0]); index++) { 504 if (find_directory(whichPath[index], gBootDevice, false, 505 pathBuffer.LockBuffer(), pathBuffer.BufferSize()) == B_OK) { 506 pathBuffer.UnlockBuffer(); 507 if (!strncmp(pathBuffer.Path(), path, pathBuffer.BufferSize())) 508 return index; 509 } 501 510 } 502 511 503 512 return -1; … … 2837 2846 struct preloaded_image* image; 2838 2847 for (image = args->preloaded_images; image != NULL; image = image->next) { 2839 2848 if (!image->is_module && image->id >= 0) { 2840 // fake an absolute path 2841 char path[B_PATH_NAME_LENGTH]; 2842 strlcpy(path, "/boot/beos/system/add-ons/kernel/", sizeof(path)); 2843 strlcat(path, image->name, sizeof(path)); 2849 KPath imagePath; 2850 status_t status = find_directory(B_BEOS_ADDONS_DIRECTORY, gBootDevice, false, 2851 imagePath.LockBuffer(), imagePath.BufferSize()); 2852 if (status < B_OK) { 2853 dprintf("devfs_add_preloaded_drivers: Failed when find_directory \"%s\"\n", 2854 strerror(status)); 2855 } else { 2856 imagePath.UnlockBuffer(); 2857 imagePath.Append("kernel/"); 2858 imagePath.Append(image->name); 2859 } 2844 2860 2845 2861 // try to add the driver 2846 status _t error = add_driver(path, image->id);2847 if ( error!= B_OK) {2862 status = add_driver(imagePath.Path(), image->id); 2863 if (status != B_OK) { 2848 2864 dprintf("devfs_add_preloaded_drivers: Failed to add \"%s\"\n", 2849 2865 image->name); 2850 2866 unload_kernel_add_on(image->id);