First try at implementing driver rescans (this has been laying around my disk for quite some time).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23072 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2007-12-06 21:36:15 +00:00
parent 9b95b879f7
commit 849e3c6724

View File

@ -2476,3 +2476,34 @@ devfs_publish_directory(const char *path)
return publish_directory(sDeviceFileSystem, path);
}
extern "C" status_t
devfs_rescan_driver(const char *driverName)
{
TRACE(("devfs_rescan_driver: %s\n", driverName));
// iterate over the drivers and search a matching driverName
struct hash_iterator i;
hash_open(sDeviceFileSystem->driver_hash, &i);
driver_entry *driver = (driver_entry *)hash_next(
sDeviceFileSystem->driver_hash, &i);
while (driver) {
const char *name = strrchr(driver->path, '/');
if (name == NULL)
name = driver->path;
else
name++;
if (!strcmp(name, driverName)) {
hash_close(sDeviceFileSystem->driver_hash, &i, false);
// ToDo: force a uninit/init cycle on the driver if loaded
return load_driver(driver);
}
driver = (driver_entry *)hash_next(sDeviceFileSystem->driver_hash, &i);
}
hash_close(sDeviceFileSystem->driver_hash, &i, false);
return B_ENTRY_NOT_FOUND;
}