* Driver probe code now uses find_directory() to get the directories to
look for drivers (also added common directory). * Now also honours the B_SAFEMODE_DISABLE_USER_ADD_ONS setting. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24316 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
637eef896b
commit
d1893d6468
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
* Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
|
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@ -26,11 +26,6 @@
|
|||||||
#define SYSTEM_DRIVER_REGISTRATION "/boot/beos/system/add-ons/kernel/"PNP_DIR"registration/"
|
#define SYSTEM_DRIVER_REGISTRATION "/boot/beos/system/add-ons/kernel/"PNP_DIR"registration/"
|
||||||
#define COMMON_DRIVER_REGISTRATION "/boot/home/config/add-ons/kernel/"PNP_DIR"registration/"
|
#define COMMON_DRIVER_REGISTRATION "/boot/home/config/add-ons/kernel/"PNP_DIR"registration/"
|
||||||
|
|
||||||
// module directories
|
|
||||||
#define SYSTEM_MODULES_DIR "/boot/beos/add-ons/kernel/"
|
|
||||||
#define COMMON_MODULES_DIR "/boot/home/config/add-ons/kernel/"
|
|
||||||
|
|
||||||
|
|
||||||
// info about ID generator
|
// info about ID generator
|
||||||
typedef struct id_generator {
|
typedef struct id_generator {
|
||||||
struct list_link link;
|
struct list_link link;
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
#include <fs/node_monitor.h>
|
#include <fs/node_monitor.h>
|
||||||
#include <kmodule.h>
|
#include <kmodule.h>
|
||||||
#include <Notifications.h>
|
#include <Notifications.h>
|
||||||
|
#include <safemode.h>
|
||||||
#include <util/kernel_cpp.h>
|
#include <util/kernel_cpp.h>
|
||||||
#include <util/OpenHashTable.h>
|
#include <util/OpenHashTable.h>
|
||||||
#include <util/Stack.h>
|
#include <util/Stack.h>
|
||||||
#include <vfs.h>
|
#include <vfs.h>
|
||||||
|
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
|
|
||||||
@ -91,26 +93,14 @@ const char *pnp_registration_dirs[2] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// list of module directories
|
|
||||||
static const char *kModulePaths[] = {
|
|
||||||
COMMON_MODULES_DIR,
|
|
||||||
"/boot/beos/system/add-ons/kernel",//SYSTEM_MODULES_DIR,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class DirectoryIterator {
|
class DirectoryIterator {
|
||||||
public:
|
public:
|
||||||
DirectoryIterator(const char *path, const char *subPath = NULL,
|
DirectoryIterator(const char *path, const char *subPath = NULL,
|
||||||
bool recursive = false);
|
bool recursive = false);
|
||||||
DirectoryIterator(const char **paths, const char *subPath = NULL,
|
|
||||||
bool recursive = false);
|
|
||||||
~DirectoryIterator();
|
~DirectoryIterator();
|
||||||
|
|
||||||
void SetTo(const char *path, const char *subPath = NULL,
|
void SetTo(const char *path, const char *subPath = NULL,
|
||||||
bool recursive = false);
|
bool recursive = false);
|
||||||
void SetTo(const char **paths, const char *subPath = NULL,
|
|
||||||
bool recursive = false);
|
|
||||||
|
|
||||||
status_t GetNext(KPath &path, struct stat &stat);
|
status_t GetNext(KPath &path, struct stat &stat);
|
||||||
const char *CurrentName() const { return fCurrentName; }
|
const char *CurrentName() const { return fCurrentName; }
|
||||||
@ -153,16 +143,6 @@ DirectoryIterator::DirectoryIterator(const char *path, const char *subPath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DirectoryIterator::DirectoryIterator(const char **paths, const char *subPath,
|
|
||||||
bool recursive)
|
|
||||||
:
|
|
||||||
fDirectory(NULL),
|
|
||||||
fBasePath(NULL)
|
|
||||||
{
|
|
||||||
SetTo(paths, subPath, recursive);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DirectoryIterator::~DirectoryIterator()
|
DirectoryIterator::~DirectoryIterator()
|
||||||
{
|
{
|
||||||
Unset();
|
Unset();
|
||||||
@ -175,20 +155,31 @@ DirectoryIterator::SetTo(const char *path, const char *subPath, bool recursive)
|
|||||||
Unset();
|
Unset();
|
||||||
fRecursive = recursive;
|
fRecursive = recursive;
|
||||||
|
|
||||||
AddPath(path, subPath);
|
if (path == NULL) {
|
||||||
}
|
// add default paths
|
||||||
|
const directory_which whichPath[] = {
|
||||||
|
B_USER_ADDONS_DIRECTORY,
|
||||||
|
B_COMMON_ADDONS_DIRECTORY,
|
||||||
|
B_BEOS_ADDONS_DIRECTORY
|
||||||
|
};
|
||||||
|
KPath pathBuffer;
|
||||||
|
|
||||||
|
bool disableUserAddOns = get_safemode_boolean(
|
||||||
|
B_SAFEMODE_DISABLE_USER_ADD_ONS, false);
|
||||||
|
|
||||||
void
|
for (uint32 i = 0; i < sizeof(whichPath) / sizeof(whichPath[0]); i++) {
|
||||||
DirectoryIterator::SetTo(const char **paths, const char *subPath,
|
if (i < 2 && disableUserAddOns)
|
||||||
bool recursive)
|
continue;
|
||||||
{
|
|
||||||
Unset();
|
|
||||||
fRecursive = recursive;
|
|
||||||
|
|
||||||
for (int32 i = 0; paths[i] != NULL; i++) {
|
if (find_directory(whichPath[i], gBootDevice, true,
|
||||||
AddPath(paths[i], subPath);
|
pathBuffer.LockBuffer(), pathBuffer.BufferSize()) == B_OK) {
|
||||||
}
|
pathBuffer.UnlockBuffer();
|
||||||
|
pathBuffer.Append("kernel");
|
||||||
|
AddPath(pathBuffer.Path(), subPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
AddPath(path, subPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1357,7 +1348,7 @@ probe_for_driver_modules(const char *type)
|
|||||||
|
|
||||||
// build list of potential drivers for that type
|
// build list of potential drivers for that type
|
||||||
|
|
||||||
DirectoryIterator iterator(kModulePaths, type, false);
|
DirectoryIterator iterator(NULL, type, false);
|
||||||
struct stat stat;
|
struct stat stat;
|
||||||
KPath path;
|
KPath path;
|
||||||
|
|
||||||
@ -1401,7 +1392,7 @@ probe_for_driver_modules(const char *type)
|
|||||||
// Iterate through bus managers to shrink the list (let them publish
|
// Iterate through bus managers to shrink the list (let them publish
|
||||||
// their own devices)
|
// their own devices)
|
||||||
|
|
||||||
iterator.SetTo(kModulePaths, "drivers/bus", false);
|
iterator.SetTo(NULL, "drivers/bus", false);
|
||||||
|
|
||||||
while (iterator.GetNext(path, stat) == B_OK) {
|
while (iterator.GetNext(path, stat) == B_OK) {
|
||||||
DirectoryIterator busIterator(path.Path(), NULL, true);
|
DirectoryIterator busIterator(path.Path(), NULL, true);
|
||||||
@ -1455,12 +1446,32 @@ probe_for_device_type(const char *type)
|
|||||||
if (!sWatching && gBootDevice > 0) {
|
if (!sWatching && gBootDevice > 0) {
|
||||||
// We're probing the actual boot volume for the first time,
|
// We're probing the actual boot volume for the first time,
|
||||||
// let's watch its driver directories for changes
|
// let's watch its driver directories for changes
|
||||||
|
const directory_which whichPath[] = {
|
||||||
|
B_USER_ADDONS_DIRECTORY,
|
||||||
|
B_COMMON_ADDONS_DIRECTORY,
|
||||||
|
B_BEOS_ADDONS_DIRECTORY
|
||||||
|
};
|
||||||
|
KPath path;
|
||||||
|
|
||||||
new(&sDirectoryWatcher) DirectoryWatcher;
|
new(&sDirectoryWatcher) DirectoryWatcher;
|
||||||
for (uint32 i = 0; kModulePaths[i] != NULL; i++) {
|
|
||||||
start_watching(kModulePaths[i], "drivers/dev");
|
bool disableUserAddOns = get_safemode_boolean(
|
||||||
start_watching(kModulePaths[i], "drivers/bin");
|
B_SAFEMODE_DISABLE_USER_ADD_ONS, false);
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < sizeof(whichPath) / sizeof(whichPath[0]); i++) {
|
||||||
|
if (i < 2 && disableUserAddOns)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (find_directory(whichPath[i], gBootDevice, true,
|
||||||
|
path.LockBuffer(), path.BufferSize()) == B_OK) {
|
||||||
|
path.UnlockBuffer();
|
||||||
|
path.Append("kernel/drivers");
|
||||||
|
|
||||||
|
start_watching(path.Path(), "dev");
|
||||||
|
start_watching(path.Path(), "bin");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sWatching = true;
|
sWatching = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user